.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * nct7802 - Driver for Nuvoton NCT7802Y |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2014 Guenter Roeck <linux@roeck-us.net> |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify |
---|
7 | | - * it under the terms of the GNU General Public License as published by |
---|
8 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
9 | | - * (at your option) any later version. |
---|
10 | | - * |
---|
11 | | - * This program is distributed in the hope that it will be useful, |
---|
12 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | | - * GNU General Public License for more details. |
---|
15 | 6 | */ |
---|
16 | 7 | |
---|
17 | 8 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
---|
.. | .. |
---|
67 | 58 | struct nct7802_data { |
---|
68 | 59 | struct regmap *regmap; |
---|
69 | 60 | struct mutex access_lock; /* for multi-byte read and write operations */ |
---|
| 61 | + u8 in_status; |
---|
| 62 | + struct mutex in_alarm_lock; |
---|
70 | 63 | }; |
---|
71 | 64 | |
---|
72 | | -static ssize_t show_temp_type(struct device *dev, struct device_attribute *attr, |
---|
73 | | - char *buf) |
---|
| 65 | +static ssize_t temp_type_show(struct device *dev, |
---|
| 66 | + struct device_attribute *attr, char *buf) |
---|
74 | 67 | { |
---|
75 | 68 | struct nct7802_data *data = dev_get_drvdata(dev); |
---|
76 | 69 | struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr); |
---|
.. | .. |
---|
84 | 77 | return sprintf(buf, "%u\n", (mode >> (2 * sattr->index) & 3) + 2); |
---|
85 | 78 | } |
---|
86 | 79 | |
---|
87 | | -static ssize_t store_temp_type(struct device *dev, |
---|
88 | | - struct device_attribute *attr, |
---|
89 | | - const char *buf, size_t count) |
---|
| 80 | +static ssize_t temp_type_store(struct device *dev, |
---|
| 81 | + struct device_attribute *attr, const char *buf, |
---|
| 82 | + size_t count) |
---|
90 | 83 | { |
---|
91 | 84 | struct nct7802_data *data = dev_get_drvdata(dev); |
---|
92 | 85 | struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr); |
---|
.. | .. |
---|
105 | 98 | return err ? : count; |
---|
106 | 99 | } |
---|
107 | 100 | |
---|
108 | | -static ssize_t show_pwm_mode(struct device *dev, struct device_attribute *attr, |
---|
109 | | - char *buf) |
---|
| 101 | +static ssize_t pwm_mode_show(struct device *dev, |
---|
| 102 | + struct device_attribute *attr, char *buf) |
---|
110 | 103 | { |
---|
111 | 104 | struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr); |
---|
112 | 105 | struct nct7802_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
123 | 116 | return sprintf(buf, "%u\n", !(regval & (1 << sattr->index))); |
---|
124 | 117 | } |
---|
125 | 118 | |
---|
126 | | -static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, |
---|
| 119 | +static ssize_t pwm_show(struct device *dev, struct device_attribute *devattr, |
---|
127 | 120 | char *buf) |
---|
128 | 121 | { |
---|
129 | 122 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
.. | .. |
---|
141 | 134 | return sprintf(buf, "%d\n", val); |
---|
142 | 135 | } |
---|
143 | 136 | |
---|
144 | | -static ssize_t store_pwm(struct device *dev, struct device_attribute *devattr, |
---|
| 137 | +static ssize_t pwm_store(struct device *dev, struct device_attribute *devattr, |
---|
145 | 138 | const char *buf, size_t count) |
---|
146 | 139 | { |
---|
147 | 140 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
.. | .. |
---|
157 | 150 | return err ? : count; |
---|
158 | 151 | } |
---|
159 | 152 | |
---|
160 | | -static ssize_t show_pwm_enable(struct device *dev, |
---|
| 153 | +static ssize_t pwm_enable_show(struct device *dev, |
---|
161 | 154 | struct device_attribute *attr, char *buf) |
---|
162 | 155 | { |
---|
163 | 156 | struct nct7802_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
172 | 165 | return sprintf(buf, "%u\n", enabled + 1); |
---|
173 | 166 | } |
---|
174 | 167 | |
---|
175 | | -static ssize_t store_pwm_enable(struct device *dev, |
---|
| 168 | +static ssize_t pwm_enable_store(struct device *dev, |
---|
176 | 169 | struct device_attribute *attr, |
---|
177 | 170 | const char *buf, size_t count) |
---|
178 | 171 | { |
---|
.. | .. |
---|
345 | 338 | return err; |
---|
346 | 339 | } |
---|
347 | 340 | |
---|
348 | | -static ssize_t show_in(struct device *dev, struct device_attribute *attr, |
---|
| 341 | +static ssize_t in_show(struct device *dev, struct device_attribute *attr, |
---|
349 | 342 | char *buf) |
---|
350 | 343 | { |
---|
351 | 344 | struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); |
---|
.. | .. |
---|
359 | 352 | return sprintf(buf, "%d\n", voltage); |
---|
360 | 353 | } |
---|
361 | 354 | |
---|
362 | | -static ssize_t store_in(struct device *dev, struct device_attribute *attr, |
---|
| 355 | +static ssize_t in_store(struct device *dev, struct device_attribute *attr, |
---|
363 | 356 | const char *buf, size_t count) |
---|
364 | 357 | { |
---|
365 | 358 | struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); |
---|
.. | .. |
---|
377 | 370 | return err ? : count; |
---|
378 | 371 | } |
---|
379 | 372 | |
---|
380 | | -static ssize_t show_temp(struct device *dev, struct device_attribute *attr, |
---|
| 373 | +static ssize_t in_alarm_show(struct device *dev, struct device_attribute *attr, |
---|
| 374 | + char *buf) |
---|
| 375 | +{ |
---|
| 376 | + struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); |
---|
| 377 | + struct nct7802_data *data = dev_get_drvdata(dev); |
---|
| 378 | + int volt, min, max, ret; |
---|
| 379 | + unsigned int val; |
---|
| 380 | + |
---|
| 381 | + mutex_lock(&data->in_alarm_lock); |
---|
| 382 | + |
---|
| 383 | + /* |
---|
| 384 | + * The SMI Voltage status register is the only register giving a status |
---|
| 385 | + * for voltages. A bit is set for each input crossing a threshold, in |
---|
| 386 | + * both direction, but the "inside" or "outside" limits info is not |
---|
| 387 | + * available. Also this register is cleared on read. |
---|
| 388 | + * Note: this is not explicitly spelled out in the datasheet, but |
---|
| 389 | + * from experiment. |
---|
| 390 | + * To deal with this we use a status cache with one validity bit and |
---|
| 391 | + * one status bit for each input. Validity is cleared at startup and |
---|
| 392 | + * each time the register reports a change, and the status is processed |
---|
| 393 | + * by software based on current input value and limits. |
---|
| 394 | + */ |
---|
| 395 | + ret = regmap_read(data->regmap, 0x1e, &val); /* SMI Voltage status */ |
---|
| 396 | + if (ret < 0) |
---|
| 397 | + goto abort; |
---|
| 398 | + |
---|
| 399 | + /* invalidate cached status for all inputs crossing a threshold */ |
---|
| 400 | + data->in_status &= ~((val & 0x0f) << 4); |
---|
| 401 | + |
---|
| 402 | + /* if cached status for requested input is invalid, update it */ |
---|
| 403 | + if (!(data->in_status & (0x10 << sattr->index))) { |
---|
| 404 | + ret = nct7802_read_voltage(data, sattr->nr, 0); |
---|
| 405 | + if (ret < 0) |
---|
| 406 | + goto abort; |
---|
| 407 | + volt = ret; |
---|
| 408 | + |
---|
| 409 | + ret = nct7802_read_voltage(data, sattr->nr, 1); |
---|
| 410 | + if (ret < 0) |
---|
| 411 | + goto abort; |
---|
| 412 | + min = ret; |
---|
| 413 | + |
---|
| 414 | + ret = nct7802_read_voltage(data, sattr->nr, 2); |
---|
| 415 | + if (ret < 0) |
---|
| 416 | + goto abort; |
---|
| 417 | + max = ret; |
---|
| 418 | + |
---|
| 419 | + if (volt < min || volt > max) |
---|
| 420 | + data->in_status |= (1 << sattr->index); |
---|
| 421 | + else |
---|
| 422 | + data->in_status &= ~(1 << sattr->index); |
---|
| 423 | + |
---|
| 424 | + data->in_status |= 0x10 << sattr->index; |
---|
| 425 | + } |
---|
| 426 | + |
---|
| 427 | + ret = sprintf(buf, "%u\n", !!(data->in_status & (1 << sattr->index))); |
---|
| 428 | +abort: |
---|
| 429 | + mutex_unlock(&data->in_alarm_lock); |
---|
| 430 | + return ret; |
---|
| 431 | +} |
---|
| 432 | + |
---|
| 433 | +static ssize_t temp_show(struct device *dev, struct device_attribute *attr, |
---|
381 | 434 | char *buf) |
---|
382 | 435 | { |
---|
383 | 436 | struct nct7802_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
391 | 444 | return sprintf(buf, "%d\n", temp); |
---|
392 | 445 | } |
---|
393 | 446 | |
---|
394 | | -static ssize_t store_temp(struct device *dev, struct device_attribute *attr, |
---|
| 447 | +static ssize_t temp_store(struct device *dev, struct device_attribute *attr, |
---|
395 | 448 | const char *buf, size_t count) |
---|
396 | 449 | { |
---|
397 | 450 | struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); |
---|
.. | .. |
---|
410 | 463 | return err ? : count; |
---|
411 | 464 | } |
---|
412 | 465 | |
---|
413 | | -static ssize_t show_fan(struct device *dev, struct device_attribute *attr, |
---|
| 466 | +static ssize_t fan_show(struct device *dev, struct device_attribute *attr, |
---|
414 | 467 | char *buf) |
---|
415 | 468 | { |
---|
416 | 469 | struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr); |
---|
.. | .. |
---|
424 | 477 | return sprintf(buf, "%d\n", speed); |
---|
425 | 478 | } |
---|
426 | 479 | |
---|
427 | | -static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr, |
---|
| 480 | +static ssize_t fan_min_show(struct device *dev, struct device_attribute *attr, |
---|
428 | 481 | char *buf) |
---|
429 | 482 | { |
---|
430 | 483 | struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); |
---|
.. | .. |
---|
438 | 491 | return sprintf(buf, "%d\n", speed); |
---|
439 | 492 | } |
---|
440 | 493 | |
---|
441 | | -static ssize_t store_fan_min(struct device *dev, struct device_attribute *attr, |
---|
442 | | - const char *buf, size_t count) |
---|
| 494 | +static ssize_t fan_min_store(struct device *dev, |
---|
| 495 | + struct device_attribute *attr, const char *buf, |
---|
| 496 | + size_t count) |
---|
443 | 497 | { |
---|
444 | 498 | struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); |
---|
445 | 499 | struct nct7802_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
454 | 508 | return err ? : count; |
---|
455 | 509 | } |
---|
456 | 510 | |
---|
457 | | -static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, |
---|
| 511 | +static ssize_t alarm_show(struct device *dev, struct device_attribute *attr, |
---|
458 | 512 | char *buf) |
---|
459 | 513 | { |
---|
460 | 514 | struct nct7802_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
471 | 525 | } |
---|
472 | 526 | |
---|
473 | 527 | static ssize_t |
---|
474 | | -show_beep(struct device *dev, struct device_attribute *attr, char *buf) |
---|
| 528 | +beep_show(struct device *dev, struct device_attribute *attr, char *buf) |
---|
475 | 529 | { |
---|
476 | 530 | struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); |
---|
477 | 531 | struct nct7802_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
486 | 540 | } |
---|
487 | 541 | |
---|
488 | 542 | static ssize_t |
---|
489 | | -store_beep(struct device *dev, struct device_attribute *attr, const char *buf, |
---|
| 543 | +beep_store(struct device *dev, struct device_attribute *attr, const char *buf, |
---|
490 | 544 | size_t count) |
---|
491 | 545 | { |
---|
492 | 546 | struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); |
---|
.. | .. |
---|
505 | 559 | return err ? : count; |
---|
506 | 560 | } |
---|
507 | 561 | |
---|
508 | | -static SENSOR_DEVICE_ATTR(temp1_type, S_IRUGO | S_IWUSR, |
---|
509 | | - show_temp_type, store_temp_type, 0); |
---|
510 | | -static SENSOR_DEVICE_ATTR_2(temp1_input, S_IRUGO, show_temp, NULL, 0x01, |
---|
511 | | - REG_TEMP_LSB); |
---|
512 | | -static SENSOR_DEVICE_ATTR_2(temp1_min, S_IRUGO | S_IWUSR, show_temp, |
---|
513 | | - store_temp, 0x31, 0); |
---|
514 | | -static SENSOR_DEVICE_ATTR_2(temp1_max, S_IRUGO | S_IWUSR, show_temp, |
---|
515 | | - store_temp, 0x30, 0); |
---|
516 | | -static SENSOR_DEVICE_ATTR_2(temp1_crit, S_IRUGO | S_IWUSR, show_temp, |
---|
517 | | - store_temp, 0x3a, 0); |
---|
| 562 | +static SENSOR_DEVICE_ATTR_RW(temp1_type, temp_type, 0); |
---|
| 563 | +static SENSOR_DEVICE_ATTR_2_RO(temp1_input, temp, 0x01, REG_TEMP_LSB); |
---|
| 564 | +static SENSOR_DEVICE_ATTR_2_RW(temp1_min, temp, 0x31, 0); |
---|
| 565 | +static SENSOR_DEVICE_ATTR_2_RW(temp1_max, temp, 0x30, 0); |
---|
| 566 | +static SENSOR_DEVICE_ATTR_2_RW(temp1_crit, temp, 0x3a, 0); |
---|
518 | 567 | |
---|
519 | | -static SENSOR_DEVICE_ATTR(temp2_type, S_IRUGO | S_IWUSR, |
---|
520 | | - show_temp_type, store_temp_type, 1); |
---|
521 | | -static SENSOR_DEVICE_ATTR_2(temp2_input, S_IRUGO, show_temp, NULL, 0x02, |
---|
522 | | - REG_TEMP_LSB); |
---|
523 | | -static SENSOR_DEVICE_ATTR_2(temp2_min, S_IRUGO | S_IWUSR, show_temp, |
---|
524 | | - store_temp, 0x33, 0); |
---|
525 | | -static SENSOR_DEVICE_ATTR_2(temp2_max, S_IRUGO | S_IWUSR, show_temp, |
---|
526 | | - store_temp, 0x32, 0); |
---|
527 | | -static SENSOR_DEVICE_ATTR_2(temp2_crit, S_IRUGO | S_IWUSR, show_temp, |
---|
528 | | - store_temp, 0x3b, 0); |
---|
| 568 | +static SENSOR_DEVICE_ATTR_RW(temp2_type, temp_type, 1); |
---|
| 569 | +static SENSOR_DEVICE_ATTR_2_RO(temp2_input, temp, 0x02, REG_TEMP_LSB); |
---|
| 570 | +static SENSOR_DEVICE_ATTR_2_RW(temp2_min, temp, 0x33, 0); |
---|
| 571 | +static SENSOR_DEVICE_ATTR_2_RW(temp2_max, temp, 0x32, 0); |
---|
| 572 | +static SENSOR_DEVICE_ATTR_2_RW(temp2_crit, temp, 0x3b, 0); |
---|
529 | 573 | |
---|
530 | | -static SENSOR_DEVICE_ATTR(temp3_type, S_IRUGO | S_IWUSR, |
---|
531 | | - show_temp_type, store_temp_type, 2); |
---|
532 | | -static SENSOR_DEVICE_ATTR_2(temp3_input, S_IRUGO, show_temp, NULL, 0x03, |
---|
533 | | - REG_TEMP_LSB); |
---|
534 | | -static SENSOR_DEVICE_ATTR_2(temp3_min, S_IRUGO | S_IWUSR, show_temp, |
---|
535 | | - store_temp, 0x35, 0); |
---|
536 | | -static SENSOR_DEVICE_ATTR_2(temp3_max, S_IRUGO | S_IWUSR, show_temp, |
---|
537 | | - store_temp, 0x34, 0); |
---|
538 | | -static SENSOR_DEVICE_ATTR_2(temp3_crit, S_IRUGO | S_IWUSR, show_temp, |
---|
539 | | - store_temp, 0x3c, 0); |
---|
| 574 | +static SENSOR_DEVICE_ATTR_RW(temp3_type, temp_type, 2); |
---|
| 575 | +static SENSOR_DEVICE_ATTR_2_RO(temp3_input, temp, 0x03, REG_TEMP_LSB); |
---|
| 576 | +static SENSOR_DEVICE_ATTR_2_RW(temp3_min, temp, 0x35, 0); |
---|
| 577 | +static SENSOR_DEVICE_ATTR_2_RW(temp3_max, temp, 0x34, 0); |
---|
| 578 | +static SENSOR_DEVICE_ATTR_2_RW(temp3_crit, temp, 0x3c, 0); |
---|
540 | 579 | |
---|
541 | | -static SENSOR_DEVICE_ATTR_2(temp4_input, S_IRUGO, show_temp, NULL, 0x04, 0); |
---|
542 | | -static SENSOR_DEVICE_ATTR_2(temp4_min, S_IRUGO | S_IWUSR, show_temp, |
---|
543 | | - store_temp, 0x37, 0); |
---|
544 | | -static SENSOR_DEVICE_ATTR_2(temp4_max, S_IRUGO | S_IWUSR, show_temp, |
---|
545 | | - store_temp, 0x36, 0); |
---|
546 | | -static SENSOR_DEVICE_ATTR_2(temp4_crit, S_IRUGO | S_IWUSR, show_temp, |
---|
547 | | - store_temp, 0x3d, 0); |
---|
| 580 | +static SENSOR_DEVICE_ATTR_2_RO(temp4_input, temp, 0x04, 0); |
---|
| 581 | +static SENSOR_DEVICE_ATTR_2_RW(temp4_min, temp, 0x37, 0); |
---|
| 582 | +static SENSOR_DEVICE_ATTR_2_RW(temp4_max, temp, 0x36, 0); |
---|
| 583 | +static SENSOR_DEVICE_ATTR_2_RW(temp4_crit, temp, 0x3d, 0); |
---|
548 | 584 | |
---|
549 | | -static SENSOR_DEVICE_ATTR_2(temp5_input, S_IRUGO, show_temp, NULL, 0x06, |
---|
550 | | - REG_TEMP_PECI_LSB); |
---|
551 | | -static SENSOR_DEVICE_ATTR_2(temp5_min, S_IRUGO | S_IWUSR, show_temp, |
---|
552 | | - store_temp, 0x39, 0); |
---|
553 | | -static SENSOR_DEVICE_ATTR_2(temp5_max, S_IRUGO | S_IWUSR, show_temp, |
---|
554 | | - store_temp, 0x38, 0); |
---|
555 | | -static SENSOR_DEVICE_ATTR_2(temp5_crit, S_IRUGO | S_IWUSR, show_temp, |
---|
556 | | - store_temp, 0x3e, 0); |
---|
| 585 | +static SENSOR_DEVICE_ATTR_2_RO(temp5_input, temp, 0x06, REG_TEMP_PECI_LSB); |
---|
| 586 | +static SENSOR_DEVICE_ATTR_2_RW(temp5_min, temp, 0x39, 0); |
---|
| 587 | +static SENSOR_DEVICE_ATTR_2_RW(temp5_max, temp, 0x38, 0); |
---|
| 588 | +static SENSOR_DEVICE_ATTR_2_RW(temp5_crit, temp, 0x3e, 0); |
---|
557 | 589 | |
---|
558 | | -static SENSOR_DEVICE_ATTR_2(temp6_input, S_IRUGO, show_temp, NULL, 0x07, |
---|
559 | | - REG_TEMP_PECI_LSB); |
---|
| 590 | +static SENSOR_DEVICE_ATTR_2_RO(temp6_input, temp, 0x07, REG_TEMP_PECI_LSB); |
---|
560 | 591 | |
---|
561 | | -static SENSOR_DEVICE_ATTR_2(temp1_min_alarm, S_IRUGO, show_alarm, NULL, |
---|
562 | | - 0x18, 0); |
---|
563 | | -static SENSOR_DEVICE_ATTR_2(temp2_min_alarm, S_IRUGO, show_alarm, NULL, |
---|
564 | | - 0x18, 1); |
---|
565 | | -static SENSOR_DEVICE_ATTR_2(temp3_min_alarm, S_IRUGO, show_alarm, NULL, |
---|
566 | | - 0x18, 2); |
---|
567 | | -static SENSOR_DEVICE_ATTR_2(temp4_min_alarm, S_IRUGO, show_alarm, NULL, |
---|
568 | | - 0x18, 3); |
---|
569 | | -static SENSOR_DEVICE_ATTR_2(temp5_min_alarm, S_IRUGO, show_alarm, NULL, |
---|
570 | | - 0x18, 4); |
---|
| 592 | +static SENSOR_DEVICE_ATTR_2_RO(temp1_min_alarm, alarm, 0x18, 0); |
---|
| 593 | +static SENSOR_DEVICE_ATTR_2_RO(temp2_min_alarm, alarm, 0x18, 1); |
---|
| 594 | +static SENSOR_DEVICE_ATTR_2_RO(temp3_min_alarm, alarm, 0x18, 2); |
---|
| 595 | +static SENSOR_DEVICE_ATTR_2_RO(temp4_min_alarm, alarm, 0x18, 3); |
---|
| 596 | +static SENSOR_DEVICE_ATTR_2_RO(temp5_min_alarm, alarm, 0x18, 4); |
---|
571 | 597 | |
---|
572 | | -static SENSOR_DEVICE_ATTR_2(temp1_max_alarm, S_IRUGO, show_alarm, NULL, |
---|
573 | | - 0x19, 0); |
---|
574 | | -static SENSOR_DEVICE_ATTR_2(temp2_max_alarm, S_IRUGO, show_alarm, NULL, |
---|
575 | | - 0x19, 1); |
---|
576 | | -static SENSOR_DEVICE_ATTR_2(temp3_max_alarm, S_IRUGO, show_alarm, NULL, |
---|
577 | | - 0x19, 2); |
---|
578 | | -static SENSOR_DEVICE_ATTR_2(temp4_max_alarm, S_IRUGO, show_alarm, NULL, |
---|
579 | | - 0x19, 3); |
---|
580 | | -static SENSOR_DEVICE_ATTR_2(temp5_max_alarm, S_IRUGO, show_alarm, NULL, |
---|
581 | | - 0x19, 4); |
---|
| 598 | +static SENSOR_DEVICE_ATTR_2_RO(temp1_max_alarm, alarm, 0x19, 0); |
---|
| 599 | +static SENSOR_DEVICE_ATTR_2_RO(temp2_max_alarm, alarm, 0x19, 1); |
---|
| 600 | +static SENSOR_DEVICE_ATTR_2_RO(temp3_max_alarm, alarm, 0x19, 2); |
---|
| 601 | +static SENSOR_DEVICE_ATTR_2_RO(temp4_max_alarm, alarm, 0x19, 3); |
---|
| 602 | +static SENSOR_DEVICE_ATTR_2_RO(temp5_max_alarm, alarm, 0x19, 4); |
---|
582 | 603 | |
---|
583 | | -static SENSOR_DEVICE_ATTR_2(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, |
---|
584 | | - 0x1b, 0); |
---|
585 | | -static SENSOR_DEVICE_ATTR_2(temp2_crit_alarm, S_IRUGO, show_alarm, NULL, |
---|
586 | | - 0x1b, 1); |
---|
587 | | -static SENSOR_DEVICE_ATTR_2(temp3_crit_alarm, S_IRUGO, show_alarm, NULL, |
---|
588 | | - 0x1b, 2); |
---|
589 | | -static SENSOR_DEVICE_ATTR_2(temp4_crit_alarm, S_IRUGO, show_alarm, NULL, |
---|
590 | | - 0x1b, 3); |
---|
591 | | -static SENSOR_DEVICE_ATTR_2(temp5_crit_alarm, S_IRUGO, show_alarm, NULL, |
---|
592 | | - 0x1b, 4); |
---|
| 604 | +static SENSOR_DEVICE_ATTR_2_RO(temp1_crit_alarm, alarm, 0x1b, 0); |
---|
| 605 | +static SENSOR_DEVICE_ATTR_2_RO(temp2_crit_alarm, alarm, 0x1b, 1); |
---|
| 606 | +static SENSOR_DEVICE_ATTR_2_RO(temp3_crit_alarm, alarm, 0x1b, 2); |
---|
| 607 | +static SENSOR_DEVICE_ATTR_2_RO(temp4_crit_alarm, alarm, 0x1b, 3); |
---|
| 608 | +static SENSOR_DEVICE_ATTR_2_RO(temp5_crit_alarm, alarm, 0x1b, 4); |
---|
593 | 609 | |
---|
594 | | -static SENSOR_DEVICE_ATTR_2(temp1_fault, S_IRUGO, show_alarm, NULL, 0x17, 0); |
---|
595 | | -static SENSOR_DEVICE_ATTR_2(temp2_fault, S_IRUGO, show_alarm, NULL, 0x17, 1); |
---|
596 | | -static SENSOR_DEVICE_ATTR_2(temp3_fault, S_IRUGO, show_alarm, NULL, 0x17, 2); |
---|
| 610 | +static SENSOR_DEVICE_ATTR_2_RO(temp1_fault, alarm, 0x17, 0); |
---|
| 611 | +static SENSOR_DEVICE_ATTR_2_RO(temp2_fault, alarm, 0x17, 1); |
---|
| 612 | +static SENSOR_DEVICE_ATTR_2_RO(temp3_fault, alarm, 0x17, 2); |
---|
597 | 613 | |
---|
598 | | -static SENSOR_DEVICE_ATTR_2(temp1_beep, S_IRUGO | S_IWUSR, show_beep, |
---|
599 | | - store_beep, 0x5c, 0); |
---|
600 | | -static SENSOR_DEVICE_ATTR_2(temp2_beep, S_IRUGO | S_IWUSR, show_beep, |
---|
601 | | - store_beep, 0x5c, 1); |
---|
602 | | -static SENSOR_DEVICE_ATTR_2(temp3_beep, S_IRUGO | S_IWUSR, show_beep, |
---|
603 | | - store_beep, 0x5c, 2); |
---|
604 | | -static SENSOR_DEVICE_ATTR_2(temp4_beep, S_IRUGO | S_IWUSR, show_beep, |
---|
605 | | - store_beep, 0x5c, 3); |
---|
606 | | -static SENSOR_DEVICE_ATTR_2(temp5_beep, S_IRUGO | S_IWUSR, show_beep, |
---|
607 | | - store_beep, 0x5c, 4); |
---|
608 | | -static SENSOR_DEVICE_ATTR_2(temp6_beep, S_IRUGO | S_IWUSR, show_beep, |
---|
609 | | - store_beep, 0x5c, 5); |
---|
| 614 | +static SENSOR_DEVICE_ATTR_2_RW(temp1_beep, beep, 0x5c, 0); |
---|
| 615 | +static SENSOR_DEVICE_ATTR_2_RW(temp2_beep, beep, 0x5c, 1); |
---|
| 616 | +static SENSOR_DEVICE_ATTR_2_RW(temp3_beep, beep, 0x5c, 2); |
---|
| 617 | +static SENSOR_DEVICE_ATTR_2_RW(temp4_beep, beep, 0x5c, 3); |
---|
| 618 | +static SENSOR_DEVICE_ATTR_2_RW(temp5_beep, beep, 0x5c, 4); |
---|
| 619 | +static SENSOR_DEVICE_ATTR_2_RW(temp6_beep, beep, 0x5c, 5); |
---|
610 | 620 | |
---|
611 | 621 | static struct attribute *nct7802_temp_attrs[] = { |
---|
612 | 622 | &sensor_dev_attr_temp1_type.dev_attr.attr, |
---|
.. | .. |
---|
669 | 679 | static umode_t nct7802_temp_is_visible(struct kobject *kobj, |
---|
670 | 680 | struct attribute *attr, int index) |
---|
671 | 681 | { |
---|
672 | | - struct device *dev = container_of(kobj, struct device, kobj); |
---|
| 682 | + struct device *dev = kobj_to_dev(kobj); |
---|
673 | 683 | struct nct7802_data *data = dev_get_drvdata(dev); |
---|
674 | 684 | unsigned int reg; |
---|
675 | 685 | int err; |
---|
.. | .. |
---|
698 | 708 | if (index >= 38 && index < 46 && !(reg & 0x01)) /* PECI 0 */ |
---|
699 | 709 | return 0; |
---|
700 | 710 | |
---|
701 | | - if (index >= 0x46 && (!(reg & 0x02))) /* PECI 1 */ |
---|
| 711 | + if (index >= 46 && !(reg & 0x02)) /* PECI 1 */ |
---|
702 | 712 | return 0; |
---|
703 | 713 | |
---|
704 | 714 | return attr->mode; |
---|
.. | .. |
---|
709 | 719 | .is_visible = nct7802_temp_is_visible, |
---|
710 | 720 | }; |
---|
711 | 721 | |
---|
712 | | -static SENSOR_DEVICE_ATTR_2(in0_input, S_IRUGO, show_in, NULL, 0, 0); |
---|
713 | | -static SENSOR_DEVICE_ATTR_2(in0_min, S_IRUGO | S_IWUSR, show_in, store_in, |
---|
714 | | - 0, 1); |
---|
715 | | -static SENSOR_DEVICE_ATTR_2(in0_max, S_IRUGO | S_IWUSR, show_in, store_in, |
---|
716 | | - 0, 2); |
---|
717 | | -static SENSOR_DEVICE_ATTR_2(in0_alarm, S_IRUGO, show_alarm, NULL, 0x1e, 3); |
---|
718 | | -static SENSOR_DEVICE_ATTR_2(in0_beep, S_IRUGO | S_IWUSR, show_beep, store_beep, |
---|
719 | | - 0x5a, 3); |
---|
| 722 | +static SENSOR_DEVICE_ATTR_2_RO(in0_input, in, 0, 0); |
---|
| 723 | +static SENSOR_DEVICE_ATTR_2_RW(in0_min, in, 0, 1); |
---|
| 724 | +static SENSOR_DEVICE_ATTR_2_RW(in0_max, in, 0, 2); |
---|
| 725 | +static SENSOR_DEVICE_ATTR_2_RO(in0_alarm, in_alarm, 0, 3); |
---|
| 726 | +static SENSOR_DEVICE_ATTR_2_RW(in0_beep, beep, 0x5a, 3); |
---|
720 | 727 | |
---|
721 | | -static SENSOR_DEVICE_ATTR_2(in1_input, S_IRUGO, show_in, NULL, 1, 0); |
---|
| 728 | +static SENSOR_DEVICE_ATTR_2_RO(in1_input, in, 1, 0); |
---|
722 | 729 | |
---|
723 | | -static SENSOR_DEVICE_ATTR_2(in2_input, S_IRUGO, show_in, NULL, 2, 0); |
---|
724 | | -static SENSOR_DEVICE_ATTR_2(in2_min, S_IRUGO | S_IWUSR, show_in, store_in, |
---|
725 | | - 2, 1); |
---|
726 | | -static SENSOR_DEVICE_ATTR_2(in2_max, S_IRUGO | S_IWUSR, show_in, store_in, |
---|
727 | | - 2, 2); |
---|
728 | | -static SENSOR_DEVICE_ATTR_2(in2_alarm, S_IRUGO, show_alarm, NULL, 0x1e, 0); |
---|
729 | | -static SENSOR_DEVICE_ATTR_2(in2_beep, S_IRUGO | S_IWUSR, show_beep, store_beep, |
---|
730 | | - 0x5a, 0); |
---|
| 730 | +static SENSOR_DEVICE_ATTR_2_RO(in2_input, in, 2, 0); |
---|
| 731 | +static SENSOR_DEVICE_ATTR_2_RW(in2_min, in, 2, 1); |
---|
| 732 | +static SENSOR_DEVICE_ATTR_2_RW(in2_max, in, 2, 2); |
---|
| 733 | +static SENSOR_DEVICE_ATTR_2_RO(in2_alarm, in_alarm, 2, 0); |
---|
| 734 | +static SENSOR_DEVICE_ATTR_2_RW(in2_beep, beep, 0x5a, 0); |
---|
731 | 735 | |
---|
732 | | -static SENSOR_DEVICE_ATTR_2(in3_input, S_IRUGO, show_in, NULL, 3, 0); |
---|
733 | | -static SENSOR_DEVICE_ATTR_2(in3_min, S_IRUGO | S_IWUSR, show_in, store_in, |
---|
734 | | - 3, 1); |
---|
735 | | -static SENSOR_DEVICE_ATTR_2(in3_max, S_IRUGO | S_IWUSR, show_in, store_in, |
---|
736 | | - 3, 2); |
---|
737 | | -static SENSOR_DEVICE_ATTR_2(in3_alarm, S_IRUGO, show_alarm, NULL, 0x1e, 1); |
---|
738 | | -static SENSOR_DEVICE_ATTR_2(in3_beep, S_IRUGO | S_IWUSR, show_beep, store_beep, |
---|
739 | | - 0x5a, 1); |
---|
| 736 | +static SENSOR_DEVICE_ATTR_2_RO(in3_input, in, 3, 0); |
---|
| 737 | +static SENSOR_DEVICE_ATTR_2_RW(in3_min, in, 3, 1); |
---|
| 738 | +static SENSOR_DEVICE_ATTR_2_RW(in3_max, in, 3, 2); |
---|
| 739 | +static SENSOR_DEVICE_ATTR_2_RO(in3_alarm, in_alarm, 3, 1); |
---|
| 740 | +static SENSOR_DEVICE_ATTR_2_RW(in3_beep, beep, 0x5a, 1); |
---|
740 | 741 | |
---|
741 | | -static SENSOR_DEVICE_ATTR_2(in4_input, S_IRUGO, show_in, NULL, 4, 0); |
---|
742 | | -static SENSOR_DEVICE_ATTR_2(in4_min, S_IRUGO | S_IWUSR, show_in, store_in, |
---|
743 | | - 4, 1); |
---|
744 | | -static SENSOR_DEVICE_ATTR_2(in4_max, S_IRUGO | S_IWUSR, show_in, store_in, |
---|
745 | | - 4, 2); |
---|
746 | | -static SENSOR_DEVICE_ATTR_2(in4_alarm, S_IRUGO, show_alarm, NULL, 0x1e, 2); |
---|
747 | | -static SENSOR_DEVICE_ATTR_2(in4_beep, S_IRUGO | S_IWUSR, show_beep, store_beep, |
---|
748 | | - 0x5a, 2); |
---|
| 742 | +static SENSOR_DEVICE_ATTR_2_RO(in4_input, in, 4, 0); |
---|
| 743 | +static SENSOR_DEVICE_ATTR_2_RW(in4_min, in, 4, 1); |
---|
| 744 | +static SENSOR_DEVICE_ATTR_2_RW(in4_max, in, 4, 2); |
---|
| 745 | +static SENSOR_DEVICE_ATTR_2_RO(in4_alarm, in_alarm, 4, 2); |
---|
| 746 | +static SENSOR_DEVICE_ATTR_2_RW(in4_beep, beep, 0x5a, 2); |
---|
749 | 747 | |
---|
750 | 748 | static struct attribute *nct7802_in_attrs[] = { |
---|
751 | 749 | &sensor_dev_attr_in0_input.dev_attr.attr, |
---|
.. | .. |
---|
780 | 778 | static umode_t nct7802_in_is_visible(struct kobject *kobj, |
---|
781 | 779 | struct attribute *attr, int index) |
---|
782 | 780 | { |
---|
783 | | - struct device *dev = container_of(kobj, struct device, kobj); |
---|
| 781 | + struct device *dev = kobj_to_dev(kobj); |
---|
784 | 782 | struct nct7802_data *data = dev_get_drvdata(dev); |
---|
785 | 783 | unsigned int reg; |
---|
786 | 784 | int err; |
---|
.. | .. |
---|
807 | 805 | .is_visible = nct7802_in_is_visible, |
---|
808 | 806 | }; |
---|
809 | 807 | |
---|
810 | | -static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0x10); |
---|
811 | | -static SENSOR_DEVICE_ATTR_2(fan1_min, S_IRUGO | S_IWUSR, show_fan_min, |
---|
812 | | - store_fan_min, 0x49, 0x4c); |
---|
813 | | -static SENSOR_DEVICE_ATTR_2(fan1_alarm, S_IRUGO, show_alarm, NULL, 0x1a, 0); |
---|
814 | | -static SENSOR_DEVICE_ATTR_2(fan1_beep, S_IRUGO | S_IWUSR, show_beep, store_beep, |
---|
815 | | - 0x5b, 0); |
---|
816 | | -static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 0x11); |
---|
817 | | -static SENSOR_DEVICE_ATTR_2(fan2_min, S_IRUGO | S_IWUSR, show_fan_min, |
---|
818 | | - store_fan_min, 0x4a, 0x4d); |
---|
819 | | -static SENSOR_DEVICE_ATTR_2(fan2_alarm, S_IRUGO, show_alarm, NULL, 0x1a, 1); |
---|
820 | | -static SENSOR_DEVICE_ATTR_2(fan2_beep, S_IRUGO | S_IWUSR, show_beep, store_beep, |
---|
821 | | - 0x5b, 1); |
---|
822 | | -static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 0x12); |
---|
823 | | -static SENSOR_DEVICE_ATTR_2(fan3_min, S_IRUGO | S_IWUSR, show_fan_min, |
---|
824 | | - store_fan_min, 0x4b, 0x4e); |
---|
825 | | -static SENSOR_DEVICE_ATTR_2(fan3_alarm, S_IRUGO, show_alarm, NULL, 0x1a, 2); |
---|
826 | | -static SENSOR_DEVICE_ATTR_2(fan3_beep, S_IRUGO | S_IWUSR, show_beep, store_beep, |
---|
827 | | - 0x5b, 2); |
---|
| 808 | +static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, 0x10); |
---|
| 809 | +static SENSOR_DEVICE_ATTR_2_RW(fan1_min, fan_min, 0x49, 0x4c); |
---|
| 810 | +static SENSOR_DEVICE_ATTR_2_RO(fan1_alarm, alarm, 0x1a, 0); |
---|
| 811 | +static SENSOR_DEVICE_ATTR_2_RW(fan1_beep, beep, 0x5b, 0); |
---|
| 812 | +static SENSOR_DEVICE_ATTR_RO(fan2_input, fan, 0x11); |
---|
| 813 | +static SENSOR_DEVICE_ATTR_2_RW(fan2_min, fan_min, 0x4a, 0x4d); |
---|
| 814 | +static SENSOR_DEVICE_ATTR_2_RO(fan2_alarm, alarm, 0x1a, 1); |
---|
| 815 | +static SENSOR_DEVICE_ATTR_2_RW(fan2_beep, beep, 0x5b, 1); |
---|
| 816 | +static SENSOR_DEVICE_ATTR_RO(fan3_input, fan, 0x12); |
---|
| 817 | +static SENSOR_DEVICE_ATTR_2_RW(fan3_min, fan_min, 0x4b, 0x4e); |
---|
| 818 | +static SENSOR_DEVICE_ATTR_2_RO(fan3_alarm, alarm, 0x1a, 2); |
---|
| 819 | +static SENSOR_DEVICE_ATTR_2_RW(fan3_beep, beep, 0x5b, 2); |
---|
828 | 820 | |
---|
829 | 821 | /* 7.2.89 Fan Control Output Type */ |
---|
830 | | -static SENSOR_DEVICE_ATTR(pwm1_mode, S_IRUGO, show_pwm_mode, NULL, 0); |
---|
831 | | -static SENSOR_DEVICE_ATTR(pwm2_mode, S_IRUGO, show_pwm_mode, NULL, 1); |
---|
832 | | -static SENSOR_DEVICE_ATTR(pwm3_mode, S_IRUGO, show_pwm_mode, NULL, 2); |
---|
| 822 | +static SENSOR_DEVICE_ATTR_RO(pwm1_mode, pwm_mode, 0); |
---|
| 823 | +static SENSOR_DEVICE_ATTR_RO(pwm2_mode, pwm_mode, 1); |
---|
| 824 | +static SENSOR_DEVICE_ATTR_RO(pwm3_mode, pwm_mode, 2); |
---|
833 | 825 | |
---|
834 | 826 | /* 7.2.91... Fan Control Output Value */ |
---|
835 | | -static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_pwm, store_pwm, |
---|
836 | | - REG_PWM(0)); |
---|
837 | | -static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, show_pwm, store_pwm, |
---|
838 | | - REG_PWM(1)); |
---|
839 | | -static SENSOR_DEVICE_ATTR(pwm3, S_IRUGO | S_IWUSR, show_pwm, store_pwm, |
---|
840 | | - REG_PWM(2)); |
---|
| 827 | +static SENSOR_DEVICE_ATTR_RW(pwm1, pwm, REG_PWM(0)); |
---|
| 828 | +static SENSOR_DEVICE_ATTR_RW(pwm2, pwm, REG_PWM(1)); |
---|
| 829 | +static SENSOR_DEVICE_ATTR_RW(pwm3, pwm, REG_PWM(2)); |
---|
841 | 830 | |
---|
842 | 831 | /* 7.2.95... Temperature to Fan mapping Relationships Register */ |
---|
843 | | -static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, show_pwm_enable, |
---|
844 | | - store_pwm_enable, 0); |
---|
845 | | -static SENSOR_DEVICE_ATTR(pwm2_enable, S_IRUGO | S_IWUSR, show_pwm_enable, |
---|
846 | | - store_pwm_enable, 1); |
---|
847 | | -static SENSOR_DEVICE_ATTR(pwm3_enable, S_IRUGO | S_IWUSR, show_pwm_enable, |
---|
848 | | - store_pwm_enable, 2); |
---|
| 832 | +static SENSOR_DEVICE_ATTR_RW(pwm1_enable, pwm_enable, 0); |
---|
| 833 | +static SENSOR_DEVICE_ATTR_RW(pwm2_enable, pwm_enable, 1); |
---|
| 834 | +static SENSOR_DEVICE_ATTR_RW(pwm3_enable, pwm_enable, 2); |
---|
849 | 835 | |
---|
850 | 836 | static struct attribute *nct7802_fan_attrs[] = { |
---|
851 | 837 | &sensor_dev_attr_fan1_input.dev_attr.attr, |
---|
.. | .. |
---|
867 | 853 | static umode_t nct7802_fan_is_visible(struct kobject *kobj, |
---|
868 | 854 | struct attribute *attr, int index) |
---|
869 | 855 | { |
---|
870 | | - struct device *dev = container_of(kobj, struct device, kobj); |
---|
| 856 | + struct device *dev = kobj_to_dev(kobj); |
---|
871 | 857 | struct nct7802_data *data = dev_get_drvdata(dev); |
---|
872 | 858 | int fan = index / 4; /* 4 attributes per fan */ |
---|
873 | 859 | unsigned int reg; |
---|
.. | .. |
---|
903 | 889 | }; |
---|
904 | 890 | |
---|
905 | 891 | /* 7.2.115... 0x80-0x83, 0x84 Temperature (X-axis) transition */ |
---|
906 | | -static SENSOR_DEVICE_ATTR_2(pwm1_auto_point1_temp, S_IRUGO | S_IWUSR, |
---|
907 | | - show_temp, store_temp, 0x80, 0); |
---|
908 | | -static SENSOR_DEVICE_ATTR_2(pwm1_auto_point2_temp, S_IRUGO | S_IWUSR, |
---|
909 | | - show_temp, store_temp, 0x81, 0); |
---|
910 | | -static SENSOR_DEVICE_ATTR_2(pwm1_auto_point3_temp, S_IRUGO | S_IWUSR, |
---|
911 | | - show_temp, store_temp, 0x82, 0); |
---|
912 | | -static SENSOR_DEVICE_ATTR_2(pwm1_auto_point4_temp, S_IRUGO | S_IWUSR, |
---|
913 | | - show_temp, store_temp, 0x83, 0); |
---|
914 | | -static SENSOR_DEVICE_ATTR_2(pwm1_auto_point5_temp, S_IRUGO | S_IWUSR, |
---|
915 | | - show_temp, store_temp, 0x84, 0); |
---|
| 892 | +static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point1_temp, temp, 0x80, 0); |
---|
| 893 | +static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point2_temp, temp, 0x81, 0); |
---|
| 894 | +static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point3_temp, temp, 0x82, 0); |
---|
| 895 | +static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point4_temp, temp, 0x83, 0); |
---|
| 896 | +static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point5_temp, temp, 0x84, 0); |
---|
916 | 897 | |
---|
917 | 898 | /* 7.2.120... 0x85-0x88 PWM (Y-axis) transition */ |
---|
918 | | -static SENSOR_DEVICE_ATTR(pwm1_auto_point1_pwm, S_IRUGO | S_IWUSR, |
---|
919 | | - show_pwm, store_pwm, 0x85); |
---|
920 | | -static SENSOR_DEVICE_ATTR(pwm1_auto_point2_pwm, S_IRUGO | S_IWUSR, |
---|
921 | | - show_pwm, store_pwm, 0x86); |
---|
922 | | -static SENSOR_DEVICE_ATTR(pwm1_auto_point3_pwm, S_IRUGO | S_IWUSR, |
---|
923 | | - show_pwm, store_pwm, 0x87); |
---|
924 | | -static SENSOR_DEVICE_ATTR(pwm1_auto_point4_pwm, S_IRUGO | S_IWUSR, |
---|
925 | | - show_pwm, store_pwm, 0x88); |
---|
926 | | -static SENSOR_DEVICE_ATTR(pwm1_auto_point5_pwm, S_IRUGO, show_pwm, NULL, 0); |
---|
| 899 | +static SENSOR_DEVICE_ATTR_RW(pwm1_auto_point1_pwm, pwm, 0x85); |
---|
| 900 | +static SENSOR_DEVICE_ATTR_RW(pwm1_auto_point2_pwm, pwm, 0x86); |
---|
| 901 | +static SENSOR_DEVICE_ATTR_RW(pwm1_auto_point3_pwm, pwm, 0x87); |
---|
| 902 | +static SENSOR_DEVICE_ATTR_RW(pwm1_auto_point4_pwm, pwm, 0x88); |
---|
| 903 | +static SENSOR_DEVICE_ATTR_RO(pwm1_auto_point5_pwm, pwm, 0); |
---|
927 | 904 | |
---|
928 | 905 | /* 7.2.124 Table 2 X-axis Transition Point 1 Register */ |
---|
929 | | -static SENSOR_DEVICE_ATTR_2(pwm2_auto_point1_temp, S_IRUGO | S_IWUSR, |
---|
930 | | - show_temp, store_temp, 0x90, 0); |
---|
931 | | -static SENSOR_DEVICE_ATTR_2(pwm2_auto_point2_temp, S_IRUGO | S_IWUSR, |
---|
932 | | - show_temp, store_temp, 0x91, 0); |
---|
933 | | -static SENSOR_DEVICE_ATTR_2(pwm2_auto_point3_temp, S_IRUGO | S_IWUSR, |
---|
934 | | - show_temp, store_temp, 0x92, 0); |
---|
935 | | -static SENSOR_DEVICE_ATTR_2(pwm2_auto_point4_temp, S_IRUGO | S_IWUSR, |
---|
936 | | - show_temp, store_temp, 0x93, 0); |
---|
937 | | -static SENSOR_DEVICE_ATTR_2(pwm2_auto_point5_temp, S_IRUGO | S_IWUSR, |
---|
938 | | - show_temp, store_temp, 0x94, 0); |
---|
| 906 | +static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point1_temp, temp, 0x90, 0); |
---|
| 907 | +static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point2_temp, temp, 0x91, 0); |
---|
| 908 | +static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point3_temp, temp, 0x92, 0); |
---|
| 909 | +static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point4_temp, temp, 0x93, 0); |
---|
| 910 | +static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point5_temp, temp, 0x94, 0); |
---|
939 | 911 | |
---|
940 | 912 | /* 7.2.129 Table 2 Y-axis Transition Point 1 Register */ |
---|
941 | | -static SENSOR_DEVICE_ATTR(pwm2_auto_point1_pwm, S_IRUGO | S_IWUSR, |
---|
942 | | - show_pwm, store_pwm, 0x95); |
---|
943 | | -static SENSOR_DEVICE_ATTR(pwm2_auto_point2_pwm, S_IRUGO | S_IWUSR, |
---|
944 | | - show_pwm, store_pwm, 0x96); |
---|
945 | | -static SENSOR_DEVICE_ATTR(pwm2_auto_point3_pwm, S_IRUGO | S_IWUSR, |
---|
946 | | - show_pwm, store_pwm, 0x97); |
---|
947 | | -static SENSOR_DEVICE_ATTR(pwm2_auto_point4_pwm, S_IRUGO | S_IWUSR, |
---|
948 | | - show_pwm, store_pwm, 0x98); |
---|
949 | | -static SENSOR_DEVICE_ATTR(pwm2_auto_point5_pwm, S_IRUGO, show_pwm, NULL, 0); |
---|
| 913 | +static SENSOR_DEVICE_ATTR_RW(pwm2_auto_point1_pwm, pwm, 0x95); |
---|
| 914 | +static SENSOR_DEVICE_ATTR_RW(pwm2_auto_point2_pwm, pwm, 0x96); |
---|
| 915 | +static SENSOR_DEVICE_ATTR_RW(pwm2_auto_point3_pwm, pwm, 0x97); |
---|
| 916 | +static SENSOR_DEVICE_ATTR_RW(pwm2_auto_point4_pwm, pwm, 0x98); |
---|
| 917 | +static SENSOR_DEVICE_ATTR_RO(pwm2_auto_point5_pwm, pwm, 0); |
---|
950 | 918 | |
---|
951 | 919 | /* 7.2.133 Table 3 X-axis Transition Point 1 Register */ |
---|
952 | | -static SENSOR_DEVICE_ATTR_2(pwm3_auto_point1_temp, S_IRUGO | S_IWUSR, |
---|
953 | | - show_temp, store_temp, 0xA0, 0); |
---|
954 | | -static SENSOR_DEVICE_ATTR_2(pwm3_auto_point2_temp, S_IRUGO | S_IWUSR, |
---|
955 | | - show_temp, store_temp, 0xA1, 0); |
---|
956 | | -static SENSOR_DEVICE_ATTR_2(pwm3_auto_point3_temp, S_IRUGO | S_IWUSR, |
---|
957 | | - show_temp, store_temp, 0xA2, 0); |
---|
958 | | -static SENSOR_DEVICE_ATTR_2(pwm3_auto_point4_temp, S_IRUGO | S_IWUSR, |
---|
959 | | - show_temp, store_temp, 0xA3, 0); |
---|
960 | | -static SENSOR_DEVICE_ATTR_2(pwm3_auto_point5_temp, S_IRUGO | S_IWUSR, |
---|
961 | | - show_temp, store_temp, 0xA4, 0); |
---|
| 920 | +static SENSOR_DEVICE_ATTR_2_RW(pwm3_auto_point1_temp, temp, 0xA0, 0); |
---|
| 921 | +static SENSOR_DEVICE_ATTR_2_RW(pwm3_auto_point2_temp, temp, 0xA1, 0); |
---|
| 922 | +static SENSOR_DEVICE_ATTR_2_RW(pwm3_auto_point3_temp, temp, 0xA2, 0); |
---|
| 923 | +static SENSOR_DEVICE_ATTR_2_RW(pwm3_auto_point4_temp, temp, 0xA3, 0); |
---|
| 924 | +static SENSOR_DEVICE_ATTR_2_RW(pwm3_auto_point5_temp, temp, 0xA4, 0); |
---|
962 | 925 | |
---|
963 | 926 | /* 7.2.138 Table 3 Y-axis Transition Point 1 Register */ |
---|
964 | | -static SENSOR_DEVICE_ATTR(pwm3_auto_point1_pwm, S_IRUGO | S_IWUSR, |
---|
965 | | - show_pwm, store_pwm, 0xA5); |
---|
966 | | -static SENSOR_DEVICE_ATTR(pwm3_auto_point2_pwm, S_IRUGO | S_IWUSR, |
---|
967 | | - show_pwm, store_pwm, 0xA6); |
---|
968 | | -static SENSOR_DEVICE_ATTR(pwm3_auto_point3_pwm, S_IRUGO | S_IWUSR, |
---|
969 | | - show_pwm, store_pwm, 0xA7); |
---|
970 | | -static SENSOR_DEVICE_ATTR(pwm3_auto_point4_pwm, S_IRUGO | S_IWUSR, |
---|
971 | | - show_pwm, store_pwm, 0xA8); |
---|
972 | | -static SENSOR_DEVICE_ATTR(pwm3_auto_point5_pwm, S_IRUGO, show_pwm, NULL, 0); |
---|
| 927 | +static SENSOR_DEVICE_ATTR_RW(pwm3_auto_point1_pwm, pwm, 0xA5); |
---|
| 928 | +static SENSOR_DEVICE_ATTR_RW(pwm3_auto_point2_pwm, pwm, 0xA6); |
---|
| 929 | +static SENSOR_DEVICE_ATTR_RW(pwm3_auto_point3_pwm, pwm, 0xA7); |
---|
| 930 | +static SENSOR_DEVICE_ATTR_RW(pwm3_auto_point4_pwm, pwm, 0xA8); |
---|
| 931 | +static SENSOR_DEVICE_ATTR_RO(pwm3_auto_point5_pwm, pwm, 0); |
---|
973 | 932 | |
---|
974 | 933 | static struct attribute *nct7802_auto_point_attrs[] = { |
---|
975 | 934 | &sensor_dev_attr_pwm1_auto_point1_temp.dev_attr.attr, |
---|
.. | .. |
---|
1097 | 1056 | return regmap_update_bits(data->regmap, REG_VMON_ENABLE, 0x03, 0x03); |
---|
1098 | 1057 | } |
---|
1099 | 1058 | |
---|
1100 | | -static int nct7802_probe(struct i2c_client *client, |
---|
1101 | | - const struct i2c_device_id *id) |
---|
| 1059 | +static int nct7802_probe(struct i2c_client *client) |
---|
1102 | 1060 | { |
---|
1103 | 1061 | struct device *dev = &client->dev; |
---|
1104 | 1062 | struct nct7802_data *data; |
---|
.. | .. |
---|
1114 | 1072 | return PTR_ERR(data->regmap); |
---|
1115 | 1073 | |
---|
1116 | 1074 | mutex_init(&data->access_lock); |
---|
| 1075 | + mutex_init(&data->in_alarm_lock); |
---|
1117 | 1076 | |
---|
1118 | 1077 | ret = nct7802_init_chip(data); |
---|
1119 | 1078 | if (ret < 0) |
---|
.. | .. |
---|
1141 | 1100 | .name = DRVNAME, |
---|
1142 | 1101 | }, |
---|
1143 | 1102 | .detect = nct7802_detect, |
---|
1144 | | - .probe = nct7802_probe, |
---|
| 1103 | + .probe_new = nct7802_probe, |
---|
1145 | 1104 | .id_table = nct7802_idtable, |
---|
1146 | 1105 | .address_list = nct7802_address_list, |
---|
1147 | 1106 | }; |
---|