.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * ds1621.c - Part of lm_sensors, Linux kernel modules for hardware |
---|
3 | 4 | * monitoring |
---|
.. | .. |
---|
18 | 19 | * Since the DS1621 was the first chipset supported by this driver, |
---|
19 | 20 | * most comments will refer to this chipset, but are actually general |
---|
20 | 21 | * and concern all supported chipsets, unless mentioned otherwise. |
---|
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/module.h> |
---|
.. | .. |
---|
234 | 221 | return data; |
---|
235 | 222 | } |
---|
236 | 223 | |
---|
237 | | -static ssize_t show_temp(struct device *dev, struct device_attribute *da, |
---|
| 224 | +static ssize_t temp_show(struct device *dev, struct device_attribute *da, |
---|
238 | 225 | char *buf) |
---|
239 | 226 | { |
---|
240 | 227 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); |
---|
.. | .. |
---|
243 | 230 | DS1621_TEMP_FROM_REG(data->temp[attr->index])); |
---|
244 | 231 | } |
---|
245 | 232 | |
---|
246 | | -static ssize_t set_temp(struct device *dev, struct device_attribute *da, |
---|
247 | | - const char *buf, size_t count) |
---|
| 233 | +static ssize_t temp_store(struct device *dev, struct device_attribute *da, |
---|
| 234 | + const char *buf, size_t count) |
---|
248 | 235 | { |
---|
249 | 236 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); |
---|
250 | 237 | struct ds1621_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
270 | 257 | return sprintf(buf, "%d\n", ALARMS_FROM_REG(data->conf)); |
---|
271 | 258 | } |
---|
272 | 259 | |
---|
273 | | -static ssize_t show_alarm(struct device *dev, struct device_attribute *da, |
---|
| 260 | +static ssize_t alarm_show(struct device *dev, struct device_attribute *da, |
---|
274 | 261 | char *buf) |
---|
275 | 262 | { |
---|
276 | 263 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); |
---|
.. | .. |
---|
319 | 306 | static DEVICE_ATTR_RO(alarms); |
---|
320 | 307 | static DEVICE_ATTR_RW(update_interval); |
---|
321 | 308 | |
---|
322 | | -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); |
---|
323 | | -static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp, set_temp, 1); |
---|
324 | | -static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp, set_temp, 2); |
---|
325 | | -static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_alarm, NULL, |
---|
326 | | - DS1621_ALARM_TEMP_LOW); |
---|
327 | | -static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, |
---|
328 | | - DS1621_ALARM_TEMP_HIGH); |
---|
| 309 | +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0); |
---|
| 310 | +static SENSOR_DEVICE_ATTR_RW(temp1_min, temp, 1); |
---|
| 311 | +static SENSOR_DEVICE_ATTR_RW(temp1_max, temp, 2); |
---|
| 312 | +static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, alarm, DS1621_ALARM_TEMP_LOW); |
---|
| 313 | +static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, DS1621_ALARM_TEMP_HIGH); |
---|
329 | 314 | |
---|
330 | 315 | static struct attribute *ds1621_attributes[] = { |
---|
331 | 316 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
---|
.. | .. |
---|
357 | 342 | }; |
---|
358 | 343 | __ATTRIBUTE_GROUPS(ds1621); |
---|
359 | 344 | |
---|
360 | | -static int ds1621_probe(struct i2c_client *client, |
---|
361 | | - const struct i2c_device_id *id) |
---|
| 345 | +static const struct i2c_device_id ds1621_id[]; |
---|
| 346 | + |
---|
| 347 | +static int ds1621_probe(struct i2c_client *client) |
---|
362 | 348 | { |
---|
363 | 349 | struct ds1621_data *data; |
---|
364 | 350 | struct device *hwmon_dev; |
---|
.. | .. |
---|
370 | 356 | |
---|
371 | 357 | mutex_init(&data->update_lock); |
---|
372 | 358 | |
---|
373 | | - data->kind = id->driver_data; |
---|
| 359 | + data->kind = i2c_match_id(ds1621_id, client)->driver_data; |
---|
374 | 360 | data->client = client; |
---|
375 | 361 | |
---|
376 | 362 | /* Initialize the DS1621 chip */ |
---|
.. | .. |
---|
398 | 384 | .driver = { |
---|
399 | 385 | .name = "ds1621", |
---|
400 | 386 | }, |
---|
401 | | - .probe = ds1621_probe, |
---|
| 387 | + .probe_new = ds1621_probe, |
---|
402 | 388 | .id_table = ds1621_id, |
---|
403 | 389 | }; |
---|
404 | 390 | |
---|