diff options
| author | Guenter Roeck <linux@roeck-us.net> | 2018-12-10 17:02:20 -0500 |
|---|---|---|
| committer | Guenter Roeck <linux@roeck-us.net> | 2019-02-18 17:23:29 -0500 |
| commit | 41c9a49ad338550d3c65a28c253b553d6e5332af (patch) | |
| tree | 4ca0f935858136924466416df39a3cbb896943d7 /drivers/hwmon | |
| parent | 6a0785aaf025b312a434dbcb81dac0cdd9f0a092 (diff) | |
hwmon: (sht15) 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>
Diffstat (limited to 'drivers/hwmon')
| -rw-r--r-- | drivers/hwmon/sht15.c | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c index c878242f3486..39b41e35c2bf 100644 --- a/drivers/hwmon/sht15.c +++ b/drivers/hwmon/sht15.c | |||
| @@ -677,9 +677,8 @@ static inline int sht15_calc_humid(struct sht15_data *data) | |||
| 677 | * and heater_enable sysfs attributes. | 677 | * and heater_enable sysfs attributes. |
| 678 | * Returns number of bytes written into buffer, negative errno on error. | 678 | * Returns number of bytes written into buffer, negative errno on error. |
| 679 | */ | 679 | */ |
| 680 | static ssize_t sht15_show_status(struct device *dev, | 680 | static ssize_t sht15_status_show(struct device *dev, |
| 681 | struct device_attribute *attr, | 681 | struct device_attribute *attr, char *buf) |
| 682 | char *buf) | ||
| 683 | { | 682 | { |
| 684 | int ret; | 683 | int ret; |
| 685 | struct sht15_data *data = dev_get_drvdata(dev); | 684 | struct sht15_data *data = dev_get_drvdata(dev); |
| @@ -700,7 +699,7 @@ static ssize_t sht15_show_status(struct device *dev, | |||
| 700 | * Will be called on write access to heater_enable sysfs attribute. | 699 | * Will be called on write access to heater_enable sysfs attribute. |
| 701 | * Returns number of bytes actually decoded, negative errno on error. | 700 | * Returns number of bytes actually decoded, negative errno on error. |
| 702 | */ | 701 | */ |
| 703 | static ssize_t sht15_store_heater(struct device *dev, | 702 | static ssize_t sht15_status_store(struct device *dev, |
| 704 | struct device_attribute *attr, | 703 | struct device_attribute *attr, |
| 705 | const char *buf, size_t count) | 704 | const char *buf, size_t count) |
| 706 | { | 705 | { |
| @@ -734,9 +733,8 @@ static ssize_t sht15_store_heater(struct device *dev, | |||
| 734 | * Will be called on read access to temp1_input sysfs attribute. | 733 | * Will be called on read access to temp1_input sysfs attribute. |
| 735 | * Returns number of bytes written into buffer, negative errno on error. | 734 | * Returns number of bytes written into buffer, negative errno on error. |
| 736 | */ | 735 | */ |
| 737 | static ssize_t sht15_show_temp(struct device *dev, | 736 | static ssize_t sht15_temp_show(struct device *dev, |
| 738 | struct device_attribute *attr, | 737 | struct device_attribute *attr, char *buf) |
| 739 | char *buf) | ||
| 740 | { | 738 | { |
| 741 | int ret; | 739 | int ret; |
| 742 | struct sht15_data *data = dev_get_drvdata(dev); | 740 | struct sht15_data *data = dev_get_drvdata(dev); |
| @@ -757,9 +755,8 @@ static ssize_t sht15_show_temp(struct device *dev, | |||
| 757 | * Will be called on read access to humidity1_input sysfs attribute. | 755 | * Will be called on read access to humidity1_input sysfs attribute. |
| 758 | * Returns number of bytes written into buffer, negative errno on error. | 756 | * Returns number of bytes written into buffer, negative errno on error. |
| 759 | */ | 757 | */ |
| 760 | static ssize_t sht15_show_humidity(struct device *dev, | 758 | static ssize_t sht15_humidity_show(struct device *dev, |
| 761 | struct device_attribute *attr, | 759 | struct device_attribute *attr, char *buf) |
| 762 | char *buf) | ||
| 763 | { | 760 | { |
| 764 | int ret; | 761 | int ret; |
| 765 | struct sht15_data *data = dev_get_drvdata(dev); | 762 | struct sht15_data *data = dev_get_drvdata(dev); |
| @@ -777,16 +774,13 @@ static ssize_t name_show(struct device *dev, | |||
| 777 | return sprintf(buf, "%s\n", pdev->name); | 774 | return sprintf(buf, "%s\n", pdev->name); |
| 778 | } | 775 | } |
| 779 | 776 | ||
| 780 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, | 777 | static SENSOR_DEVICE_ATTR_RO(temp1_input, sht15_temp, 0); |
| 781 | sht15_show_temp, NULL, 0); | 778 | static SENSOR_DEVICE_ATTR_RO(humidity1_input, sht15_humidity, 0); |
| 782 | static SENSOR_DEVICE_ATTR(humidity1_input, S_IRUGO, | 779 | static SENSOR_DEVICE_ATTR_RO(temp1_fault, sht15_status, |
| 783 | sht15_show_humidity, NULL, 0); | 780 | SHT15_STATUS_LOW_BATTERY); |
| 784 | static SENSOR_DEVICE_ATTR(temp1_fault, S_IRUGO, sht15_show_status, NULL, | 781 | static SENSOR_DEVICE_ATTR_RO(humidity1_fault, sht15_status, |
| 785 | SHT15_STATUS_LOW_BATTERY); | 782 | SHT15_STATUS_LOW_BATTERY); |
| 786 | static SENSOR_DEVICE_ATTR(humidity1_fault, S_IRUGO, sht15_show_status, NULL, | 783 | static SENSOR_DEVICE_ATTR_RW(heater_enable, sht15_status, SHT15_STATUS_HEATER); |
| 787 | SHT15_STATUS_LOW_BATTERY); | ||
| 788 | static SENSOR_DEVICE_ATTR(heater_enable, S_IRUGO | S_IWUSR, sht15_show_status, | ||
| 789 | sht15_store_heater, SHT15_STATUS_HEATER); | ||
| 790 | static DEVICE_ATTR_RO(name); | 784 | static DEVICE_ATTR_RO(name); |
| 791 | static struct attribute *sht15_attrs[] = { | 785 | static struct attribute *sht15_attrs[] = { |
| 792 | &sensor_dev_attr_temp1_input.dev_attr.attr, | 786 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
