On 7/30/2020 4:54 PM, Herbert Xu wrote:
> Currently the debugfs fops are defined in caam/intern.h.  This causes
> problems because it creates identical static functions and variables
> in multiple files.  It also creates warnings when those files don't
> use the fops.
> 
Indeed, I see the warnings when compiling with W=1 and CONFIG_DEBUG_FS=y.

> This patch moves them into a standalone file, debugfs.c.
> 
> It also removes unnecessary uses of ifdefs on CONFIG_DEBUG_FS.
> 
> Signed-off-by: Herbert Xu <[email protected]>
> 
Below hunk is needed for fixing the compilation when CONFIG_DEBUG_FS=y:

diff --git a/drivers/crypto/caam/Makefile b/drivers/crypto/caam/Makefile
index 68d5cc0f28e2..a8d0d37408b2 100644
--- a/drivers/crypto/caam/Makefile
+++ b/drivers/crypto/caam/Makefile
@@ -15,6 +15,7 @@ obj-$(CONFIG_CRYPTO_DEV_FSL_CAAM_CRYPTO_API_DESC) += 
caamalg_desc.o
 obj-$(CONFIG_CRYPTO_DEV_FSL_CAAM_AHASH_API_DESC) += caamhash_desc.o

 caam-y := ctrl.o
+caam-$(CONFIG_DEBUG_FS) += debugfs.o
 caam_jr-y := jr.o key_gen.o
 caam_jr-$(CONFIG_CRYPTO_DEV_FSL_CAAM_CRYPTO_API) += caamalg.o
 caam_jr-$(CONFIG_CRYPTO_DEV_FSL_CAAM_CRYPTO_API_QI) += caamalg_qi.o

> -     ctrlpriv->ctl = debugfs_create_dir("ctl", dfs_root);
> +     ctl = debugfs_create_dir("ctl", dfs_root);
> +#ifdef CONFIG_DEBUG_FS
> +     ctrlpriv->ctl = ctl;
>  #endif
[...]
>       debugfs_create_blob("kek", S_IRUSR | S_IRGRP | S_IROTH, ctrlpriv->ctl,
> -                         &ctrlpriv->ctl_kek_wrap);
> +                         blob);
Compilation fails when CONFIG_DEBUG_FS=n.

s/ctrlpriv->ctl/ctl, here and below.

>  
> -     ctrlpriv->ctl_tkek_wrap.data = (__force void *)&ctrlpriv->ctrl->tkek[0];
> -     ctrlpriv->ctl_tkek_wrap.size = KEK_KEY_SIZE * sizeof(u32);
> +     blob = caam_debugfs_ptr(&ctrlpriv->ctl_tkek_wrap);
> +     blob->data = (__force void *)&ctrlpriv->ctrl->tkek[0];
> +     blob->size = KEK_KEY_SIZE * sizeof(u32);
>       debugfs_create_blob("tkek", S_IRUSR | S_IRGRP | S_IROTH, ctrlpriv->ctl,
> -                         &ctrlpriv->ctl_tkek_wrap);
> +                         blob);
>  
> -     ctrlpriv->ctl_tdsk_wrap.data = (__force void *)&ctrlpriv->ctrl->tdsk[0];
> -     ctrlpriv->ctl_tdsk_wrap.size = KEK_KEY_SIZE * sizeof(u32);
> +     blob = caam_debugfs_ptr(&ctrlpriv->ctl_tdsk_wrap);
> +     blob->data = (__force void *)&ctrlpriv->ctrl->tdsk[0];
> +     blob->size = KEK_KEY_SIZE * sizeof(u32);
>       debugfs_create_blob("tdsk", S_IRUSR | S_IRGRP | S_IROTH, ctrlpriv->ctl,
> -                         &ctrlpriv->ctl_tdsk_wrap);
> -#endif
> +                         blob);

Thanks,
Horia

Reply via email to