hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/drivers/hwmon/adcxx.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * adcxx.c
34 *
....@@ -18,20 +19,6 @@
1819 *
1920 * Handling of 8, 10 and 12 bits converters are the same, the
2021 * unavailable bits are 0 :)
21
- *
22
- * This program is free software; you can redistribute it and/or modify
23
- * it under the terms of the GNU General Public License as published by
24
- * the Free Software Foundation; either version 2 of the License, or
25
- * (at your option) any later version.
26
- *
27
- * This program is distributed in the hope that it will be useful,
28
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
29
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30
- * GNU General Public License for more details.
31
- *
32
- * You should have received a copy of the GNU General Public License
33
- * along with this program; if not, write to the Free Software
34
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3522 */
3623
3724 #include <linux/init.h>
....@@ -57,8 +44,8 @@
5744 };
5845
5946 /* sysfs hook function */
60
-static ssize_t adcxx_read(struct device *dev,
61
- struct device_attribute *devattr, char *buf)
47
+static ssize_t adcxx_show(struct device *dev,
48
+ struct device_attribute *devattr, char *buf)
6249 {
6350 struct spi_device *spi = to_spi_device(dev);
6451 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
....@@ -94,15 +81,15 @@
9481 return status;
9582 }
9683
97
-static ssize_t adcxx_show_min(struct device *dev,
98
- struct device_attribute *devattr, char *buf)
84
+static ssize_t adcxx_min_show(struct device *dev,
85
+ struct device_attribute *devattr, char *buf)
9986 {
10087 /* The minimum reference is 0 for this chip family */
10188 return sprintf(buf, "0\n");
10289 }
10390
104
-static ssize_t adcxx_show_max(struct device *dev,
105
- struct device_attribute *devattr, char *buf)
91
+static ssize_t adcxx_max_show(struct device *dev,
92
+ struct device_attribute *devattr, char *buf)
10693 {
10794 struct spi_device *spi = to_spi_device(dev);
10895 struct adcxx *adc = spi_get_drvdata(spi);
....@@ -118,8 +105,9 @@
118105 return sprintf(buf, "%d\n", reference);
119106 }
120107
121
-static ssize_t adcxx_set_max(struct device *dev,
122
- struct device_attribute *devattr, const char *buf, size_t count)
108
+static ssize_t adcxx_max_store(struct device *dev,
109
+ struct device_attribute *devattr,
110
+ const char *buf, size_t count)
123111 {
124112 struct spi_device *spi = to_spi_device(dev);
125113 struct adcxx *adc = spi_get_drvdata(spi);
....@@ -138,25 +126,24 @@
138126 return count;
139127 }
140128
141
-static ssize_t adcxx_show_name(struct device *dev, struct device_attribute
142
- *devattr, char *buf)
129
+static ssize_t adcxx_name_show(struct device *dev,
130
+ struct device_attribute *devattr, char *buf)
143131 {
144132 return sprintf(buf, "%s\n", to_spi_device(dev)->modalias);
145133 }
146134
147135 static struct sensor_device_attribute ad_input[] = {
148
- SENSOR_ATTR(name, S_IRUGO, adcxx_show_name, NULL, 0),
149
- SENSOR_ATTR(in_min, S_IRUGO, adcxx_show_min, NULL, 0),
150
- SENSOR_ATTR(in_max, S_IWUSR | S_IRUGO, adcxx_show_max,
151
- adcxx_set_max, 0),
152
- SENSOR_ATTR(in0_input, S_IRUGO, adcxx_read, NULL, 0),
153
- SENSOR_ATTR(in1_input, S_IRUGO, adcxx_read, NULL, 1),
154
- SENSOR_ATTR(in2_input, S_IRUGO, adcxx_read, NULL, 2),
155
- SENSOR_ATTR(in3_input, S_IRUGO, adcxx_read, NULL, 3),
156
- SENSOR_ATTR(in4_input, S_IRUGO, adcxx_read, NULL, 4),
157
- SENSOR_ATTR(in5_input, S_IRUGO, adcxx_read, NULL, 5),
158
- SENSOR_ATTR(in6_input, S_IRUGO, adcxx_read, NULL, 6),
159
- SENSOR_ATTR(in7_input, S_IRUGO, adcxx_read, NULL, 7),
136
+ SENSOR_ATTR_RO(name, adcxx_name, 0),
137
+ SENSOR_ATTR_RO(in_min, adcxx_min, 0),
138
+ SENSOR_ATTR_RW(in_max, adcxx_max, 0),
139
+ SENSOR_ATTR_RO(in0_input, adcxx, 0),
140
+ SENSOR_ATTR_RO(in1_input, adcxx, 1),
141
+ SENSOR_ATTR_RO(in2_input, adcxx, 2),
142
+ SENSOR_ATTR_RO(in3_input, adcxx, 3),
143
+ SENSOR_ATTR_RO(in4_input, adcxx, 4),
144
+ SENSOR_ATTR_RO(in5_input, adcxx, 5),
145
+ SENSOR_ATTR_RO(in6_input, adcxx, 6),
146
+ SENSOR_ATTR_RO(in7_input, adcxx, 7),
160147 };
161148
162149 /*----------------------------------------------------------------------*/