.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * emc2103.c - Support for SMSC EMC2103 |
---|
3 | 4 | * Copyright (c) 2010 SMSC |
---|
4 | | - * |
---|
5 | | - * This program is free software; you can redistribute it and/or modify |
---|
6 | | - * it under the terms of the GNU General Public License as published by |
---|
7 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
8 | | - * (at your option) any later version. |
---|
9 | | - * |
---|
10 | | - * This program is distributed in the hope that it will be useful, |
---|
11 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
13 | | - * GNU General Public License for more details. |
---|
14 | | - * |
---|
15 | | - * You should have received a copy of the GNU General Public License |
---|
16 | | - * along with this program; if not, write to the Free Software |
---|
17 | | - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
18 | 5 | */ |
---|
19 | 6 | |
---|
20 | 7 | #include <linux/module.h> |
---|
.. | .. |
---|
185 | 172 | } |
---|
186 | 173 | |
---|
187 | 174 | static ssize_t |
---|
188 | | -show_temp(struct device *dev, struct device_attribute *da, char *buf) |
---|
| 175 | +temp_show(struct device *dev, struct device_attribute *da, char *buf) |
---|
189 | 176 | { |
---|
190 | 177 | int nr = to_sensor_dev_attr(da)->index; |
---|
191 | 178 | struct emc2103_data *data = emc2103_update_device(dev); |
---|
.. | .. |
---|
195 | 182 | } |
---|
196 | 183 | |
---|
197 | 184 | static ssize_t |
---|
198 | | -show_temp_min(struct device *dev, struct device_attribute *da, char *buf) |
---|
| 185 | +temp_min_show(struct device *dev, struct device_attribute *da, char *buf) |
---|
199 | 186 | { |
---|
200 | 187 | int nr = to_sensor_dev_attr(da)->index; |
---|
201 | 188 | struct emc2103_data *data = emc2103_update_device(dev); |
---|
.. | .. |
---|
204 | 191 | } |
---|
205 | 192 | |
---|
206 | 193 | static ssize_t |
---|
207 | | -show_temp_max(struct device *dev, struct device_attribute *da, char *buf) |
---|
| 194 | +temp_max_show(struct device *dev, struct device_attribute *da, char *buf) |
---|
208 | 195 | { |
---|
209 | 196 | int nr = to_sensor_dev_attr(da)->index; |
---|
210 | 197 | struct emc2103_data *data = emc2103_update_device(dev); |
---|
.. | .. |
---|
213 | 200 | } |
---|
214 | 201 | |
---|
215 | 202 | static ssize_t |
---|
216 | | -show_temp_fault(struct device *dev, struct device_attribute *da, char *buf) |
---|
| 203 | +temp_fault_show(struct device *dev, struct device_attribute *da, char *buf) |
---|
217 | 204 | { |
---|
218 | 205 | int nr = to_sensor_dev_attr(da)->index; |
---|
219 | 206 | struct emc2103_data *data = emc2103_update_device(dev); |
---|
.. | .. |
---|
222 | 209 | } |
---|
223 | 210 | |
---|
224 | 211 | static ssize_t |
---|
225 | | -show_temp_min_alarm(struct device *dev, struct device_attribute *da, char *buf) |
---|
| 212 | +temp_min_alarm_show(struct device *dev, struct device_attribute *da, |
---|
| 213 | + char *buf) |
---|
226 | 214 | { |
---|
227 | 215 | int nr = to_sensor_dev_attr(da)->index; |
---|
228 | 216 | struct emc2103_data *data = emc2103_update_device(dev); |
---|
.. | .. |
---|
231 | 219 | } |
---|
232 | 220 | |
---|
233 | 221 | static ssize_t |
---|
234 | | -show_temp_max_alarm(struct device *dev, struct device_attribute *da, char *buf) |
---|
| 222 | +temp_max_alarm_show(struct device *dev, struct device_attribute *da, |
---|
| 223 | + char *buf) |
---|
235 | 224 | { |
---|
236 | 225 | int nr = to_sensor_dev_attr(da)->index; |
---|
237 | 226 | struct emc2103_data *data = emc2103_update_device(dev); |
---|
.. | .. |
---|
239 | 228 | return sprintf(buf, "%d\n", alarm ? 1 : 0); |
---|
240 | 229 | } |
---|
241 | 230 | |
---|
242 | | -static ssize_t set_temp_min(struct device *dev, struct device_attribute *da, |
---|
243 | | - const char *buf, size_t count) |
---|
| 231 | +static ssize_t temp_min_store(struct device *dev, struct device_attribute *da, |
---|
| 232 | + const char *buf, size_t count) |
---|
244 | 233 | { |
---|
245 | 234 | int nr = to_sensor_dev_attr(da)->index; |
---|
246 | 235 | struct emc2103_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
261 | 250 | return count; |
---|
262 | 251 | } |
---|
263 | 252 | |
---|
264 | | -static ssize_t set_temp_max(struct device *dev, struct device_attribute *da, |
---|
265 | | - const char *buf, size_t count) |
---|
| 253 | +static ssize_t temp_max_store(struct device *dev, struct device_attribute *da, |
---|
| 254 | + const char *buf, size_t count) |
---|
266 | 255 | { |
---|
267 | 256 | int nr = to_sensor_dev_attr(da)->index; |
---|
268 | 257 | struct emc2103_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
470 | 459 | return count; |
---|
471 | 460 | } |
---|
472 | 461 | |
---|
473 | | -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); |
---|
474 | | -static SENSOR_DEVICE_ATTR(temp1_min, S_IRUGO | S_IWUSR, show_temp_min, |
---|
475 | | - set_temp_min, 0); |
---|
476 | | -static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, show_temp_max, |
---|
477 | | - set_temp_max, 0); |
---|
478 | | -static SENSOR_DEVICE_ATTR(temp1_fault, S_IRUGO, show_temp_fault, NULL, 0); |
---|
479 | | -static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_temp_min_alarm, |
---|
480 | | - NULL, 0); |
---|
481 | | -static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_temp_max_alarm, |
---|
482 | | - NULL, 0); |
---|
| 462 | +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0); |
---|
| 463 | +static SENSOR_DEVICE_ATTR_RW(temp1_min, temp_min, 0); |
---|
| 464 | +static SENSOR_DEVICE_ATTR_RW(temp1_max, temp_max, 0); |
---|
| 465 | +static SENSOR_DEVICE_ATTR_RO(temp1_fault, temp_fault, 0); |
---|
| 466 | +static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, temp_min_alarm, 0); |
---|
| 467 | +static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, temp_max_alarm, 0); |
---|
483 | 468 | |
---|
484 | | -static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1); |
---|
485 | | -static SENSOR_DEVICE_ATTR(temp2_min, S_IRUGO | S_IWUSR, show_temp_min, |
---|
486 | | - set_temp_min, 1); |
---|
487 | | -static SENSOR_DEVICE_ATTR(temp2_max, S_IRUGO | S_IWUSR, show_temp_max, |
---|
488 | | - set_temp_max, 1); |
---|
489 | | -static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_temp_fault, NULL, 1); |
---|
490 | | -static SENSOR_DEVICE_ATTR(temp2_min_alarm, S_IRUGO, show_temp_min_alarm, |
---|
491 | | - NULL, 1); |
---|
492 | | -static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_temp_max_alarm, |
---|
493 | | - NULL, 1); |
---|
| 469 | +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1); |
---|
| 470 | +static SENSOR_DEVICE_ATTR_RW(temp2_min, temp_min, 1); |
---|
| 471 | +static SENSOR_DEVICE_ATTR_RW(temp2_max, temp_max, 1); |
---|
| 472 | +static SENSOR_DEVICE_ATTR_RO(temp2_fault, temp_fault, 1); |
---|
| 473 | +static SENSOR_DEVICE_ATTR_RO(temp2_min_alarm, temp_min_alarm, 1); |
---|
| 474 | +static SENSOR_DEVICE_ATTR_RO(temp2_max_alarm, temp_max_alarm, 1); |
---|
494 | 475 | |
---|
495 | | -static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2); |
---|
496 | | -static SENSOR_DEVICE_ATTR(temp3_min, S_IRUGO | S_IWUSR, show_temp_min, |
---|
497 | | - set_temp_min, 2); |
---|
498 | | -static SENSOR_DEVICE_ATTR(temp3_max, S_IRUGO | S_IWUSR, show_temp_max, |
---|
499 | | - set_temp_max, 2); |
---|
500 | | -static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_temp_fault, NULL, 2); |
---|
501 | | -static SENSOR_DEVICE_ATTR(temp3_min_alarm, S_IRUGO, show_temp_min_alarm, |
---|
502 | | - NULL, 2); |
---|
503 | | -static SENSOR_DEVICE_ATTR(temp3_max_alarm, S_IRUGO, show_temp_max_alarm, |
---|
504 | | - NULL, 2); |
---|
| 476 | +static SENSOR_DEVICE_ATTR_RO(temp3_input, temp, 2); |
---|
| 477 | +static SENSOR_DEVICE_ATTR_RW(temp3_min, temp_min, 2); |
---|
| 478 | +static SENSOR_DEVICE_ATTR_RW(temp3_max, temp_max, 2); |
---|
| 479 | +static SENSOR_DEVICE_ATTR_RO(temp3_fault, temp_fault, 2); |
---|
| 480 | +static SENSOR_DEVICE_ATTR_RO(temp3_min_alarm, temp_min_alarm, 2); |
---|
| 481 | +static SENSOR_DEVICE_ATTR_RO(temp3_max_alarm, temp_max_alarm, 2); |
---|
505 | 482 | |
---|
506 | | -static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, 3); |
---|
507 | | -static SENSOR_DEVICE_ATTR(temp4_min, S_IRUGO | S_IWUSR, show_temp_min, |
---|
508 | | - set_temp_min, 3); |
---|
509 | | -static SENSOR_DEVICE_ATTR(temp4_max, S_IRUGO | S_IWUSR, show_temp_max, |
---|
510 | | - set_temp_max, 3); |
---|
511 | | -static SENSOR_DEVICE_ATTR(temp4_fault, S_IRUGO, show_temp_fault, NULL, 3); |
---|
512 | | -static SENSOR_DEVICE_ATTR(temp4_min_alarm, S_IRUGO, show_temp_min_alarm, |
---|
513 | | - NULL, 3); |
---|
514 | | -static SENSOR_DEVICE_ATTR(temp4_max_alarm, S_IRUGO, show_temp_max_alarm, |
---|
515 | | - NULL, 3); |
---|
| 483 | +static SENSOR_DEVICE_ATTR_RO(temp4_input, temp, 3); |
---|
| 484 | +static SENSOR_DEVICE_ATTR_RW(temp4_min, temp_min, 3); |
---|
| 485 | +static SENSOR_DEVICE_ATTR_RW(temp4_max, temp_max, 3); |
---|
| 486 | +static SENSOR_DEVICE_ATTR_RO(temp4_fault, temp_fault, 3); |
---|
| 487 | +static SENSOR_DEVICE_ATTR_RO(temp4_min_alarm, temp_min_alarm, 3); |
---|
| 488 | +static SENSOR_DEVICE_ATTR_RO(temp4_max_alarm, temp_max_alarm, 3); |
---|
516 | 489 | |
---|
517 | 490 | static DEVICE_ATTR_RO(fan1_input); |
---|
518 | 491 | static DEVICE_ATTR_RW(fan1_div); |
---|
.. | .. |
---|
578 | 551 | }; |
---|
579 | 552 | |
---|
580 | 553 | static int |
---|
581 | | -emc2103_probe(struct i2c_client *client, const struct i2c_device_id *id) |
---|
| 554 | +emc2103_probe(struct i2c_client *client) |
---|
582 | 555 | { |
---|
583 | 556 | struct emc2103_data *data; |
---|
584 | 557 | struct device *hwmon_dev; |
---|
.. | .. |
---|
680 | 653 | .driver = { |
---|
681 | 654 | .name = "emc2103", |
---|
682 | 655 | }, |
---|
683 | | - .probe = emc2103_probe, |
---|
| 656 | + .probe_new = emc2103_probe, |
---|
684 | 657 | .id_table = emc2103_ids, |
---|
685 | 658 | .detect = emc2103_detect, |
---|
686 | 659 | .address_list = normal_i2c, |
---|