.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Driver for +/-1 degree C, SMBus-Compatible Remote/Local Temperature Sensor |
---|
3 | 4 | * with Overtemperature Alarm |
---|
.. | .. |
---|
15 | 16 | * one external one). Complete datasheet can be |
---|
16 | 17 | * obtained from Maxim's website at: |
---|
17 | 18 | * http://datasheets.maxim-ic.com/en/ds/MAX6642.pdf |
---|
18 | | - * |
---|
19 | | - * This program is free software; you can redistribute it and/or modify |
---|
20 | | - * it under the terms of the GNU General Public License as published by |
---|
21 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
22 | | - * (at your option) any later version. |
---|
23 | | - * |
---|
24 | | - * This program is distributed in the hope that it will be useful, |
---|
25 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
26 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
27 | | - * GNU General Public License for more details. |
---|
28 | | - * |
---|
29 | | - * You should have received a copy of the GNU General Public License |
---|
30 | | - * along with this program; if not, write to the Free Software |
---|
31 | | - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
32 | 19 | */ |
---|
33 | 20 | |
---|
34 | 21 | |
---|
.. | .. |
---|
206 | 193 | * Sysfs stuff |
---|
207 | 194 | */ |
---|
208 | 195 | |
---|
209 | | -static ssize_t show_temp_max10(struct device *dev, |
---|
| 196 | +static ssize_t temp_max10_show(struct device *dev, |
---|
210 | 197 | struct device_attribute *dev_attr, char *buf) |
---|
211 | 198 | { |
---|
212 | 199 | struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); |
---|
.. | .. |
---|
216 | 203 | temp_from_reg10(data->temp_input[attr->index])); |
---|
217 | 204 | } |
---|
218 | 205 | |
---|
219 | | -static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr, |
---|
220 | | - char *buf) |
---|
| 206 | +static ssize_t temp_max_show(struct device *dev, |
---|
| 207 | + struct device_attribute *attr, char *buf) |
---|
221 | 208 | { |
---|
222 | 209 | struct sensor_device_attribute_2 *attr2 = to_sensor_dev_attr_2(attr); |
---|
223 | 210 | struct max6642_data *data = max6642_update_device(dev); |
---|
.. | .. |
---|
225 | 212 | return sprintf(buf, "%d\n", temp_from_reg(data->temp_high[attr2->nr])); |
---|
226 | 213 | } |
---|
227 | 214 | |
---|
228 | | -static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, |
---|
229 | | - const char *buf, size_t count) |
---|
| 215 | +static ssize_t temp_max_store(struct device *dev, |
---|
| 216 | + struct device_attribute *attr, const char *buf, |
---|
| 217 | + size_t count) |
---|
230 | 218 | { |
---|
231 | 219 | struct sensor_device_attribute_2 *attr2 = to_sensor_dev_attr_2(attr); |
---|
232 | 220 | struct max6642_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
245 | 233 | return count; |
---|
246 | 234 | } |
---|
247 | 235 | |
---|
248 | | -static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, |
---|
| 236 | +static ssize_t alarm_show(struct device *dev, struct device_attribute *attr, |
---|
249 | 237 | char *buf) |
---|
250 | 238 | { |
---|
251 | 239 | int bitnr = to_sensor_dev_attr(attr)->index; |
---|
.. | .. |
---|
253 | 241 | return sprintf(buf, "%d\n", (data->alarms >> bitnr) & 1); |
---|
254 | 242 | } |
---|
255 | 243 | |
---|
256 | | -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_max10, NULL, 0); |
---|
257 | | -static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp_max10, NULL, 1); |
---|
258 | | -static SENSOR_DEVICE_ATTR_2(temp1_max, S_IWUSR | S_IRUGO, show_temp_max, |
---|
259 | | - set_temp_max, 0, MAX6642_REG_W_LOCAL_HIGH); |
---|
260 | | -static SENSOR_DEVICE_ATTR_2(temp2_max, S_IWUSR | S_IRUGO, show_temp_max, |
---|
261 | | - set_temp_max, 1, MAX6642_REG_W_REMOTE_HIGH); |
---|
262 | | -static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 2); |
---|
263 | | -static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6); |
---|
264 | | -static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 4); |
---|
| 244 | +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp_max10, 0); |
---|
| 245 | +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp_max10, 1); |
---|
| 246 | +static SENSOR_DEVICE_ATTR_2_RW(temp1_max, temp_max, 0, |
---|
| 247 | + MAX6642_REG_W_LOCAL_HIGH); |
---|
| 248 | +static SENSOR_DEVICE_ATTR_2_RW(temp2_max, temp_max, 1, |
---|
| 249 | + MAX6642_REG_W_REMOTE_HIGH); |
---|
| 250 | +static SENSOR_DEVICE_ATTR_RO(temp2_fault, alarm, 2); |
---|
| 251 | +static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, 6); |
---|
| 252 | +static SENSOR_DEVICE_ATTR_RO(temp2_max_alarm, alarm, 4); |
---|
265 | 253 | |
---|
266 | 254 | static struct attribute *max6642_attrs[] = { |
---|
267 | 255 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
---|
.. | .. |
---|
276 | 264 | }; |
---|
277 | 265 | ATTRIBUTE_GROUPS(max6642); |
---|
278 | 266 | |
---|
279 | | -static int max6642_probe(struct i2c_client *client, |
---|
280 | | - const struct i2c_device_id *id) |
---|
| 267 | +static int max6642_probe(struct i2c_client *client) |
---|
281 | 268 | { |
---|
282 | 269 | struct device *dev = &client->dev; |
---|
283 | 270 | struct max6642_data *data; |
---|
.. | .. |
---|
314 | 301 | .driver = { |
---|
315 | 302 | .name = "max6642", |
---|
316 | 303 | }, |
---|
317 | | - .probe = max6642_probe, |
---|
| 304 | + .probe_new = max6642_probe, |
---|
318 | 305 | .id_table = max6642_id, |
---|
319 | 306 | .detect = max6642_detect, |
---|
320 | 307 | .address_list = normal_i2c, |
---|