From: Guenter Roeck Date: Mon, 10 Dec 2018 22:02:09 +0000 (-0800) Subject: hwmon: (ibmaem) Use permission specific SENSOR[_DEVICE]_ATTR variants X-Git-Tag: v5.1-rc1~180^2~73 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=f6861c0eea3da6093c8576fe0d51c62f4168bec6;p=uclinux-h8%2Flinux.git 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_ 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 --- 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) /* sysfs support functions */ /* AEM device name */ -static ssize_t show_name(struct device *dev, struct device_attribute *devattr, +static ssize_t name_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct aem_data *data = dev_get_drvdata(dev); return sprintf(buf, "%s%d\n", DRVNAME, data->ver_major); } -static SENSOR_DEVICE_ATTR(name, S_IRUGO, show_name, NULL, 0); +static SENSOR_DEVICE_ATTR_RO(name, name, 0); /* AEM device version */ -static ssize_t show_version(struct device *dev, - struct device_attribute *devattr, - char *buf) +static ssize_t version_show(struct device *dev, + struct device_attribute *devattr, char *buf) { struct aem_data *data = dev_get_drvdata(dev); return sprintf(buf, "%d.%d\n", data->ver_major, data->ver_minor); } -static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, 0); +static SENSOR_DEVICE_ATTR_RO(version, version, 0); /* Display power use */ static ssize_t aem_show_power(struct device *dev, @@ -931,7 +930,7 @@ static int aem_register_sensors(struct aem_data *data, while (ro->label) { sysfs_attr_init(&sensors->dev_attr.attr); sensors->dev_attr.attr.name = ro->label; - sensors->dev_attr.attr.mode = S_IRUGO; + sensors->dev_attr.attr.mode = 0444; sensors->dev_attr.show = ro->show; sensors->index = ro->index; @@ -948,7 +947,7 @@ static int aem_register_sensors(struct aem_data *data, while (rw->label) { sysfs_attr_init(&sensors->dev_attr.attr); sensors->dev_attr.attr.name = rw->label; - sensors->dev_attr.attr.mode = S_IRUGO | S_IWUSR; + sensors->dev_attr.attr.mode = 0644; sensors->dev_attr.show = rw->show; sensors->dev_attr.store = rw->set; sensors->index = rw->index;