linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] mmc: core: Use DEFINE_DEBUGFS_ATTRIBUTE instead of DEFINE_SIMPLE_ATTRIBUTE
@ 2020-04-23  9:15 Zou Wei
  2020-04-23 11:17 ` Ulf Hansson
  0 siblings, 1 reply; 4+ messages in thread
From: Zou Wei @ 2020-04-23  9:15 UTC (permalink / raw)
  To: ulf.hansson; +Cc: linux-mmc, linux-kernel, 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")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zou Wei <zou_wei@huawei.com>
---
 drivers/mmc/core/debugfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
index 09e0c76..9ec84c8 100644
--- a/drivers/mmc/core/debugfs.c
+++ b/drivers/mmc/core/debugfs.c
@@ -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)
-- 
2.6.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH -next] mmc: core: Use DEFINE_DEBUGFS_ATTRIBUTE instead of DEFINE_SIMPLE_ATTRIBUTE
  2020-04-23  9:15 [PATCH -next] mmc: core: Use DEFINE_DEBUGFS_ATTRIBUTE instead of DEFINE_SIMPLE_ATTRIBUTE Zou Wei
@ 2020-04-23 11:17 ` Ulf Hansson
  2020-04-23 11:55   ` 答复: " Zouwei (Samuel)
  0 siblings, 1 reply; 4+ messages in thread
From: Ulf Hansson @ 2020-04-23 11:17 UTC (permalink / raw)
  To: Zou Wei; +Cc: linux-mmc, Linux Kernel Mailing List

On Thu, 23 Apr 2020 at 11:09, Zou Wei <zou_wei@huawei.com> wrote:
>
> 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")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Zou Wei <zou_wei@huawei.com>
> ---
>  drivers/mmc/core/debugfs.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
> index 09e0c76..9ec84c8 100644
> --- a/drivers/mmc/core/debugfs.c
> +++ b/drivers/mmc/core/debugfs.c
> @@ -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);

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

[...]

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 4+ messages in thread

* 答复: [PATCH -next] mmc: core: Use DEFINE_DEBUGFS_ATTRIBUTE instead of DEFINE_SIMPLE_ATTRIBUTE
  2020-04-23 11:17 ` Ulf Hansson
@ 2020-04-23 11:55   ` Zouwei (Samuel)
  2020-04-23 12:21     ` Ulf Hansson
  0 siblings, 1 reply; 4+ messages in thread
From: Zouwei (Samuel) @ 2020-04-23 11:55 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: linux-mmc, Linux Kernel Mailing List

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:ulf.hansson@linaro.org] 
发送时间: 2020年4月23日 19:17
收件人: Zouwei (Samuel) <zou_wei@huawei.com>
抄送: linux-mmc@vger.kernel.org; Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
主题: Re: [PATCH -next] mmc: core: Use DEFINE_DEBUGFS_ATTRIBUTE instead of DEFINE_SIMPLE_ATTRIBUTE

On Thu, 23 Apr 2020 at 11:09, Zou Wei <zou_wei@huawei.com> wrote:
>
> 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")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Zou Wei <zou_wei@huawei.com>
> ---
>  drivers/mmc/core/debugfs.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c 
> index 09e0c76..9ec84c8 100644
> --- a/drivers/mmc/core/debugfs.c
> +++ b/drivers/mmc/core/debugfs.c
> @@ -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);

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

[...]

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -next] mmc: core: Use DEFINE_DEBUGFS_ATTRIBUTE instead of DEFINE_SIMPLE_ATTRIBUTE
  2020-04-23 11:55   ` 答复: " Zouwei (Samuel)
@ 2020-04-23 12:21     ` Ulf Hansson
  0 siblings, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2020-04-23 12:21 UTC (permalink / raw)
  To: Zouwei (Samuel); +Cc: linux-mmc, Linux Kernel Mailing List

On Thu, 23 Apr 2020 at 13:55, Zouwei (Samuel) <zou_wei@huawei.com> wrote:
>
> 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.

> 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.

>
> -----邮件原件-----
> 发件人: Ulf Hansson [mailto:ulf.hansson@linaro.org]
> 发送时间: 2020年4月23日 19:17
> 收件人: Zouwei (Samuel) <zou_wei@huawei.com>
> 抄送: linux-mmc@vger.kernel.org; Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
> 主题: Re: [PATCH -next] mmc: core: Use DEFINE_DEBUGFS_ATTRIBUTE instead of DEFINE_SIMPLE_ATTRIBUTE
>
> On Thu, 23 Apr 2020 at 11:09, Zou Wei <zou_wei@huawei.com> wrote:
> >
> > 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")
> > Reported-by: Hulk Robot <hulkci@huawei.com>
> > Signed-off-by: Zou Wei <zou_wei@huawei.com>

Applied for next, thanks!

Kind regards
Uffe

> > ---
> >  drivers/mmc/core/debugfs.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
> > index 09e0c76..9ec84c8 100644
> > --- a/drivers/mmc/core/debugfs.c
> > +++ b/drivers/mmc/core/debugfs.c
> > @@ -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);
>
> Apologize for my ignorance, but why convert to the *_unsafe option for this one, but not for the others?
>
> [...]
>
> Kind regards
> Uffe

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-04-23 12:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-23  9:15 [PATCH -next] mmc: core: Use DEFINE_DEBUGFS_ATTRIBUTE instead of DEFINE_SIMPLE_ATTRIBUTE Zou Wei
2020-04-23 11:17 ` Ulf Hansson
2020-04-23 11:55   ` 答复: " Zouwei (Samuel)
2020-04-23 12:21     ` Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).