.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * adcxx.c |
---|
3 | 4 | * |
---|
.. | .. |
---|
18 | 19 | * |
---|
19 | 20 | * Handling of 8, 10 and 12 bits converters are the same, the |
---|
20 | 21 | * 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. |
---|
35 | 22 | */ |
---|
36 | 23 | |
---|
37 | 24 | #include <linux/init.h> |
---|
.. | .. |
---|
57 | 44 | }; |
---|
58 | 45 | |
---|
59 | 46 | /* 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) |
---|
62 | 49 | { |
---|
63 | 50 | struct spi_device *spi = to_spi_device(dev); |
---|
64 | 51 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
.. | .. |
---|
94 | 81 | return status; |
---|
95 | 82 | } |
---|
96 | 83 | |
---|
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) |
---|
99 | 86 | { |
---|
100 | 87 | /* The minimum reference is 0 for this chip family */ |
---|
101 | 88 | return sprintf(buf, "0\n"); |
---|
102 | 89 | } |
---|
103 | 90 | |
---|
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) |
---|
106 | 93 | { |
---|
107 | 94 | struct spi_device *spi = to_spi_device(dev); |
---|
108 | 95 | struct adcxx *adc = spi_get_drvdata(spi); |
---|
.. | .. |
---|
118 | 105 | return sprintf(buf, "%d\n", reference); |
---|
119 | 106 | } |
---|
120 | 107 | |
---|
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) |
---|
123 | 111 | { |
---|
124 | 112 | struct spi_device *spi = to_spi_device(dev); |
---|
125 | 113 | struct adcxx *adc = spi_get_drvdata(spi); |
---|
.. | .. |
---|
138 | 126 | return count; |
---|
139 | 127 | } |
---|
140 | 128 | |
---|
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) |
---|
143 | 131 | { |
---|
144 | 132 | return sprintf(buf, "%s\n", to_spi_device(dev)->modalias); |
---|
145 | 133 | } |
---|
146 | 134 | |
---|
147 | 135 | 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), |
---|
160 | 147 | }; |
---|
161 | 148 | |
---|
162 | 149 | /*----------------------------------------------------------------------*/ |
---|