Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hwmon: (vexpress-hwmon) Use permission specific SENSOR[_DEVICE]_ATTR variants

Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code,
to improve readability, and to reduce the chance of inconsistencies.

Also replace any remaining S_<PERMS> in the driver 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: Liviu Dudau <liviu.dudau@arm.com>
Cc: Sudeep Holla <sudeep.holla@arm.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Sudeep Holla <sudeep.holla@arm.com>
Acked-by: Liviu Dudau <liviu.dudau@arm.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

+10 -15
+10 -15
drivers/hwmon/vexpress-hwmon.c
··· 92 92 }; 93 93 94 94 #if !defined(CONFIG_REGULATOR_VEXPRESS) 95 - static DEVICE_ATTR(in1_label, S_IRUGO, vexpress_hwmon_label_show, NULL); 96 - static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, vexpress_hwmon_u32_show, 97 - NULL, 1000); 95 + static DEVICE_ATTR(in1_label, 0444, vexpress_hwmon_label_show, NULL); 96 + static SENSOR_DEVICE_ATTR_RO(in1_input, vexpress_hwmon_u32, 1000); 98 97 static struct attribute *vexpress_hwmon_attrs_volt[] = { 99 98 &dev_attr_in1_label.attr, 100 99 &sensor_dev_attr_in1_input.dev_attr.attr, ··· 112 113 }; 113 114 #endif 114 115 115 - static DEVICE_ATTR(curr1_label, S_IRUGO, vexpress_hwmon_label_show, NULL); 116 - static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, vexpress_hwmon_u32_show, 117 - NULL, 1000); 116 + static DEVICE_ATTR(curr1_label, 0444, vexpress_hwmon_label_show, NULL); 117 + static SENSOR_DEVICE_ATTR_RO(curr1_input, vexpress_hwmon_u32, 1000); 118 118 static struct attribute *vexpress_hwmon_attrs_amp[] = { 119 119 &dev_attr_curr1_label.attr, 120 120 &sensor_dev_attr_curr1_input.dev_attr.attr, ··· 131 133 }, 132 134 }; 133 135 134 - static DEVICE_ATTR(temp1_label, S_IRUGO, vexpress_hwmon_label_show, NULL); 135 - static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, vexpress_hwmon_u32_show, 136 - NULL, 1000); 136 + static DEVICE_ATTR(temp1_label, 0444, vexpress_hwmon_label_show, NULL); 137 + static SENSOR_DEVICE_ATTR_RO(temp1_input, vexpress_hwmon_u32, 1000); 137 138 static struct attribute *vexpress_hwmon_attrs_temp[] = { 138 139 &dev_attr_temp1_label.attr, 139 140 &sensor_dev_attr_temp1_input.dev_attr.attr, ··· 150 153 }, 151 154 }; 152 155 153 - static DEVICE_ATTR(power1_label, S_IRUGO, vexpress_hwmon_label_show, NULL); 154 - static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO, vexpress_hwmon_u32_show, 155 - NULL, 1); 156 + static DEVICE_ATTR(power1_label, 0444, vexpress_hwmon_label_show, NULL); 157 + static SENSOR_DEVICE_ATTR_RO(power1_input, vexpress_hwmon_u32, 1); 156 158 static struct attribute *vexpress_hwmon_attrs_power[] = { 157 159 &dev_attr_power1_label.attr, 158 160 &sensor_dev_attr_power1_input.dev_attr.attr, ··· 169 173 }, 170 174 }; 171 175 172 - static DEVICE_ATTR(energy1_label, S_IRUGO, vexpress_hwmon_label_show, NULL); 173 - static SENSOR_DEVICE_ATTR(energy1_input, S_IRUGO, vexpress_hwmon_u64_show, 174 - NULL, 1); 176 + static DEVICE_ATTR(energy1_label, 0444, vexpress_hwmon_label_show, NULL); 177 + static SENSOR_DEVICE_ATTR_RO(energy1_input, vexpress_hwmon_u64, 1); 175 178 static struct attribute *vexpress_hwmon_attrs_energy[] = { 176 179 &dev_attr_energy1_label.attr, 177 180 &sensor_dev_attr_energy1_input.dev_attr.attr,