Skip to contentSkip to conversation

mmc: core: Use DEFINE_DEBUGFS_ATTRIBUTE instead of DEFINE_SIMPLE_ATTRIBUTE

PATCH In review Zou Wei 2 participants 4 messages Apr 23, 2020 MMC, SD and SDIO

lore
Share & tools
lore

Zou Wei

author
#0 lore raw

PATCH 1/1 mmc: core: Use DEFINE_DEBUGFS_ATTRIBUTE instead of DEFINE_SIMPLE_ATTRIBUTE

Fixes coccicheck warning:

drivers/mmc/core/debugfs.c:222:0-23: WARNING: mmc_clock_fops should be defined with DEFINE_DEBUGFS_ATTRIBUTE

Use DEFINE_DEBUGFS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTRIBUTE for debugfs files

Fixes 703aae3d09a4b ("mmc: add a file to debugfs for changing host clock at runtime")
Fixes a04c50aaa916f ("mmc: core: no need to check return value of debugfs_create functions")
---
 drivers/mmc/core/debugfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mmc/core/debugfs.c +3 -3
index 09e0c76..9ec84c8 100644
@@ -219,7 +219,7 @@ static int mmc_clock_opt_set(void *data, u64 val)
 	return 0;
 }
 
-DEFINE_SIMPLE_ATTRIBUTE(mmc_clock_fops, mmc_clock_opt_get, mmc_clock_opt_set,
+DEFINE_DEBUGFS_ATTRIBUTE(mmc_clock_fops, mmc_clock_opt_get, mmc_clock_opt_set,
 	"%llu\n");
 
 void mmc_add_host_debugfs(struct mmc_host *host)
@@ -232,8 +232,8 @@ void mmc_add_host_debugfs(struct mmc_host *host)
 	debugfs_create_file("ios", S_IRUSR, root, host, &mmc_ios_fops);
 	debugfs_create_x32("caps", S_IRUSR, root, &host->caps);
 	debugfs_create_x32("caps2", S_IRUSR, root, &host->caps2);
-	debugfs_create_file("clock", S_IRUSR | S_IWUSR, root, host,
-			    &mmc_clock_fops);
+	debugfs_create_file_unsafe("clock", S_IRUSR | S_IWUSR, root, host,
+				   &mmc_clock_fops);
 
 #ifdef CONFIG_FAIL_MMC_REQUEST
 	if (fail_request)
Signature · 1 line
2.6.2
#1 lore raw
Quoted 31 lines · Zou Wei

Fixes coccicheck warning:

drivers/mmc/core/debugfs.c:222:0-23: WARNING: mmc_clock_fops should be defined with DEFINE_DEBUGFS_ATTRIBUTE

Use DEFINE_DEBUGFS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTRIBUTE for debugfs files

Fixes 703aae3d09a4b ("mmc: add a file to debugfs for changing host clock at runtime")
Fixes a04c50aaa916f ("mmc: core: no need to check return value of debugfs_create functions")
---
 drivers/mmc/core/debugfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mmc/core/debugfs.c +1 -1
index 09e0c76..9ec84c8 100644
@@ -219,7 +219,7 @@ static int mmc_clock_opt_set(void *data, u64 val)
        return 0;
 }
 
-DEFINE_SIMPLE_ATTRIBUTE(mmc_clock_fops, mmc_clock_opt_get, mmc_clock_opt_set,
+DEFINE_DEBUGFS_ATTRIBUTE(mmc_clock_fops, mmc_clock_opt_get, mmc_clock_opt_set,
        "%llu\n");
 
 void mmc_add_host_debugfs(struct mmc_host *host)

drivers/mmc/core/debugfs.c void mmc_add_host_debugfs(struct mmc_host *host) · line 236

Quoted 7 lines
drivers/mmc/core/debugfs.c +2 -2
@@ -232,8 +232,8 @@ void mmc_add_host_debugfs(struct mmc_host *host)
        debugfs_create_file("ios", S_IRUSR, root, host, &mmc_ios_fops);
        debugfs_create_x32("caps", S_IRUSR, root, &host->caps);
        debugfs_create_x32("caps2", S_IRUSR, root, &host->caps2);
-       debugfs_create_file("clock", S_IRUSR | S_IWUSR, root, host,
-                           &mmc_clock_fops);
+       debugfs_create_file_unsafe("clock", S_IRUSR | S_IWUSR, root, host,
+                                  &mmc_clock_fops);

Apologize for my ignorance, but why convert to the *_unsafe option for this one, but not for the others?

[...]

Kind regards
Uffe

#2 lore raw

Hi Ulf,

Thanks for your review and reply.

1. DEFINE_SIMPLE_ATTRIBUTE + debugfs_create_file() imposes some significant overhead as compared to DEFINE_DEBUGFS_ATTRIBUTE + debugfs_create_file_unsafe(). You can refer to the patch of 1a2b3666da58 ("mt76: fix debugfs_simple_attr.cocci warnings")
2. debugfs_create_file_unsafe(...&mmc_clock_fops) is corresponds to DEFINE_DEBUGFS_ATTRIBUTE(mmc_clock_fops...), so I only modified this one.

-----邮件原件-----
发件人: Ulf Hansson [mailto:[email protected]]
发送时间: 2020年4月23日 19:17
收件人: Zouwei (Samuel) <[email protected]>
抄送: [email protected]; Linux Kernel Mailing List <[email protected]> 主题: Re: [PATCH -next] mmc: core: Use DEFINE_DEBUGFS_ATTRIBUTE instead of DEFINE_SIMPLE_ATTRIBUTE

Quoted 38 lines · Zou Wei

Fixes coccicheck warning:

drivers/mmc/core/debugfs.c:222:0-23: WARNING: mmc_clock_fops should be defined with DEFINE_DEBUGFS_ATTRIBUTE

Use DEFINE_DEBUGFS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTRIBUTE for debugfs files

Fixes 703aae3d09a4b ("mmc: add a file to debugfs for changing host

clock at runtime")

Fixes a04c50aaa916f ("mmc: core: no need to check return value of

debugfs_create functions")

---
 drivers/mmc/core/debugfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mmc/core/debugfs.c +2 -1
index 09e0c76..9ec84c8 100644
@@ -219,7 +219,7 @@ static int mmc_clock_opt_set(void *data, u64 val)
        return 0;
 }
 
-DEFINE_SIMPLE_ATTRIBUTE(mmc_clock_fops, mmc_clock_opt_get, 
 mmc_clock_opt_set,
+DEFINE_DEBUGFS_ATTRIBUTE(mmc_clock_fops, mmc_clock_opt_get, 
+mmc_clock_opt_set,
        "%llu\n");
 
 void mmc_add_host_debugfs(struct mmc_host *host) @@ -232,8 +232,8 @@ 

void mmc_add_host_debugfs(struct mmc_host *host)

        debugfs_create_file("ios", S_IRUSR, root, host, &mmc_ios_fops);
        debugfs_create_x32("caps", S_IRUSR, root, &host->caps);
        debugfs_create_x32("caps2", S_IRUSR, root, &host->caps2);

drivers/mmc/core/debugfs.c void mmc_add_host_debugfs(struct mmc_host *host) · line 236

Quoted 4 lines
drivers/mmc/core/debugfs.c +2 -2
-       debugfs_create_file("clock", S_IRUSR | S_IWUSR, root, host,
-                           &mmc_clock_fops);
+       debugfs_create_file_unsafe("clock", S_IRUSR | S_IWUSR, root, host,
+                                  &mmc_clock_fops);

Apologize for my ignorance, but why convert to the *_unsafe option for this one, but not for the others?

[...]

Kind regards
Uffe

#3 lore raw
Quoted 7 lines · Zouwei (Samuel)

Hi Ulf,

Thanks for your review and reply.

1. DEFINE_SIMPLE_ATTRIBUTE + debugfs_create_file() imposes some significant overhead as compared to DEFINE_DEBUGFS_ATTRIBUTE + debugfs_create_file_unsafe(). You can refer to the patch of 1a2b3666da58 ("mt76: fix debugfs_simple_attr.cocci warnings")

I see.

Quoted 1 line

2. debugfs_create_file_unsafe(...&mmc_clock_fops) is corresponds to DEFINE_DEBUGFS_ATTRIBUTE(mmc_clock_fops...), so I only modified this one.

I have now read the complete function header of debugfs_create_file_unsafe() and realized that this is indeed okay.

Quoted 24 lines

-----邮件原件-----
发件人: Ulf Hansson [mailto:[email protected]]
发送时间: 2020年4月23日 19:17
收件人: Zouwei (Samuel) <[email protected]>
抄送: [email protected]; Linux Kernel Mailing List <[email protected]> 主题: Re: [PATCH -next] mmc: core: Use DEFINE_DEBUGFS_ATTRIBUTE instead of DEFINE_SIMPLE_ATTRIBUTE

Quoted 15 lines · Zou Wei

Fixes coccicheck warning:

drivers/mmc/core/debugfs.c:222:0-23: WARNING: mmc_clock_fops should be defined with DEFINE_DEBUGFS_ATTRIBUTE

Use DEFINE_DEBUGFS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTRIBUTE for debugfs files

Fixes 703aae3d09a4b ("mmc: add a file to debugfs for changing host

clock at runtime")

Fixes a04c50aaa916f ("mmc: core: no need to check return value of

debugfs_create functions")

Applied for next, thanks!

Kind regards
Uffe

Quoted 34 lines
Quoted 23 lines
---
 drivers/mmc/core/debugfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mmc/core/debugfs.c +2 -1
index 09e0c76..9ec84c8 100644
@@ -219,7 +219,7 @@ static int mmc_clock_opt_set(void *data, u64 val)
        return 0;
 }
 
-DEFINE_SIMPLE_ATTRIBUTE(mmc_clock_fops, mmc_clock_opt_get,
 mmc_clock_opt_set,
+DEFINE_DEBUGFS_ATTRIBUTE(mmc_clock_fops, mmc_clock_opt_get,
+mmc_clock_opt_set,
        "%llu\n");
 
 void mmc_add_host_debugfs(struct mmc_host *host) @@ -232,8 +232,8 @@

void mmc_add_host_debugfs(struct mmc_host *host)

        debugfs_create_file("ios", S_IRUSR, root, host, &mmc_ios_fops);
        debugfs_create_x32("caps", S_IRUSR, root, &host->caps);
        debugfs_create_x32("caps2", S_IRUSR, root, &host->caps2);

drivers/mmc/core/debugfs.c void mmc_add_host_debugfs(struct mmc_host *host) · line 236

Quoted 4 lines
drivers/mmc/core/debugfs.c +2 -2
-       debugfs_create_file("clock", S_IRUSR | S_IWUSR, root, host,
-                           &mmc_clock_fops);
+       debugfs_create_file_unsafe("clock", S_IRUSR | S_IWUSR, root, host,
+                                  &mmc_clock_fops);

Apologize for my ignorance, but why convert to the *_unsafe option for this one, but not for the others?

[...]

Kind regards
Uffe