diff options
-rw-r--r-- | drivers/hwmon/pc87360.c | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c index db543a8d78b0..ce3232c75ae1 100644 --- a/drivers/hwmon/pc87360.c +++ b/drivers/hwmon/pc87360.c | |||
@@ -328,6 +328,12 @@ static struct sensor_device_attribute fan_min[] = { | |||
328 | SENSOR_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 2), | 328 | SENSOR_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 2), |
329 | }; | 329 | }; |
330 | 330 | ||
331 | #define FAN_UNIT_ATTRS(X) \ | ||
332 | &fan_input[X].dev_attr.attr, \ | ||
333 | &fan_status[X].dev_attr.attr, \ | ||
334 | &fan_div[X].dev_attr.attr, \ | ||
335 | &fan_min[X].dev_attr.attr | ||
336 | |||
331 | static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, char *buf) | 337 | static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, char *buf) |
332 | { | 338 | { |
333 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 339 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
@@ -360,6 +366,19 @@ static struct sensor_device_attribute pwm[] = { | |||
360 | SENSOR_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 2), | 366 | SENSOR_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 2), |
361 | }; | 367 | }; |
362 | 368 | ||
369 | static struct attribute * pc8736x_fan_attr_array[] = { | ||
370 | FAN_UNIT_ATTRS(0), | ||
371 | FAN_UNIT_ATTRS(1), | ||
372 | FAN_UNIT_ATTRS(2), | ||
373 | &pwm[0].dev_attr.attr, | ||
374 | &pwm[1].dev_attr.attr, | ||
375 | &pwm[2].dev_attr.attr, | ||
376 | NULL | ||
377 | }; | ||
378 | static const struct attribute_group pc8736x_fan_group = { | ||
379 | .attrs = pc8736x_fan_attr_array, | ||
380 | }; | ||
381 | |||
363 | static ssize_t show_in_input(struct device *dev, struct device_attribute *devattr, char *buf) | 382 | static ssize_t show_in_input(struct device *dev, struct device_attribute *devattr, char *buf) |
364 | { | 383 | { |
365 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 384 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
@@ -472,6 +491,12 @@ static struct sensor_device_attribute in_max[] = { | |||
472 | SENSOR_ATTR(in10_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 10), | 491 | SENSOR_ATTR(in10_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 10), |
473 | }; | 492 | }; |
474 | 493 | ||
494 | #define VIN_UNIT_ATTRS(X) \ | ||
495 | &in_input[X].dev_attr.attr, \ | ||
496 | &in_status[X].dev_attr.attr, \ | ||
497 | &in_min[X].dev_attr.attr, \ | ||
498 | &in_max[X].dev_attr.attr | ||
499 | |||
475 | static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf) | 500 | static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf) |
476 | { | 501 | { |
477 | struct pc87360_data *data = pc87360_update_device(dev); | 502 | struct pc87360_data *data = pc87360_update_device(dev); |
@@ -500,6 +525,27 @@ static ssize_t show_in_alarms(struct device *dev, struct device_attribute *attr, | |||
500 | } | 525 | } |
501 | static DEVICE_ATTR(alarms_in, S_IRUGO, show_in_alarms, NULL); | 526 | static DEVICE_ATTR(alarms_in, S_IRUGO, show_in_alarms, NULL); |
502 | 527 | ||
528 | static struct attribute *pc8736x_vin_attr_array[] = { | ||
529 | VIN_UNIT_ATTRS(0), | ||
530 | VIN_UNIT_ATTRS(1), | ||
531 | VIN_UNIT_ATTRS(2), | ||
532 | VIN_UNIT_ATTRS(3), | ||
533 | VIN_UNIT_ATTRS(4), | ||
534 | VIN_UNIT_ATTRS(5), | ||
535 | VIN_UNIT_ATTRS(6), | ||
536 | VIN_UNIT_ATTRS(7), | ||
537 | VIN_UNIT_ATTRS(8), | ||
538 | VIN_UNIT_ATTRS(9), | ||
539 | VIN_UNIT_ATTRS(10), | ||
540 | &dev_attr_cpu0_vid.attr, | ||
541 | &dev_attr_vrm.attr, | ||
542 | &dev_attr_alarms_in.attr, | ||
543 | NULL | ||
544 | }; | ||
545 | static const struct attribute_group pc8736x_vin_group = { | ||
546 | .attrs = pc8736x_vin_attr_array, | ||
547 | }; | ||
548 | |||
503 | static ssize_t show_therm_input(struct device *dev, struct device_attribute *devattr, char *buf) | 549 | static ssize_t show_therm_input(struct device *dev, struct device_attribute *devattr, char *buf) |
504 | { | 550 | { |
505 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 551 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
@@ -618,6 +664,23 @@ static struct sensor_device_attribute therm_crit[] = { | |||
618 | show_therm_crit, set_therm_crit, 2+11), | 664 | show_therm_crit, set_therm_crit, 2+11), |
619 | }; | 665 | }; |
620 | 666 | ||
667 | #define THERM_UNIT_ATTRS(X) \ | ||
668 | &therm_input[X].dev_attr.attr, \ | ||
669 | &therm_status[X].dev_attr.attr, \ | ||
670 | &therm_min[X].dev_attr.attr, \ | ||
671 | &therm_max[X].dev_attr.attr, \ | ||
672 | &therm_crit[X].dev_attr.attr | ||
673 | |||
674 | static struct attribute * pc8736x_therm_attr_array[] = { | ||
675 | THERM_UNIT_ATTRS(0), | ||
676 | THERM_UNIT_ATTRS(1), | ||
677 | THERM_UNIT_ATTRS(2), | ||
678 | NULL | ||
679 | }; | ||
680 | static const struct attribute_group pc8736x_therm_group = { | ||
681 | .attrs = pc8736x_therm_attr_array, | ||
682 | }; | ||
683 | |||
621 | static ssize_t show_temp_input(struct device *dev, struct device_attribute *devattr, char *buf) | 684 | static ssize_t show_temp_input(struct device *dev, struct device_attribute *devattr, char *buf) |
622 | { | 685 | { |
623 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 686 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
@@ -736,6 +799,25 @@ static ssize_t show_temp_alarms(struct device *dev, struct device_attribute *att | |||
736 | } | 799 | } |
737 | static DEVICE_ATTR(alarms_temp, S_IRUGO, show_temp_alarms, NULL); | 800 | static DEVICE_ATTR(alarms_temp, S_IRUGO, show_temp_alarms, NULL); |
738 | 801 | ||
802 | #define TEMP_UNIT_ATTRS(X) \ | ||
803 | &temp_input[X].dev_attr.attr, \ | ||
804 | &temp_status[X].dev_attr.attr, \ | ||
805 | &temp_min[X].dev_attr.attr, \ | ||
806 | &temp_max[X].dev_attr.attr, \ | ||
807 | &temp_crit[X].dev_attr.attr | ||
808 | |||
809 | static struct attribute * pc8736x_temp_attr_array[] = { | ||
810 | TEMP_UNIT_ATTRS(0), | ||
811 | TEMP_UNIT_ATTRS(1), | ||
812 | TEMP_UNIT_ATTRS(2), | ||
813 | /* include the few miscellaneous atts here */ | ||
814 | &dev_attr_alarms_temp.attr, | ||
815 | NULL | ||
816 | }; | ||
817 | static const struct attribute_group pc8736x_temp_group = { | ||
818 | .attrs = pc8736x_temp_attr_array, | ||
819 | }; | ||
820 | |||
739 | /* | 821 | /* |
740 | * Device detection, registration and update | 822 | * Device detection, registration and update |
741 | */ | 823 | */ |
@@ -1009,6 +1091,11 @@ static int pc87360_detach_client(struct i2c_client *client) | |||
1009 | 1091 | ||
1010 | hwmon_device_unregister(data->class_dev); | 1092 | hwmon_device_unregister(data->class_dev); |
1011 | 1093 | ||
1094 | sysfs_remove_group(&client->dev.kobj, &pc8736x_temp_group); | ||
1095 | sysfs_remove_group(&client->dev.kobj, &pc8736x_fan_group); | ||
1096 | sysfs_remove_group(&client->dev.kobj, &pc8736x_therm_group); | ||
1097 | sysfs_remove_group(&client->dev.kobj, &pc8736x_vin_group); | ||
1098 | |||
1012 | if ((i = i2c_detach_client(client))) | 1099 | if ((i = i2c_detach_client(client))) |
1013 | return i; | 1100 | return i; |
1014 | 1101 | ||