[-next] mmc: block: fix debugfs_simple_attr.cocci warnings
diff mbox series

Message ID 1546047828-161783-1-git-send-email-yuehaibing@huawei.com
State New
Headers show
Series
  • [-next] mmc: block: fix debugfs_simple_attr.cocci warnings
Related show

Commit Message

YueHaibing Dec. 29, 2018, 1:43 a.m. UTC
Use DEFINE_DEBUGFS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTRIBUTE
for debugfs files.

Semantic patch information:
Rationale: DEFINE_SIMPLE_ATTRIBUTE + debugfs_create_file()
imposes some significant overhead as compared to
DEFINE_DEBUGFS_ATTRIBUTE + debugfs_create_file_unsafe().

Generated by: scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/mmc/core/block.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Ulf Hansson Jan. 14, 2019, 11:44 a.m. UTC | #1
On Sat, 29 Dec 2018 at 02:36, YueHaibing <yuehaibing@huawei.com> wrote:
>
> Use DEFINE_DEBUGFS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTRIBUTE
> for debugfs files.
>
> Semantic patch information:
> Rationale: DEFINE_SIMPLE_ATTRIBUTE + debugfs_create_file()
> imposes some significant overhead as compared to
> DEFINE_DEBUGFS_ATTRIBUTE + debugfs_create_file_unsafe().
>
> Generated by: scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci
>
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>

Applied for next, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/core/block.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
> index aef1185..b08fb91 100644
> --- a/drivers/mmc/core/block.c
> +++ b/drivers/mmc/core/block.c
> @@ -2774,8 +2774,8 @@ static int mmc_dbg_card_status_get(void *data, u64 *val)
>
>         return ret;
>  }
> -DEFINE_SIMPLE_ATTRIBUTE(mmc_dbg_card_status_fops, mmc_dbg_card_status_get,
> -               NULL, "%08llx\n");
> +DEFINE_DEBUGFS_ATTRIBUTE(mmc_dbg_card_status_fops, mmc_dbg_card_status_get,
> +                        NULL, "%08llx\n");
>
>  /* That is two digits * 512 + 1 for newline */
>  #define EXT_CSD_STR_LEN 1025
> @@ -2863,8 +2863,9 @@ static int mmc_blk_add_debugfs(struct mmc_card *card, struct mmc_blk_data *md)
>
>         if (mmc_card_mmc(card) || mmc_card_sd(card)) {
>                 md->status_dentry =
> -                       debugfs_create_file("status", S_IRUSR, root, card,
> -                                           &mmc_dbg_card_status_fops);
> +                       debugfs_create_file_unsafe("status", 0400, root,
> +                                                  card,
> +                                                  &mmc_dbg_card_status_fops);
>                 if (!md->status_dentry)
>                         return -EIO;
>         }
>
>
>
>
>

Patch
diff mbox series

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index aef1185..b08fb91 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -2774,8 +2774,8 @@  static int mmc_dbg_card_status_get(void *data, u64 *val)
 
 	return ret;
 }
-DEFINE_SIMPLE_ATTRIBUTE(mmc_dbg_card_status_fops, mmc_dbg_card_status_get,
-		NULL, "%08llx\n");
+DEFINE_DEBUGFS_ATTRIBUTE(mmc_dbg_card_status_fops, mmc_dbg_card_status_get,
+			 NULL, "%08llx\n");
 
 /* That is two digits * 512 + 1 for newline */
 #define EXT_CSD_STR_LEN 1025
@@ -2863,8 +2863,9 @@  static int mmc_blk_add_debugfs(struct mmc_card *card, struct mmc_blk_data *md)
 
 	if (mmc_card_mmc(card) || mmc_card_sd(card)) {
 		md->status_dentry =
-			debugfs_create_file("status", S_IRUSR, root, card,
-					    &mmc_dbg_card_status_fops);
+			debugfs_create_file_unsafe("status", 0400, root,
+						   card,
+						   &mmc_dbg_card_status_fops);
 		if (!md->status_dentry)
 			return -EIO;
 	}