Patchwork [v2,-next] ACPI: APEI: EINJ: Use DEFINE_DEBUGFS_ATTRIBUTE for debugfs files

login
register
mail settings
Submitter YueHaibing
Date Jan. 2, 2019, 11:54 a.m.
Message ID <1546430058-157207-1-git-send-email-yuehaibing@huawei.com>
Download mbox | patch
Permalink /patch/691603/
State New
Headers show

Comments

YueHaibing - Jan. 2, 2019, 11:54 a.m.
Use DEFINE_DEBUGFS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTRIBUTE
for debugfs files to make debugfs_simple_attr.cocci warnings go away.

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

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
v2: fix patch title and log
---
 drivers/acpi/apei/einj.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
Julia Lawall - Jan. 2, 2019, 12:33 p.m.
On Wed, 2 Jan 2019, YueHaibing wrote:

> Use DEFINE_DEBUGFS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTRIBUTE
> for debugfs files to make debugfs_simple_attr.cocci warnings go away.

Actually, make the errors go away, is not a very compelling motivation.
Rafael suggested you put the comment in the semantic patch.
Unfortunately, I didn't write the semantic patch, and I don't know
anything more about the issue.  You could contact the author if more
information is needed.

julia


>
> Generated by: scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci
>
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
> v2: fix patch title and log
> ---
>  drivers/acpi/apei/einj.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c
> index fcccbfd..6119da1 100644
> --- a/drivers/acpi/apei/einj.c
> +++ b/drivers/acpi/apei/einj.c
> @@ -644,8 +644,8 @@ static int error_type_set(void *data, u64 val)
>  	return 0;
>  }
>
> -DEFINE_SIMPLE_ATTRIBUTE(error_type_fops, error_type_get,
> -			error_type_set, "0x%llx\n");
> +DEFINE_DEBUGFS_ATTRIBUTE(error_type_fops, error_type_get, error_type_set,
> +			 "0x%llx\n");
>
>  static int error_inject_set(void *data, u64 val)
>  {
> @@ -656,8 +656,7 @@ static int error_inject_set(void *data, u64 val)
>  		error_param3, error_param4);
>  }
>
> -DEFINE_SIMPLE_ATTRIBUTE(error_inject_fops, NULL,
> -			error_inject_set, "%llu\n");
> +DEFINE_DEBUGFS_ATTRIBUTE(error_inject_fops, NULL, error_inject_set, "%llu\n");
>
>  static int einj_check_table(struct acpi_table_einj *einj_tab)
>  {
> @@ -718,12 +717,14 @@ static int __init einj_init(void)
>  	if (!fentry)
>  		goto err_cleanup;
>
> -	fentry = debugfs_create_file("error_type", S_IRUSR | S_IWUSR,
> -				     einj_debug_dir, NULL, &error_type_fops);
> +	fentry = debugfs_create_file_unsafe("error_type", 0600,
> +					    einj_debug_dir, NULL,
> +					    &error_type_fops);
>  	if (!fentry)
>  		goto err_cleanup;
> -	fentry = debugfs_create_file("error_inject", S_IWUSR,
> -				     einj_debug_dir, NULL, &error_inject_fops);
> +	fentry = debugfs_create_file_unsafe("error_inject", 0200,
> +					    einj_debug_dir, NULL,
> +					    &error_inject_fops);
>  	if (!fentry)
>  		goto err_cleanup;
>
>
>
>
YueHaibing - Jan. 2, 2019, 1:09 p.m.
On 2019/1/2 20:33, Julia Lawall wrote:
> 
> 
> On Wed, 2 Jan 2019, YueHaibing wrote:
> 
>> Use DEFINE_DEBUGFS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTRIBUTE
>> for debugfs files to make debugfs_simple_attr.cocci warnings go away.
> 
> Actually, make the errors go away, is not a very compelling motivation.
> Rafael suggested you put the comment in the semantic patch.
> Unfortunately, I didn't write the semantic patch, and I don't know
> anything more about the issue.  You could contact the author if more
> information is needed.

Oh, I forgot add the semantic patch's comment

> 
> julia
> 
> 
>>
>> Generated by: scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci
>>
>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
>> ---
>> v2: fix patch title and log
>> ---
>>  drivers/acpi/apei/einj.c | 17 +++++++++--------
>>  1 file changed, 9 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c
>> index fcccbfd..6119da1 100644
>> --- a/drivers/acpi/apei/einj.c
>> +++ b/drivers/acpi/apei/einj.c
>> @@ -644,8 +644,8 @@ static int error_type_set(void *data, u64 val)
>>  	return 0;
>>  }
>>
>> -DEFINE_SIMPLE_ATTRIBUTE(error_type_fops, error_type_get,
>> -			error_type_set, "0x%llx\n");
>> +DEFINE_DEBUGFS_ATTRIBUTE(error_type_fops, error_type_get, error_type_set,
>> +			 "0x%llx\n");
>>
>>  static int error_inject_set(void *data, u64 val)
>>  {
>> @@ -656,8 +656,7 @@ static int error_inject_set(void *data, u64 val)
>>  		error_param3, error_param4);
>>  }
>>
>> -DEFINE_SIMPLE_ATTRIBUTE(error_inject_fops, NULL,
>> -			error_inject_set, "%llu\n");
>> +DEFINE_DEBUGFS_ATTRIBUTE(error_inject_fops, NULL, error_inject_set, "%llu\n");
>>
>>  static int einj_check_table(struct acpi_table_einj *einj_tab)
>>  {
>> @@ -718,12 +717,14 @@ static int __init einj_init(void)
>>  	if (!fentry)
>>  		goto err_cleanup;
>>
>> -	fentry = debugfs_create_file("error_type", S_IRUSR | S_IWUSR,
>> -				     einj_debug_dir, NULL, &error_type_fops);
>> +	fentry = debugfs_create_file_unsafe("error_type", 0600,
>> +					    einj_debug_dir, NULL,
>> +					    &error_type_fops);
>>  	if (!fentry)
>>  		goto err_cleanup;
>> -	fentry = debugfs_create_file("error_inject", S_IWUSR,
>> -				     einj_debug_dir, NULL, &error_inject_fops);
>> +	fentry = debugfs_create_file_unsafe("error_inject", 0200,
>> +					    einj_debug_dir, NULL,
>> +					    &error_inject_fops);
>>  	if (!fentry)
>>  		goto err_cleanup;
>>
>>
>>
>>
> 
> .
>

Patch

diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c
index fcccbfd..6119da1 100644
--- a/drivers/acpi/apei/einj.c
+++ b/drivers/acpi/apei/einj.c
@@ -644,8 +644,8 @@  static int error_type_set(void *data, u64 val)
 	return 0;
 }
 
-DEFINE_SIMPLE_ATTRIBUTE(error_type_fops, error_type_get,
-			error_type_set, "0x%llx\n");
+DEFINE_DEBUGFS_ATTRIBUTE(error_type_fops, error_type_get, error_type_set,
+			 "0x%llx\n");
 
 static int error_inject_set(void *data, u64 val)
 {
@@ -656,8 +656,7 @@  static int error_inject_set(void *data, u64 val)
 		error_param3, error_param4);
 }
 
-DEFINE_SIMPLE_ATTRIBUTE(error_inject_fops, NULL,
-			error_inject_set, "%llu\n");
+DEFINE_DEBUGFS_ATTRIBUTE(error_inject_fops, NULL, error_inject_set, "%llu\n");
 
 static int einj_check_table(struct acpi_table_einj *einj_tab)
 {
@@ -718,12 +717,14 @@  static int __init einj_init(void)
 	if (!fentry)
 		goto err_cleanup;
 
-	fentry = debugfs_create_file("error_type", S_IRUSR | S_IWUSR,
-				     einj_debug_dir, NULL, &error_type_fops);
+	fentry = debugfs_create_file_unsafe("error_type", 0600,
+					    einj_debug_dir, NULL,
+					    &error_type_fops);
 	if (!fentry)
 		goto err_cleanup;
-	fentry = debugfs_create_file("error_inject", S_IWUSR,
-				     einj_debug_dir, NULL, &error_inject_fops);
+	fentry = debugfs_create_file_unsafe("error_inject", 0200,
+					    einj_debug_dir, NULL,
+					    &error_inject_fops);
 	if (!fentry)
 		goto err_cleanup;