Linux-Hwmon Archive on lore.kernel.org
 help / Atom feed
* [PATCH -next] hwmon: Fix debugfs_simple_attr.cocci warnings
@ 2018-12-12  8:36 YueHaibing
  2018-12-12 14:45 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: YueHaibing @ 2018-12-12  8:36 UTC (permalink / raw)
  To: Luca Tettamanti, Jean Delvare, Guenter Roeck
  Cc: YueHaibing, linux-hwmon, kernel-janitors

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/hwmon/asus_atk0110.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
index a5638d1..22be78c 100644
--- a/drivers/hwmon/asus_atk0110.c
+++ b/drivers/hwmon/asus_atk0110.c
@@ -681,10 +681,8 @@ static int atk_debugfs_gitm_get(void *p, u64 *val)
 	return err;
 }
 
-DEFINE_SIMPLE_ATTRIBUTE(atk_debugfs_gitm,
-			atk_debugfs_gitm_get,
-			NULL,
-			"0x%08llx\n");
+DEFINE_DEBUGFS_ATTRIBUTE(atk_debugfs_gitm, atk_debugfs_gitm_get, NULL,
+			 "0x%08llx\n");
 
 static int atk_acpi_print(char *buf, size_t sz, union acpi_object *obj)
 {
@@ -803,8 +801,8 @@ static void atk_debugfs_init(struct atk_data *data)
 	if (!f || IS_ERR(f))
 		goto cleanup;
 
-	f = debugfs_create_file("gitm", 0400, d, data,
-				&atk_debugfs_gitm);
+	f = debugfs_create_file_unsafe("gitm", 0400, d, data,
+				       &atk_debugfs_gitm);
 	if (!f || IS_ERR(f))
 		goto cleanup;
 

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

* Re: [PATCH -next] hwmon: Fix debugfs_simple_attr.cocci warnings
  2018-12-12  8:36 [PATCH -next] hwmon: Fix debugfs_simple_attr.cocci warnings YueHaibing
@ 2018-12-12 14:45 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2018-12-12 14:45 UTC (permalink / raw)
  To: YueHaibing; +Cc: Luca Tettamanti, Jean Delvare, linux-hwmon, kernel-janitors

On Wed, Dec 12, 2018 at 08:36:36AM +0000, YueHaibing 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. In future patches, please refer to the affected driver in the
subject line.

Thanks,
Guenter

> ---
>  drivers/hwmon/asus_atk0110.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
> index a5638d1..22be78c 100644
> --- a/drivers/hwmon/asus_atk0110.c
> +++ b/drivers/hwmon/asus_atk0110.c
> @@ -681,10 +681,8 @@ static int atk_debugfs_gitm_get(void *p, u64 *val)
>  	return err;
>  }
>  
> -DEFINE_SIMPLE_ATTRIBUTE(atk_debugfs_gitm,
> -			atk_debugfs_gitm_get,
> -			NULL,
> -			"0x%08llx\n");
> +DEFINE_DEBUGFS_ATTRIBUTE(atk_debugfs_gitm, atk_debugfs_gitm_get, NULL,
> +			 "0x%08llx\n");
>  
>  static int atk_acpi_print(char *buf, size_t sz, union acpi_object *obj)
>  {
> @@ -803,8 +801,8 @@ static void atk_debugfs_init(struct atk_data *data)
>  	if (!f || IS_ERR(f))
>  		goto cleanup;
>  
> -	f = debugfs_create_file("gitm", 0400, d, data,
> -				&atk_debugfs_gitm);
> +	f = debugfs_create_file_unsafe("gitm", 0400, d, data,
> +				       &atk_debugfs_gitm);
>  	if (!f || IS_ERR(f))
>  		goto cleanup;
>  

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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-12  8:36 [PATCH -next] hwmon: Fix debugfs_simple_attr.cocci warnings YueHaibing
2018-12-12 14:45 ` Guenter Roeck

Linux-Hwmon Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-hwmon/0 linux-hwmon/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-hwmon linux-hwmon/ https://lore.kernel.org/linux-hwmon \
		linux-hwmon@vger.kernel.org linux-hwmon@archiver.kernel.org
	public-inbox-index linux-hwmon


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-hwmon


AGPL code for this site: git clone https://public-inbox.org/ public-inbox