summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2018-12-06 13:41:54 -0500
committerGuenter Roeck <linux@roeck-us.net>2018-12-16 18:13:25 -0500
commit4aabaf30976eac011b70aa7c0e1fb385331e22f2 (patch)
tree5d03349373689869bf54f7a52e28fd067b0aaffe
parent33721d90c0444133219f9773cb6d88f380699fa4 (diff)
hwmon: (nct7802) Auto-convert to use SENSOR_DEVICE_ATTR_{RO, RW, WO}
Auto-conversion was done done using the coccinelle script at https://github.com/groeck/coccinelle-patches/raw/master/hwmon/sensor-devattr-w6.cocci Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r--drivers/hwmon/nct7802.c408
1 files changed, 157 insertions, 251 deletions
diff --git a/drivers/hwmon/nct7802.c b/drivers/hwmon/nct7802.c
index 2876c18ed841..6aa44492ae30 100644
--- a/drivers/hwmon/nct7802.c
+++ b/drivers/hwmon/nct7802.c
@@ -69,8 +69,8 @@ struct nct7802_data {
69 struct mutex access_lock; /* for multi-byte read and write operations */ 69 struct mutex access_lock; /* for multi-byte read and write operations */
70}; 70};
71 71
72static ssize_t show_temp_type(struct device *dev, struct device_attribute *attr, 72static ssize_t temp_type_show(struct device *dev,
73 char *buf) 73 struct device_attribute *attr, char *buf)
74{ 74{
75 struct nct7802_data *data = dev_get_drvdata(dev); 75 struct nct7802_data *data = dev_get_drvdata(dev);
76 struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr); 76 struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr);
@@ -84,9 +84,9 @@ static ssize_t show_temp_type(struct device *dev, struct device_attribute *attr,
84 return sprintf(buf, "%u\n", (mode >> (2 * sattr->index) & 3) + 2); 84 return sprintf(buf, "%u\n", (mode >> (2 * sattr->index) & 3) + 2);
85} 85}
86 86
87static ssize_t store_temp_type(struct device *dev, 87static ssize_t temp_type_store(struct device *dev,
88 struct device_attribute *attr, 88 struct device_attribute *attr, const char *buf,
89 const char *buf, size_t count) 89 size_t count)
90{ 90{
91 struct nct7802_data *data = dev_get_drvdata(dev); 91 struct nct7802_data *data = dev_get_drvdata(dev);
92 struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr); 92 struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr);
@@ -105,8 +105,8 @@ static ssize_t store_temp_type(struct device *dev,
105 return err ? : count; 105 return err ? : count;
106} 106}
107 107
108static ssize_t show_pwm_mode(struct device *dev, struct device_attribute *attr, 108static ssize_t pwm_mode_show(struct device *dev,
109 char *buf) 109 struct device_attribute *attr, char *buf)
110{ 110{
111 struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr); 111 struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr);
112 struct nct7802_data *data = dev_get_drvdata(dev); 112 struct nct7802_data *data = dev_get_drvdata(dev);
@@ -123,7 +123,7 @@ static ssize_t show_pwm_mode(struct device *dev, struct device_attribute *attr,
123 return sprintf(buf, "%u\n", !(regval & (1 << sattr->index))); 123 return sprintf(buf, "%u\n", !(regval & (1 << sattr->index)));
124} 124}
125 125
126static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, 126static ssize_t pwm_show(struct device *dev, struct device_attribute *devattr,
127 char *buf) 127 char *buf)
128{ 128{
129 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 129 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
@@ -141,7 +141,7 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr,
141 return sprintf(buf, "%d\n", val); 141 return sprintf(buf, "%d\n", val);
142} 142}
143 143
144static ssize_t store_pwm(struct device *dev, struct device_attribute *devattr, 144static ssize_t pwm_store(struct device *dev, struct device_attribute *devattr,
145 const char *buf, size_t count) 145 const char *buf, size_t count)
146{ 146{
147 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 147 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
@@ -157,7 +157,7 @@ static ssize_t store_pwm(struct device *dev, struct device_attribute *devattr,
157 return err ? : count; 157 return err ? : count;
158} 158}
159 159
160static ssize_t show_pwm_enable(struct device *dev, 160static ssize_t pwm_enable_show(struct device *dev,
161 struct device_attribute *attr, char *buf) 161 struct device_attribute *attr, char *buf)
162{ 162{
163 struct nct7802_data *data = dev_get_drvdata(dev); 163 struct nct7802_data *data = dev_get_drvdata(dev);
@@ -172,7 +172,7 @@ static ssize_t show_pwm_enable(struct device *dev,
172 return sprintf(buf, "%u\n", enabled + 1); 172 return sprintf(buf, "%u\n", enabled + 1);
173} 173}
174 174
175static ssize_t store_pwm_enable(struct device *dev, 175static ssize_t pwm_enable_store(struct device *dev,
176 struct device_attribute *attr, 176 struct device_attribute *attr,
177 const char *buf, size_t count) 177 const char *buf, size_t count)
178{ 178{
@@ -345,7 +345,7 @@ abort:
345 return err; 345 return err;
346} 346}
347 347
348static ssize_t show_in(struct device *dev, struct device_attribute *attr, 348static ssize_t in_show(struct device *dev, struct device_attribute *attr,
349 char *buf) 349 char *buf)
350{ 350{
351 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); 351 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
@@ -359,7 +359,7 @@ static ssize_t show_in(struct device *dev, struct device_attribute *attr,
359 return sprintf(buf, "%d\n", voltage); 359 return sprintf(buf, "%d\n", voltage);
360} 360}
361 361
362static ssize_t store_in(struct device *dev, struct device_attribute *attr, 362static ssize_t in_store(struct device *dev, struct device_attribute *attr,
363 const char *buf, size_t count) 363 const char *buf, size_t count)
364{ 364{
365 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); 365 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
@@ -377,7 +377,7 @@ static ssize_t store_in(struct device *dev, struct device_attribute *attr,
377 return err ? : count; 377 return err ? : count;
378} 378}
379 379
380static ssize_t show_temp(struct device *dev, struct device_attribute *attr, 380static ssize_t temp_show(struct device *dev, struct device_attribute *attr,
381 char *buf) 381 char *buf)
382{ 382{
383 struct nct7802_data *data = dev_get_drvdata(dev); 383 struct nct7802_data *data = dev_get_drvdata(dev);
@@ -391,7 +391,7 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *attr,
391 return sprintf(buf, "%d\n", temp); 391 return sprintf(buf, "%d\n", temp);
392} 392}
393 393
394static ssize_t store_temp(struct device *dev, struct device_attribute *attr, 394static ssize_t temp_store(struct device *dev, struct device_attribute *attr,
395 const char *buf, size_t count) 395 const char *buf, size_t count)
396{ 396{
397 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); 397 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
@@ -410,7 +410,7 @@ static ssize_t store_temp(struct device *dev, struct device_attribute *attr,
410 return err ? : count; 410 return err ? : count;
411} 411}
412 412
413static ssize_t show_fan(struct device *dev, struct device_attribute *attr, 413static ssize_t fan_show(struct device *dev, struct device_attribute *attr,
414 char *buf) 414 char *buf)
415{ 415{
416 struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr); 416 struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr);
@@ -424,7 +424,7 @@ static ssize_t show_fan(struct device *dev, struct device_attribute *attr,
424 return sprintf(buf, "%d\n", speed); 424 return sprintf(buf, "%d\n", speed);
425} 425}
426 426
427static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr, 427static ssize_t fan_min_show(struct device *dev, struct device_attribute *attr,
428 char *buf) 428 char *buf)
429{ 429{
430 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); 430 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
@@ -438,8 +438,9 @@ static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr,
438 return sprintf(buf, "%d\n", speed); 438 return sprintf(buf, "%d\n", speed);
439} 439}
440 440
441static ssize_t store_fan_min(struct device *dev, struct device_attribute *attr, 441static ssize_t fan_min_store(struct device *dev,
442 const char *buf, size_t count) 442 struct device_attribute *attr, const char *buf,
443 size_t count)
443{ 444{
444 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); 445 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
445 struct nct7802_data *data = dev_get_drvdata(dev); 446 struct nct7802_data *data = dev_get_drvdata(dev);
@@ -454,7 +455,7 @@ static ssize_t store_fan_min(struct device *dev, struct device_attribute *attr,
454 return err ? : count; 455 return err ? : count;
455} 456}
456 457
457static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, 458static ssize_t alarm_show(struct device *dev, struct device_attribute *attr,
458 char *buf) 459 char *buf)
459{ 460{
460 struct nct7802_data *data = dev_get_drvdata(dev); 461 struct nct7802_data *data = dev_get_drvdata(dev);
@@ -471,7 +472,7 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *attr,
471} 472}
472 473
473static ssize_t 474static ssize_t
474show_beep(struct device *dev, struct device_attribute *attr, char *buf) 475beep_show(struct device *dev, struct device_attribute *attr, char *buf)
475{ 476{
476 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); 477 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
477 struct nct7802_data *data = dev_get_drvdata(dev); 478 struct nct7802_data *data = dev_get_drvdata(dev);
@@ -486,7 +487,7 @@ show_beep(struct device *dev, struct device_attribute *attr, char *buf)
486} 487}
487 488
488static ssize_t 489static ssize_t
489store_beep(struct device *dev, struct device_attribute *attr, const char *buf, 490beep_store(struct device *dev, struct device_attribute *attr, const char *buf,
490 size_t count) 491 size_t count)
491{ 492{
492 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); 493 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
@@ -505,108 +506,64 @@ store_beep(struct device *dev, struct device_attribute *attr, const char *buf,
505 return err ? : count; 506 return err ? : count;
506} 507}
507 508
508static SENSOR_DEVICE_ATTR(temp1_type, S_IRUGO | S_IWUSR, 509static SENSOR_DEVICE_ATTR_RW(temp1_type, temp_type, 0);
509 show_temp_type, store_temp_type, 0); 510static SENSOR_DEVICE_ATTR_2_RO(temp1_input, temp, 0x01, REG_TEMP_LSB);
510static SENSOR_DEVICE_ATTR_2(temp1_input, S_IRUGO, show_temp, NULL, 0x01, 511static SENSOR_DEVICE_ATTR_2_RW(temp1_min, temp, 0x31, 0);
511 REG_TEMP_LSB); 512static SENSOR_DEVICE_ATTR_2_RW(temp1_max, temp, 0x30, 0);
512static SENSOR_DEVICE_ATTR_2(temp1_min, S_IRUGO | S_IWUSR, show_temp, 513static SENSOR_DEVICE_ATTR_2_RW(temp1_crit, temp, 0x3a, 0);
513 store_temp, 0x31, 0); 514
514static SENSOR_DEVICE_ATTR_2(temp1_max, S_IRUGO | S_IWUSR, show_temp, 515static SENSOR_DEVICE_ATTR_RW(temp2_type, temp_type, 1);
515 store_temp, 0x30, 0); 516static SENSOR_DEVICE_ATTR_2_RO(temp2_input, temp, 0x02, REG_TEMP_LSB);
516static SENSOR_DEVICE_ATTR_2(temp1_crit, S_IRUGO | S_IWUSR, show_temp, 517static SENSOR_DEVICE_ATTR_2_RW(temp2_min, temp, 0x33, 0);
517 store_temp, 0x3a, 0); 518static SENSOR_DEVICE_ATTR_2_RW(temp2_max, temp, 0x32, 0);
518 519static SENSOR_DEVICE_ATTR_2_RW(temp2_crit, temp, 0x3b, 0);
519static SENSOR_DEVICE_ATTR(temp2_type, S_IRUGO | S_IWUSR, 520
520 show_temp_type, store_temp_type, 1); 521static SENSOR_DEVICE_ATTR_RW(temp3_type, temp_type, 2);
521static SENSOR_DEVICE_ATTR_2(temp2_input, S_IRUGO, show_temp, NULL, 0x02, 522static SENSOR_DEVICE_ATTR_2_RO(temp3_input, temp, 0x03, REG_TEMP_LSB);
522 REG_TEMP_LSB); 523static SENSOR_DEVICE_ATTR_2_RW(temp3_min, temp, 0x35, 0);
523static SENSOR_DEVICE_ATTR_2(temp2_min, S_IRUGO | S_IWUSR, show_temp, 524static SENSOR_DEVICE_ATTR_2_RW(temp3_max, temp, 0x34, 0);
524 store_temp, 0x33, 0); 525static SENSOR_DEVICE_ATTR_2_RW(temp3_crit, temp, 0x3c, 0);
525static SENSOR_DEVICE_ATTR_2(temp2_max, S_IRUGO | S_IWUSR, show_temp, 526
526 store_temp, 0x32, 0); 527static SENSOR_DEVICE_ATTR_2_RO(temp4_input, temp, 0x04, 0);
527static SENSOR_DEVICE_ATTR_2(temp2_crit, S_IRUGO | S_IWUSR, show_temp, 528static SENSOR_DEVICE_ATTR_2_RW(temp4_min, temp, 0x37, 0);
528 store_temp, 0x3b, 0); 529static SENSOR_DEVICE_ATTR_2_RW(temp4_max, temp, 0x36, 0);
529 530static SENSOR_DEVICE_ATTR_2_RW(temp4_crit, temp, 0x3d, 0);
530static SENSOR_DEVICE_ATTR(temp3_type, S_IRUGO | S_IWUSR, 531
531 show_temp_type, store_temp_type, 2); 532static SENSOR_DEVICE_ATTR_2_RO(temp5_input, temp, 0x06, REG_TEMP_PECI_LSB);
532static SENSOR_DEVICE_ATTR_2(temp3_input, S_IRUGO, show_temp, NULL, 0x03, 533static SENSOR_DEVICE_ATTR_2_RW(temp5_min, temp, 0x39, 0);
533 REG_TEMP_LSB); 534static SENSOR_DEVICE_ATTR_2_RW(temp5_max, temp, 0x38, 0);
534static SENSOR_DEVICE_ATTR_2(temp3_min, S_IRUGO | S_IWUSR, show_temp, 535static SENSOR_DEVICE_ATTR_2_RW(temp5_crit, temp, 0x3e, 0);
535 store_temp, 0x35, 0); 536
536static SENSOR_DEVICE_ATTR_2(temp3_max, S_IRUGO | S_IWUSR, show_temp, 537static SENSOR_DEVICE_ATTR_2_RO(temp6_input, temp, 0x07, REG_TEMP_PECI_LSB);
537 store_temp, 0x34, 0); 538
538static SENSOR_DEVICE_ATTR_2(temp3_crit, S_IRUGO | S_IWUSR, show_temp, 539static SENSOR_DEVICE_ATTR_2_RO(temp1_min_alarm, alarm, 0x18, 0);
539 store_temp, 0x3c, 0); 540static SENSOR_DEVICE_ATTR_2_RO(temp2_min_alarm, alarm, 0x18, 1);
540 541static SENSOR_DEVICE_ATTR_2_RO(temp3_min_alarm, alarm, 0x18, 2);
541static SENSOR_DEVICE_ATTR_2(temp4_input, S_IRUGO, show_temp, NULL, 0x04, 0); 542static SENSOR_DEVICE_ATTR_2_RO(temp4_min_alarm, alarm, 0x18, 3);
542static SENSOR_DEVICE_ATTR_2(temp4_min, S_IRUGO | S_IWUSR, show_temp, 543static SENSOR_DEVICE_ATTR_2_RO(temp5_min_alarm, alarm, 0x18, 4);
543 store_temp, 0x37, 0); 544
544static SENSOR_DEVICE_ATTR_2(temp4_max, S_IRUGO | S_IWUSR, show_temp, 545static SENSOR_DEVICE_ATTR_2_RO(temp1_max_alarm, alarm, 0x19, 0);
545 store_temp, 0x36, 0); 546static SENSOR_DEVICE_ATTR_2_RO(temp2_max_alarm, alarm, 0x19, 1);
546static SENSOR_DEVICE_ATTR_2(temp4_crit, S_IRUGO | S_IWUSR, show_temp, 547static SENSOR_DEVICE_ATTR_2_RO(temp3_max_alarm, alarm, 0x19, 2);
547 store_temp, 0x3d, 0); 548static SENSOR_DEVICE_ATTR_2_RO(temp4_max_alarm, alarm, 0x19, 3);
548 549static SENSOR_DEVICE_ATTR_2_RO(temp5_max_alarm, alarm, 0x19, 4);
549static SENSOR_DEVICE_ATTR_2(temp5_input, S_IRUGO, show_temp, NULL, 0x06, 550
550 REG_TEMP_PECI_LSB); 551static SENSOR_DEVICE_ATTR_2_RO(temp1_crit_alarm, alarm, 0x1b, 0);
551static SENSOR_DEVICE_ATTR_2(temp5_min, S_IRUGO | S_IWUSR, show_temp, 552static SENSOR_DEVICE_ATTR_2_RO(temp2_crit_alarm, alarm, 0x1b, 1);
552 store_temp, 0x39, 0); 553static SENSOR_DEVICE_ATTR_2_RO(temp3_crit_alarm, alarm, 0x1b, 2);
553static SENSOR_DEVICE_ATTR_2(temp5_max, S_IRUGO | S_IWUSR, show_temp, 554static SENSOR_DEVICE_ATTR_2_RO(temp4_crit_alarm, alarm, 0x1b, 3);
554 store_temp, 0x38, 0); 555static SENSOR_DEVICE_ATTR_2_RO(temp5_crit_alarm, alarm, 0x1b, 4);
555static SENSOR_DEVICE_ATTR_2(temp5_crit, S_IRUGO | S_IWUSR, show_temp, 556
556 store_temp, 0x3e, 0); 557static SENSOR_DEVICE_ATTR_2_RO(temp1_fault, alarm, 0x17, 0);
557 558static SENSOR_DEVICE_ATTR_2_RO(temp2_fault, alarm, 0x17, 1);
558static SENSOR_DEVICE_ATTR_2(temp6_input, S_IRUGO, show_temp, NULL, 0x07, 559static SENSOR_DEVICE_ATTR_2_RO(temp3_fault, alarm, 0x17, 2);
559 REG_TEMP_PECI_LSB); 560
560 561static SENSOR_DEVICE_ATTR_2_RW(temp1_beep, beep, 0x5c, 0);
561static SENSOR_DEVICE_ATTR_2(temp1_min_alarm, S_IRUGO, show_alarm, NULL, 562static SENSOR_DEVICE_ATTR_2_RW(temp2_beep, beep, 0x5c, 1);
562 0x18, 0); 563static SENSOR_DEVICE_ATTR_2_RW(temp3_beep, beep, 0x5c, 2);
563static SENSOR_DEVICE_ATTR_2(temp2_min_alarm, S_IRUGO, show_alarm, NULL, 564static SENSOR_DEVICE_ATTR_2_RW(temp4_beep, beep, 0x5c, 3);
564 0x18, 1); 565static SENSOR_DEVICE_ATTR_2_RW(temp5_beep, beep, 0x5c, 4);
565static SENSOR_DEVICE_ATTR_2(temp3_min_alarm, S_IRUGO, show_alarm, NULL, 566static SENSOR_DEVICE_ATTR_2_RW(temp6_beep, beep, 0x5c, 5);
566 0x18, 2);
567static SENSOR_DEVICE_ATTR_2(temp4_min_alarm, S_IRUGO, show_alarm, NULL,
568 0x18, 3);
569static SENSOR_DEVICE_ATTR_2(temp5_min_alarm, S_IRUGO, show_alarm, NULL,
570 0x18, 4);
571
572static SENSOR_DEVICE_ATTR_2(temp1_max_alarm, S_IRUGO, show_alarm, NULL,
573 0x19, 0);
574static SENSOR_DEVICE_ATTR_2(temp2_max_alarm, S_IRUGO, show_alarm, NULL,
575 0x19, 1);
576static SENSOR_DEVICE_ATTR_2(temp3_max_alarm, S_IRUGO, show_alarm, NULL,
577 0x19, 2);
578static SENSOR_DEVICE_ATTR_2(temp4_max_alarm, S_IRUGO, show_alarm, NULL,
579 0x19, 3);
580static SENSOR_DEVICE_ATTR_2(temp5_max_alarm, S_IRUGO, show_alarm, NULL,
581 0x19, 4);
582
583static SENSOR_DEVICE_ATTR_2(temp1_crit_alarm, S_IRUGO, show_alarm, NULL,
584 0x1b, 0);
585static SENSOR_DEVICE_ATTR_2(temp2_crit_alarm, S_IRUGO, show_alarm, NULL,
586 0x1b, 1);
587static SENSOR_DEVICE_ATTR_2(temp3_crit_alarm, S_IRUGO, show_alarm, NULL,
588 0x1b, 2);
589static SENSOR_DEVICE_ATTR_2(temp4_crit_alarm, S_IRUGO, show_alarm, NULL,
590 0x1b, 3);
591static SENSOR_DEVICE_ATTR_2(temp5_crit_alarm, S_IRUGO, show_alarm, NULL,
592 0x1b, 4);
593
594static SENSOR_DEVICE_ATTR_2(temp1_fault, S_IRUGO, show_alarm, NULL, 0x17, 0);
595static SENSOR_DEVICE_ATTR_2(temp2_fault, S_IRUGO, show_alarm, NULL, 0x17, 1);
596static SENSOR_DEVICE_ATTR_2(temp3_fault, S_IRUGO, show_alarm, NULL, 0x17, 2);
597
598static SENSOR_DEVICE_ATTR_2(temp1_beep, S_IRUGO | S_IWUSR, show_beep,
599 store_beep, 0x5c, 0);
600static SENSOR_DEVICE_ATTR_2(temp2_beep, S_IRUGO | S_IWUSR, show_beep,
601 store_beep, 0x5c, 1);
602static SENSOR_DEVICE_ATTR_2(temp3_beep, S_IRUGO | S_IWUSR, show_beep,
603 store_beep, 0x5c, 2);
604static SENSOR_DEVICE_ATTR_2(temp4_beep, S_IRUGO | S_IWUSR, show_beep,
605 store_beep, 0x5c, 3);
606static SENSOR_DEVICE_ATTR_2(temp5_beep, S_IRUGO | S_IWUSR, show_beep,
607 store_beep, 0x5c, 4);
608static SENSOR_DEVICE_ATTR_2(temp6_beep, S_IRUGO | S_IWUSR, show_beep,
609 store_beep, 0x5c, 5);
610 567
611static struct attribute *nct7802_temp_attrs[] = { 568static struct attribute *nct7802_temp_attrs[] = {
612 &sensor_dev_attr_temp1_type.dev_attr.attr, 569 &sensor_dev_attr_temp1_type.dev_attr.attr,
@@ -709,43 +666,31 @@ static const struct attribute_group nct7802_temp_group = {
709 .is_visible = nct7802_temp_is_visible, 666 .is_visible = nct7802_temp_is_visible,
710}; 667};
711 668
712static SENSOR_DEVICE_ATTR_2(in0_input, S_IRUGO, show_in, NULL, 0, 0); 669static SENSOR_DEVICE_ATTR_2_RO(in0_input, in, 0, 0);
713static SENSOR_DEVICE_ATTR_2(in0_min, S_IRUGO | S_IWUSR, show_in, store_in, 670static SENSOR_DEVICE_ATTR_2_RW(in0_min, in, 0, 1);
714 0, 1); 671static SENSOR_DEVICE_ATTR_2_RW(in0_max, in, 0, 2);
715static SENSOR_DEVICE_ATTR_2(in0_max, S_IRUGO | S_IWUSR, show_in, store_in, 672static SENSOR_DEVICE_ATTR_2_RO(in0_alarm, alarm, 0x1e, 3);
716 0, 2); 673static SENSOR_DEVICE_ATTR_2_RW(in0_beep, beep, 0x5a, 3);
717static SENSOR_DEVICE_ATTR_2(in0_alarm, S_IRUGO, show_alarm, NULL, 0x1e, 3); 674
718static SENSOR_DEVICE_ATTR_2(in0_beep, S_IRUGO | S_IWUSR, show_beep, store_beep, 675static SENSOR_DEVICE_ATTR_2_RO(in1_input, in, 1, 0);
719 0x5a, 3); 676
720 677static SENSOR_DEVICE_ATTR_2_RO(in2_input, in, 2, 0);
721static SENSOR_DEVICE_ATTR_2(in1_input, S_IRUGO, show_in, NULL, 1, 0); 678static SENSOR_DEVICE_ATTR_2_RW(in2_min, in, 2, 1);
722 679static SENSOR_DEVICE_ATTR_2_RW(in2_max, in, 2, 2);
723static SENSOR_DEVICE_ATTR_2(in2_input, S_IRUGO, show_in, NULL, 2, 0); 680static SENSOR_DEVICE_ATTR_2_RO(in2_alarm, alarm, 0x1e, 0);
724static SENSOR_DEVICE_ATTR_2(in2_min, S_IRUGO | S_IWUSR, show_in, store_in, 681static SENSOR_DEVICE_ATTR_2_RW(in2_beep, beep, 0x5a, 0);
725 2, 1); 682
726static SENSOR_DEVICE_ATTR_2(in2_max, S_IRUGO | S_IWUSR, show_in, store_in, 683static SENSOR_DEVICE_ATTR_2_RO(in3_input, in, 3, 0);
727 2, 2); 684static SENSOR_DEVICE_ATTR_2_RW(in3_min, in, 3, 1);
728static SENSOR_DEVICE_ATTR_2(in2_alarm, S_IRUGO, show_alarm, NULL, 0x1e, 0); 685static SENSOR_DEVICE_ATTR_2_RW(in3_max, in, 3, 2);
729static SENSOR_DEVICE_ATTR_2(in2_beep, S_IRUGO | S_IWUSR, show_beep, store_beep, 686static SENSOR_DEVICE_ATTR_2_RO(in3_alarm, alarm, 0x1e, 1);
730 0x5a, 0); 687static SENSOR_DEVICE_ATTR_2_RW(in3_beep, beep, 0x5a, 1);
731 688
732static SENSOR_DEVICE_ATTR_2(in3_input, S_IRUGO, show_in, NULL, 3, 0); 689static SENSOR_DEVICE_ATTR_2_RO(in4_input, in, 4, 0);
733static SENSOR_DEVICE_ATTR_2(in3_min, S_IRUGO | S_IWUSR, show_in, store_in, 690static SENSOR_DEVICE_ATTR_2_RW(in4_min, in, 4, 1);
734 3, 1); 691static SENSOR_DEVICE_ATTR_2_RW(in4_max, in, 4, 2);
735static SENSOR_DEVICE_ATTR_2(in3_max, S_IRUGO | S_IWUSR, show_in, store_in, 692static SENSOR_DEVICE_ATTR_2_RO(in4_alarm, alarm, 0x1e, 2);
736 3, 2); 693static SENSOR_DEVICE_ATTR_2_RW(in4_beep, beep, 0x5a, 2);
737static SENSOR_DEVICE_ATTR_2(in3_alarm, S_IRUGO, show_alarm, NULL, 0x1e, 1);
738static SENSOR_DEVICE_ATTR_2(in3_beep, S_IRUGO | S_IWUSR, show_beep, store_beep,
739 0x5a, 1);
740
741static SENSOR_DEVICE_ATTR_2(in4_input, S_IRUGO, show_in, NULL, 4, 0);
742static SENSOR_DEVICE_ATTR_2(in4_min, S_IRUGO | S_IWUSR, show_in, store_in,
743 4, 1);
744static SENSOR_DEVICE_ATTR_2(in4_max, S_IRUGO | S_IWUSR, show_in, store_in,
745 4, 2);
746static SENSOR_DEVICE_ATTR_2(in4_alarm, S_IRUGO, show_alarm, NULL, 0x1e, 2);
747static SENSOR_DEVICE_ATTR_2(in4_beep, S_IRUGO | S_IWUSR, show_beep, store_beep,
748 0x5a, 2);
749 694
750static struct attribute *nct7802_in_attrs[] = { 695static struct attribute *nct7802_in_attrs[] = {
751 &sensor_dev_attr_in0_input.dev_attr.attr, 696 &sensor_dev_attr_in0_input.dev_attr.attr,
@@ -807,45 +752,33 @@ static const struct attribute_group nct7802_in_group = {
807 .is_visible = nct7802_in_is_visible, 752 .is_visible = nct7802_in_is_visible,
808}; 753};
809 754
810static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0x10); 755static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, 0x10);
811static SENSOR_DEVICE_ATTR_2(fan1_min, S_IRUGO | S_IWUSR, show_fan_min, 756static SENSOR_DEVICE_ATTR_2_RW(fan1_min, fan_min, 0x49, 0x4c);
812 store_fan_min, 0x49, 0x4c); 757static SENSOR_DEVICE_ATTR_2_RO(fan1_alarm, alarm, 0x1a, 0);
813static SENSOR_DEVICE_ATTR_2(fan1_alarm, S_IRUGO, show_alarm, NULL, 0x1a, 0); 758static SENSOR_DEVICE_ATTR_2_RW(fan1_beep, beep, 0x5b, 0);
814static SENSOR_DEVICE_ATTR_2(fan1_beep, S_IRUGO | S_IWUSR, show_beep, store_beep, 759static SENSOR_DEVICE_ATTR_RO(fan2_input, fan, 0x11);
815 0x5b, 0); 760static SENSOR_DEVICE_ATTR_2_RW(fan2_min, fan_min, 0x4a, 0x4d);
816static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 0x11); 761static SENSOR_DEVICE_ATTR_2_RO(fan2_alarm, alarm, 0x1a, 1);
817static SENSOR_DEVICE_ATTR_2(fan2_min, S_IRUGO | S_IWUSR, show_fan_min, 762static SENSOR_DEVICE_ATTR_2_RW(fan2_beep, beep, 0x5b, 1);
818 store_fan_min, 0x4a, 0x4d); 763static SENSOR_DEVICE_ATTR_RO(fan3_input, fan, 0x12);
819static SENSOR_DEVICE_ATTR_2(fan2_alarm, S_IRUGO, show_alarm, NULL, 0x1a, 1); 764static SENSOR_DEVICE_ATTR_2_RW(fan3_min, fan_min, 0x4b, 0x4e);
820static SENSOR_DEVICE_ATTR_2(fan2_beep, S_IRUGO | S_IWUSR, show_beep, store_beep, 765static SENSOR_DEVICE_ATTR_2_RO(fan3_alarm, alarm, 0x1a, 2);
821 0x5b, 1); 766static SENSOR_DEVICE_ATTR_2_RW(fan3_beep, beep, 0x5b, 2);
822static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 0x12);
823static SENSOR_DEVICE_ATTR_2(fan3_min, S_IRUGO | S_IWUSR, show_fan_min,
824 store_fan_min, 0x4b, 0x4e);
825static SENSOR_DEVICE_ATTR_2(fan3_alarm, S_IRUGO, show_alarm, NULL, 0x1a, 2);
826static SENSOR_DEVICE_ATTR_2(fan3_beep, S_IRUGO | S_IWUSR, show_beep, store_beep,
827 0x5b, 2);
828 767
829/* 7.2.89 Fan Control Output Type */ 768/* 7.2.89 Fan Control Output Type */
830static SENSOR_DEVICE_ATTR(pwm1_mode, S_IRUGO, show_pwm_mode, NULL, 0); 769static SENSOR_DEVICE_ATTR_RO(pwm1_mode, pwm_mode, 0);
831static SENSOR_DEVICE_ATTR(pwm2_mode, S_IRUGO, show_pwm_mode, NULL, 1); 770static SENSOR_DEVICE_ATTR_RO(pwm2_mode, pwm_mode, 1);
832static SENSOR_DEVICE_ATTR(pwm3_mode, S_IRUGO, show_pwm_mode, NULL, 2); 771static SENSOR_DEVICE_ATTR_RO(pwm3_mode, pwm_mode, 2);
833 772
834/* 7.2.91... Fan Control Output Value */ 773/* 7.2.91... Fan Control Output Value */
835static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_pwm, store_pwm, 774static SENSOR_DEVICE_ATTR_RW(pwm1, pwm, REG_PWM(0));
836 REG_PWM(0)); 775static SENSOR_DEVICE_ATTR_RW(pwm2, pwm, REG_PWM(1));
837static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, show_pwm, store_pwm, 776static SENSOR_DEVICE_ATTR_RW(pwm3, pwm, REG_PWM(2));
838 REG_PWM(1));
839static SENSOR_DEVICE_ATTR(pwm3, S_IRUGO | S_IWUSR, show_pwm, store_pwm,
840 REG_PWM(2));
841 777
842/* 7.2.95... Temperature to Fan mapping Relationships Register */ 778/* 7.2.95... Temperature to Fan mapping Relationships Register */
843static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, show_pwm_enable, 779static SENSOR_DEVICE_ATTR_RW(pwm1_enable, pwm_enable, 0);
844 store_pwm_enable, 0); 780static SENSOR_DEVICE_ATTR_RW(pwm2_enable, pwm_enable, 1);
845static SENSOR_DEVICE_ATTR(pwm2_enable, S_IRUGO | S_IWUSR, show_pwm_enable, 781static SENSOR_DEVICE_ATTR_RW(pwm3_enable, pwm_enable, 2);
846 store_pwm_enable, 1);
847static SENSOR_DEVICE_ATTR(pwm3_enable, S_IRUGO | S_IWUSR, show_pwm_enable,
848 store_pwm_enable, 2);
849 782
850static struct attribute *nct7802_fan_attrs[] = { 783static struct attribute *nct7802_fan_attrs[] = {
851 &sensor_dev_attr_fan1_input.dev_attr.attr, 784 &sensor_dev_attr_fan1_input.dev_attr.attr,
@@ -903,73 +836,46 @@ static const struct attribute_group nct7802_pwm_group = {
903}; 836};
904 837
905/* 7.2.115... 0x80-0x83, 0x84 Temperature (X-axis) transition */ 838/* 7.2.115... 0x80-0x83, 0x84 Temperature (X-axis) transition */
906static SENSOR_DEVICE_ATTR_2(pwm1_auto_point1_temp, S_IRUGO | S_IWUSR, 839static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point1_temp, temp, 0x80, 0);
907 show_temp, store_temp, 0x80, 0); 840static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point2_temp, temp, 0x81, 0);
908static SENSOR_DEVICE_ATTR_2(pwm1_auto_point2_temp, S_IRUGO | S_IWUSR, 841static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point3_temp, temp, 0x82, 0);
909 show_temp, store_temp, 0x81, 0); 842static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point4_temp, temp, 0x83, 0);
910static SENSOR_DEVICE_ATTR_2(pwm1_auto_point3_temp, S_IRUGO | S_IWUSR, 843static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point5_temp, temp, 0x84, 0);
911 show_temp, store_temp, 0x82, 0);
912static SENSOR_DEVICE_ATTR_2(pwm1_auto_point4_temp, S_IRUGO | S_IWUSR,
913 show_temp, store_temp, 0x83, 0);
914static SENSOR_DEVICE_ATTR_2(pwm1_auto_point5_temp, S_IRUGO | S_IWUSR,
915 show_temp, store_temp, 0x84, 0);
916 844
917/* 7.2.120... 0x85-0x88 PWM (Y-axis) transition */ 845/* 7.2.120... 0x85-0x88 PWM (Y-axis) transition */
918static SENSOR_DEVICE_ATTR(pwm1_auto_point1_pwm, S_IRUGO | S_IWUSR, 846static SENSOR_DEVICE_ATTR_RW(pwm1_auto_point1_pwm, pwm, 0x85);
919 show_pwm, store_pwm, 0x85); 847static SENSOR_DEVICE_ATTR_RW(pwm1_auto_point2_pwm, pwm, 0x86);
920static SENSOR_DEVICE_ATTR(pwm1_auto_point2_pwm, S_IRUGO | S_IWUSR, 848static SENSOR_DEVICE_ATTR_RW(pwm1_auto_point3_pwm, pwm, 0x87);
921 show_pwm, store_pwm, 0x86); 849static SENSOR_DEVICE_ATTR_RW(pwm1_auto_point4_pwm, pwm, 0x88);
922static SENSOR_DEVICE_ATTR(pwm1_auto_point3_pwm, S_IRUGO | S_IWUSR, 850static SENSOR_DEVICE_ATTR_RO(pwm1_auto_point5_pwm, pwm, 0);
923 show_pwm, store_pwm, 0x87);
924static SENSOR_DEVICE_ATTR(pwm1_auto_point4_pwm, S_IRUGO | S_IWUSR,
925 show_pwm, store_pwm, 0x88);
926static SENSOR_DEVICE_ATTR(pwm1_auto_point5_pwm, S_IRUGO, show_pwm, NULL, 0);
927 851
928/* 7.2.124 Table 2 X-axis Transition Point 1 Register */ 852/* 7.2.124 Table 2 X-axis Transition Point 1 Register */
929static SENSOR_DEVICE_ATTR_2(pwm2_auto_point1_temp, S_IRUGO | S_IWUSR, 853static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point1_temp, temp, 0x90, 0);
930 show_temp, store_temp, 0x90, 0); 854static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point2_temp, temp, 0x91, 0);
931static SENSOR_DEVICE_ATTR_2(pwm2_auto_point2_temp, S_IRUGO | S_IWUSR, 855static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point3_temp, temp, 0x92, 0);
932 show_temp, store_temp, 0x91, 0); 856static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point4_temp, temp, 0x93, 0);
933static SENSOR_DEVICE_ATTR_2(pwm2_auto_point3_temp, S_IRUGO | S_IWUSR, 857static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point5_temp, temp, 0x94, 0);
934 show_temp, store_temp, 0x92, 0);
935static SENSOR_DEVICE_ATTR_2(pwm2_auto_point4_temp, S_IRUGO | S_IWUSR,
936 show_temp, store_temp, 0x93, 0);
937static SENSOR_DEVICE_ATTR_2(pwm2_auto_point5_temp, S_IRUGO | S_IWUSR,
938 show_temp, store_temp, 0x94, 0);
939 858
940/* 7.2.129 Table 2 Y-axis Transition Point 1 Register */ 859/* 7.2.129 Table 2 Y-axis Transition Point 1 Register */
941static SENSOR_DEVICE_ATTR(pwm2_auto_point1_pwm, S_IRUGO | S_IWUSR, 860static SENSOR_DEVICE_ATTR_RW(pwm2_auto_point1_pwm, pwm, 0x95);
942 show_pwm, store_pwm, 0x95); 861static SENSOR_DEVICE_ATTR_RW(pwm2_auto_point2_pwm, pwm, 0x96);
943static SENSOR_DEVICE_ATTR(pwm2_auto_point2_pwm, S_IRUGO | S_IWUSR, 862static SENSOR_DEVICE_ATTR_RW(pwm2_auto_point3_pwm, pwm, 0x97);
944 show_pwm, store_pwm, 0x96); 863static SENSOR_DEVICE_ATTR_RW(pwm2_auto_point4_pwm, pwm, 0x98);
945static SENSOR_DEVICE_ATTR(pwm2_auto_point3_pwm, S_IRUGO | S_IWUSR, 864static SENSOR_DEVICE_ATTR_RO(pwm2_auto_point5_pwm, pwm, 0);
946 show_pwm, store_pwm, 0x97);
947static SENSOR_DEVICE_ATTR(pwm2_auto_point4_pwm, S_IRUGO | S_IWUSR,
948 show_pwm, store_pwm, 0x98);
949static SENSOR_DEVICE_ATTR(pwm2_auto_point5_pwm, S_IRUGO, show_pwm, NULL, 0);
950 865
951/* 7.2.133 Table 3 X-axis Transition Point 1 Register */ 866/* 7.2.133 Table 3 X-axis Transition Point 1 Register */
952static SENSOR_DEVICE_ATTR_2(pwm3_auto_point1_temp, S_IRUGO | S_IWUSR, 867static SENSOR_DEVICE_ATTR_2_RW(pwm3_auto_point1_temp, temp, 0xA0, 0);
953 show_temp, store_temp, 0xA0, 0); 868static SENSOR_DEVICE_ATTR_2_RW(pwm3_auto_point2_temp, temp, 0xA1, 0);
954static SENSOR_DEVICE_ATTR_2(pwm3_auto_point2_temp, S_IRUGO | S_IWUSR, 869static SENSOR_DEVICE_ATTR_2_RW(pwm3_auto_point3_temp, temp, 0xA2, 0);
955 show_temp, store_temp, 0xA1, 0); 870static SENSOR_DEVICE_ATTR_2_RW(pwm3_auto_point4_temp, temp, 0xA3, 0);
956static SENSOR_DEVICE_ATTR_2(pwm3_auto_point3_temp, S_IRUGO | S_IWUSR, 871static SENSOR_DEVICE_ATTR_2_RW(pwm3_auto_point5_temp, temp, 0xA4, 0);
957 show_temp, store_temp, 0xA2, 0);
958static SENSOR_DEVICE_ATTR_2(pwm3_auto_point4_temp, S_IRUGO | S_IWUSR,
959 show_temp, store_temp, 0xA3, 0);
960static SENSOR_DEVICE_ATTR_2(pwm3_auto_point5_temp, S_IRUGO | S_IWUSR,
961 show_temp, store_temp, 0xA4, 0);
962 872
963/* 7.2.138 Table 3 Y-axis Transition Point 1 Register */ 873/* 7.2.138 Table 3 Y-axis Transition Point 1 Register */
964static SENSOR_DEVICE_ATTR(pwm3_auto_point1_pwm, S_IRUGO | S_IWUSR, 874static SENSOR_DEVICE_ATTR_RW(pwm3_auto_point1_pwm, pwm, 0xA5);
965 show_pwm, store_pwm, 0xA5); 875static SENSOR_DEVICE_ATTR_RW(pwm3_auto_point2_pwm, pwm, 0xA6);
966static SENSOR_DEVICE_ATTR(pwm3_auto_point2_pwm, S_IRUGO | S_IWUSR, 876static SENSOR_DEVICE_ATTR_RW(pwm3_auto_point3_pwm, pwm, 0xA7);
967 show_pwm, store_pwm, 0xA6); 877static SENSOR_DEVICE_ATTR_RW(pwm3_auto_point4_pwm, pwm, 0xA8);
968static SENSOR_DEVICE_ATTR(pwm3_auto_point3_pwm, S_IRUGO | S_IWUSR, 878static SENSOR_DEVICE_ATTR_RO(pwm3_auto_point5_pwm, pwm, 0);
969 show_pwm, store_pwm, 0xA7);
970static SENSOR_DEVICE_ATTR(pwm3_auto_point4_pwm, S_IRUGO | S_IWUSR,
971 show_pwm, store_pwm, 0xA8);
972static SENSOR_DEVICE_ATTR(pwm3_auto_point5_pwm, S_IRUGO, show_pwm, NULL, 0);
973 879
974static struct attribute *nct7802_auto_point_attrs[] = { 880static struct attribute *nct7802_auto_point_attrs[] = {
975 &sensor_dev_attr_pwm1_auto_point1_temp.dev_attr.attr, 881 &sensor_dev_attr_pwm1_auto_point1_temp.dev_attr.attr,