summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2018-12-10 17:02:09 -0500
committerGuenter Roeck <linux@roeck-us.net>2019-02-18 17:23:29 -0500
commitf6861c0eea3da6093c8576fe0d51c62f4168bec6 (patch)
tree29eebd3ec15dc7421766e793ae499f575ec93859
parent2f8f710236c9bd44fbed94f0b8dc306f350cbbef (diff)
hwmon: (ibmaem) 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. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r--drivers/hwmon/ibmaem.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
index 9e92673f6913..db63c1295cb2 100644
--- a/drivers/hwmon/ibmaem.c
+++ b/drivers/hwmon/ibmaem.c
@@ -813,25 +813,24 @@ static void aem_bmc_gone(int iface)
813/* sysfs support functions */ 813/* sysfs support functions */
814 814
815/* AEM device name */ 815/* AEM device name */
816static ssize_t show_name(struct device *dev, struct device_attribute *devattr, 816static ssize_t name_show(struct device *dev, struct device_attribute *devattr,
817 char *buf) 817 char *buf)
818{ 818{
819 struct aem_data *data = dev_get_drvdata(dev); 819 struct aem_data *data = dev_get_drvdata(dev);
820 820
821 return sprintf(buf, "%s%d\n", DRVNAME, data->ver_major); 821 return sprintf(buf, "%s%d\n", DRVNAME, data->ver_major);
822} 822}
823static SENSOR_DEVICE_ATTR(name, S_IRUGO, show_name, NULL, 0); 823static SENSOR_DEVICE_ATTR_RO(name, name, 0);
824 824
825/* AEM device version */ 825/* AEM device version */
826static ssize_t show_version(struct device *dev, 826static ssize_t version_show(struct device *dev,
827 struct device_attribute *devattr, 827 struct device_attribute *devattr, char *buf)
828 char *buf)
829{ 828{
830 struct aem_data *data = dev_get_drvdata(dev); 829 struct aem_data *data = dev_get_drvdata(dev);
831 830
832 return sprintf(buf, "%d.%d\n", data->ver_major, data->ver_minor); 831 return sprintf(buf, "%d.%d\n", data->ver_major, data->ver_minor);
833} 832}
834static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, 0); 833static SENSOR_DEVICE_ATTR_RO(version, version, 0);
835 834
836/* Display power use */ 835/* Display power use */
837static ssize_t aem_show_power(struct device *dev, 836static ssize_t aem_show_power(struct device *dev,
@@ -931,7 +930,7 @@ static int aem_register_sensors(struct aem_data *data,
931 while (ro->label) { 930 while (ro->label) {
932 sysfs_attr_init(&sensors->dev_attr.attr); 931 sysfs_attr_init(&sensors->dev_attr.attr);
933 sensors->dev_attr.attr.name = ro->label; 932 sensors->dev_attr.attr.name = ro->label;
934 sensors->dev_attr.attr.mode = S_IRUGO; 933 sensors->dev_attr.attr.mode = 0444;
935 sensors->dev_attr.show = ro->show; 934 sensors->dev_attr.show = ro->show;
936 sensors->index = ro->index; 935 sensors->index = ro->index;
937 936
@@ -948,7 +947,7 @@ static int aem_register_sensors(struct aem_data *data,
948 while (rw->label) { 947 while (rw->label) {
949 sysfs_attr_init(&sensors->dev_attr.attr); 948 sysfs_attr_init(&sensors->dev_attr.attr);
950 sensors->dev_attr.attr.name = rw->label; 949 sensors->dev_attr.attr.name = rw->label;
951 sensors->dev_attr.attr.mode = S_IRUGO | S_IWUSR; 950 sensors->dev_attr.attr.mode = 0644;
952 sensors->dev_attr.show = rw->show; 951 sensors->dev_attr.show = rw->show;
953 sensors->dev_attr.store = rw->set; 952 sensors->dev_attr.store = rw->set;
954 sensors->index = rw->index; 953 sensors->index = rw->index;