linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hwmon: (pmbus_core) Replace S_<PERMS> with octal values
@ 2019-04-14 21:57 Guenter Roeck
  2019-04-14 22:22 ` Adamski, Krzysztof (Nokia - PL/Wroclaw)
  0 siblings, 1 reply; 3+ messages in thread
From: Guenter Roeck @ 2019-04-14 21:57 UTC (permalink / raw)
  To: Hardware Monitoring; +Cc: Jean Delvare, Guenter Roeck, Krzysztof Adamski

Replace S_<PERMS> with octal values.

The conversion was done automatically with coccinelle. The semantic patches
and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches/hwmon/.

This patch does not introduce functional changes. It was verified by
compiling the old and new files and comparing text and data sizes.

Cc: Krzysztof Adamski <krzysztof.adamski@nokia.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/hwmon/pmbus/pmbus_core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index 2e2b5851139c..e2366428a9a9 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -1073,7 +1073,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
 		 name, seq, type);
 	boolean->s1 = s1;
 	boolean->s2 = s2;
-	pmbus_attr_init(a, boolean->name, S_IRUGO, pmbus_show_boolean, NULL,
+	pmbus_attr_init(a, boolean->name, 0444, pmbus_show_boolean, NULL,
 			(reg << 16) | mask);
 
 	return pmbus_add_attribute(data, &a->dev_attr.attr);
@@ -1107,7 +1107,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
 	sensor->update = update;
 	sensor->convert = convert;
 	pmbus_dev_attr_init(a, sensor->name,
-			    readonly ? S_IRUGO : S_IRUGO | S_IWUSR,
+			    readonly ? 0444 : 0644,
 			    pmbus_show_sensor, pmbus_set_sensor);
 
 	if (pmbus_add_attribute(data, &a->attr))
@@ -1139,7 +1139,7 @@ static int pmbus_add_label(struct pmbus_data *data,
 		snprintf(label->label, sizeof(label->label), "%s%d", lstring,
 			 index);
 
-	pmbus_dev_attr_init(a, label->name, S_IRUGO, pmbus_show_label, NULL);
+	pmbus_dev_attr_init(a, label->name, 0444, pmbus_show_label, NULL);
 	return pmbus_add_attribute(data, &a->attr);
 }
 
-- 
2.7.4


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

* Re: [PATCH] hwmon: (pmbus_core) Replace S_<PERMS> with octal values
  2019-04-14 21:57 [PATCH] hwmon: (pmbus_core) Replace S_<PERMS> with octal values Guenter Roeck
@ 2019-04-14 22:22 ` Adamski, Krzysztof (Nokia - PL/Wroclaw)
  2019-04-15 13:38   ` Guenter Roeck
  0 siblings, 1 reply; 3+ messages in thread
From: Adamski, Krzysztof (Nokia - PL/Wroclaw) @ 2019-04-14 22:22 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: Hardware Monitoring, Jean Delvare

On Sun, Apr 14, 2019 at 02:57:24PM -0700, Guenter Roeck wrote:
>Replace S_<PERMS> with octal values.
>
>The conversion was done automatically with coccinelle. The semantic patches
>and the scripts used to generate this commit log are available at
>https://github.com/groeck/coccinelle-patches/hwmon/.

The URL is 404. blob/master/hwmon instead of just hwmon at the end would
work.

>This patch does not introduce functional changes. It was verified by
>compiling the old and new files and comparing text and data sizes.

I don't think that the sizes would change even if there was some error
introuced if it still compiles. But of course both the conccinele script
is ok and I manually verified the patch. Also, git grep "\bS_" pmbus*
does not return anything meaning all the places were converted.

>Cc: Krzysztof Adamski <krzysztof.adamski@nokia.com>
>Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>---
> drivers/hwmon/pmbus/pmbus_core.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
>diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
>index 2e2b5851139c..e2366428a9a9 100644
>--- a/drivers/hwmon/pmbus/pmbus_core.c
>+++ b/drivers/hwmon/pmbus/pmbus_core.c
>@@ -1073,7 +1073,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
> 		 name, seq, type);
> 	boolean->s1 = s1;
> 	boolean->s2 = s2;
>-	pmbus_attr_init(a, boolean->name, S_IRUGO, pmbus_show_boolean, NULL,
>+	pmbus_attr_init(a, boolean->name, 0444, pmbus_show_boolean, NULL,
> 			(reg << 16) | mask);
>
> 	return pmbus_add_attribute(data, &a->dev_attr.attr);
>@@ -1107,7 +1107,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
> 	sensor->update = update;
> 	sensor->convert = convert;
> 	pmbus_dev_attr_init(a, sensor->name,
>-			    readonly ? S_IRUGO : S_IRUGO | S_IWUSR,
>+			    readonly ? 0444 : 0644,
> 			    pmbus_show_sensor, pmbus_set_sensor);
>
> 	if (pmbus_add_attribute(data, &a->attr))
>@@ -1139,7 +1139,7 @@ static int pmbus_add_label(struct pmbus_data *data,
> 		snprintf(label->label, sizeof(label->label), "%s%d", lstring,
> 			 index);
>
>-	pmbus_dev_attr_init(a, label->name, S_IRUGO, pmbus_show_label, NULL);
>+	pmbus_dev_attr_init(a, label->name, 0444, pmbus_show_label, NULL);
> 	return pmbus_add_attribute(data, &a->attr);
> }
>
>-- 
>2.7.4
>

Krzysztof

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

* Re: [PATCH] hwmon: (pmbus_core) Replace S_<PERMS> with octal values
  2019-04-14 22:22 ` Adamski, Krzysztof (Nokia - PL/Wroclaw)
@ 2019-04-15 13:38   ` Guenter Roeck
  0 siblings, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2019-04-15 13:38 UTC (permalink / raw)
  To: Adamski, Krzysztof (Nokia - PL/Wroclaw); +Cc: Hardware Monitoring, Jean Delvare

On 4/14/19 3:22 PM, Adamski, Krzysztof (Nokia - PL/Wroclaw) wrote:
> On Sun, Apr 14, 2019 at 02:57:24PM -0700, Guenter Roeck wrote:
>> Replace S_<PERMS> with octal values.
>>
>> The conversion was done automatically with coccinelle. The semantic patches
>> and the scripts used to generate this commit log are available at
>> https://github.com/groeck/coccinelle-patches/hwmon/.
> 
> The URL is 404. blob/master/hwmon instead of just hwmon at the end would
> work.
> 
Thanks for noticing. Looks like github changed references since I wrote
the automated scripts. Oh well. I'll drop the hwmon part from all similar
patches.

>> This patch does not introduce functional changes. It was verified by
>> compiling the old and new files and comparing text and data sizes.
> 
> I don't think that the sizes would change even if there was some error
> introuced if it still compiles. But of course both the conccinele script
> is ok and I manually verified the patch. Also, git grep "\bS_" pmbus*
> does not return anything meaning all the places were converted.
> 

It may not catch all cases, that is correct, but it does help.

Guenter

>> Cc: Krzysztof Adamski <krzysztof.adamski@nokia.com>
>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>> ---
>> drivers/hwmon/pmbus/pmbus_core.c | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
>> index 2e2b5851139c..e2366428a9a9 100644
>> --- a/drivers/hwmon/pmbus/pmbus_core.c
>> +++ b/drivers/hwmon/pmbus/pmbus_core.c
>> @@ -1073,7 +1073,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
>> 		 name, seq, type);
>> 	boolean->s1 = s1;
>> 	boolean->s2 = s2;
>> -	pmbus_attr_init(a, boolean->name, S_IRUGO, pmbus_show_boolean, NULL,
>> +	pmbus_attr_init(a, boolean->name, 0444, pmbus_show_boolean, NULL,
>> 			(reg << 16) | mask);
>>
>> 	return pmbus_add_attribute(data, &a->dev_attr.attr);
>> @@ -1107,7 +1107,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
>> 	sensor->update = update;
>> 	sensor->convert = convert;
>> 	pmbus_dev_attr_init(a, sensor->name,
>> -			    readonly ? S_IRUGO : S_IRUGO | S_IWUSR,
>> +			    readonly ? 0444 : 0644,
>> 			    pmbus_show_sensor, pmbus_set_sensor);
>>
>> 	if (pmbus_add_attribute(data, &a->attr))
>> @@ -1139,7 +1139,7 @@ static int pmbus_add_label(struct pmbus_data *data,
>> 		snprintf(label->label, sizeof(label->label), "%s%d", lstring,
>> 			 index);
>>
>> -	pmbus_dev_attr_init(a, label->name, S_IRUGO, pmbus_show_label, NULL);
>> +	pmbus_dev_attr_init(a, label->name, 0444, pmbus_show_label, NULL);
>> 	return pmbus_add_attribute(data, &a->attr);
>> }
>>
>> -- 
>> 2.7.4
>>
> 
> Krzysztof
> 


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

end of thread, other threads:[~2019-04-15 13:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-14 21:57 [PATCH] hwmon: (pmbus_core) Replace S_<PERMS> with octal values Guenter Roeck
2019-04-14 22:22 ` Adamski, Krzysztof (Nokia - PL/Wroclaw)
2019-04-15 13:38   ` Guenter Roeck

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