aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/adm9240.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/adm9240.c')
-rw-r--r--drivers/hwmon/adm9240.c105
1 files changed, 46 insertions, 59 deletions
diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c
index 43f6991b588c..377961c4a41e 100644
--- a/drivers/hwmon/adm9240.c
+++ b/drivers/hwmon/adm9240.c
@@ -465,6 +465,45 @@ static ssize_t chassis_clear(struct device *dev,
465} 465}
466static DEVICE_ATTR(chassis_clear, S_IWUSR, NULL, chassis_clear); 466static DEVICE_ATTR(chassis_clear, S_IWUSR, NULL, chassis_clear);
467 467
468static struct attribute *adm9240_attributes[] = {
469 &sensor_dev_attr_in0_input.dev_attr.attr,
470 &sensor_dev_attr_in0_min.dev_attr.attr,
471 &sensor_dev_attr_in0_max.dev_attr.attr,
472 &sensor_dev_attr_in1_input.dev_attr.attr,
473 &sensor_dev_attr_in1_min.dev_attr.attr,
474 &sensor_dev_attr_in1_max.dev_attr.attr,
475 &sensor_dev_attr_in2_input.dev_attr.attr,
476 &sensor_dev_attr_in2_min.dev_attr.attr,
477 &sensor_dev_attr_in2_max.dev_attr.attr,
478 &sensor_dev_attr_in3_input.dev_attr.attr,
479 &sensor_dev_attr_in3_min.dev_attr.attr,
480 &sensor_dev_attr_in3_max.dev_attr.attr,
481 &sensor_dev_attr_in4_input.dev_attr.attr,
482 &sensor_dev_attr_in4_min.dev_attr.attr,
483 &sensor_dev_attr_in4_max.dev_attr.attr,
484 &sensor_dev_attr_in5_input.dev_attr.attr,
485 &sensor_dev_attr_in5_min.dev_attr.attr,
486 &sensor_dev_attr_in5_max.dev_attr.attr,
487 &dev_attr_temp1_input.attr,
488 &sensor_dev_attr_temp1_max.dev_attr.attr,
489 &sensor_dev_attr_temp1_max_hyst.dev_attr.attr,
490 &sensor_dev_attr_fan1_input.dev_attr.attr,
491 &sensor_dev_attr_fan1_div.dev_attr.attr,
492 &sensor_dev_attr_fan1_min.dev_attr.attr,
493 &sensor_dev_attr_fan2_input.dev_attr.attr,
494 &sensor_dev_attr_fan2_div.dev_attr.attr,
495 &sensor_dev_attr_fan2_min.dev_attr.attr,
496 &dev_attr_alarms.attr,
497 &dev_attr_aout_output.attr,
498 &dev_attr_chassis_clear.attr,
499 &dev_attr_cpu0_vid.attr,
500 NULL
501};
502
503static const struct attribute_group adm9240_group = {
504 .attrs = adm9240_attributes,
505};
506
468 507
469/*** sensor chip detect and driver install ***/ 508/*** sensor chip detect and driver install ***/
470 509
@@ -548,72 +587,19 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind)
548 adm9240_init_client(new_client); 587 adm9240_init_client(new_client);
549 588
550 /* populate sysfs filesystem */ 589 /* populate sysfs filesystem */
590 if ((err = sysfs_create_group(&new_client->dev.kobj, &adm9240_group)))
591 goto exit_detach;
592
551 data->class_dev = hwmon_device_register(&new_client->dev); 593 data->class_dev = hwmon_device_register(&new_client->dev);
552 if (IS_ERR(data->class_dev)) { 594 if (IS_ERR(data->class_dev)) {
553 err = PTR_ERR(data->class_dev); 595 err = PTR_ERR(data->class_dev);
554 goto exit_detach; 596 goto exit_remove;
555 } 597 }
556 598
557 device_create_file(&new_client->dev,
558 &sensor_dev_attr_in0_input.dev_attr);
559 device_create_file(&new_client->dev,
560 &sensor_dev_attr_in0_min.dev_attr);
561 device_create_file(&new_client->dev,
562 &sensor_dev_attr_in0_max.dev_attr);
563 device_create_file(&new_client->dev,
564 &sensor_dev_attr_in1_input.dev_attr);
565 device_create_file(&new_client->dev,
566 &sensor_dev_attr_in1_min.dev_attr);
567 device_create_file(&new_client->dev,
568 &sensor_dev_attr_in1_max.dev_attr);
569 device_create_file(&new_client->dev,
570 &sensor_dev_attr_in2_input.dev_attr);
571 device_create_file(&new_client->dev,
572 &sensor_dev_attr_in2_min.dev_attr);
573 device_create_file(&new_client->dev,
574 &sensor_dev_attr_in2_max.dev_attr);
575 device_create_file(&new_client->dev,
576 &sensor_dev_attr_in3_input.dev_attr);
577 device_create_file(&new_client->dev,
578 &sensor_dev_attr_in3_min.dev_attr);
579 device_create_file(&new_client->dev,
580 &sensor_dev_attr_in3_max.dev_attr);
581 device_create_file(&new_client->dev,
582 &sensor_dev_attr_in4_input.dev_attr);
583 device_create_file(&new_client->dev,
584 &sensor_dev_attr_in4_min.dev_attr);
585 device_create_file(&new_client->dev,
586 &sensor_dev_attr_in4_max.dev_attr);
587 device_create_file(&new_client->dev,
588 &sensor_dev_attr_in5_input.dev_attr);
589 device_create_file(&new_client->dev,
590 &sensor_dev_attr_in5_min.dev_attr);
591 device_create_file(&new_client->dev,
592 &sensor_dev_attr_in5_max.dev_attr);
593 device_create_file(&new_client->dev, &dev_attr_temp1_input);
594 device_create_file(&new_client->dev,
595 &sensor_dev_attr_temp1_max.dev_attr);
596 device_create_file(&new_client->dev,
597 &sensor_dev_attr_temp1_max_hyst.dev_attr);
598 device_create_file(&new_client->dev,
599 &sensor_dev_attr_fan1_input.dev_attr);
600 device_create_file(&new_client->dev,
601 &sensor_dev_attr_fan1_div.dev_attr);
602 device_create_file(&new_client->dev,
603 &sensor_dev_attr_fan1_min.dev_attr);
604 device_create_file(&new_client->dev,
605 &sensor_dev_attr_fan2_input.dev_attr);
606 device_create_file(&new_client->dev,
607 &sensor_dev_attr_fan2_div.dev_attr);
608 device_create_file(&new_client->dev,
609 &sensor_dev_attr_fan2_min.dev_attr);
610 device_create_file(&new_client->dev, &dev_attr_alarms);
611 device_create_file(&new_client->dev, &dev_attr_aout_output);
612 device_create_file(&new_client->dev, &dev_attr_chassis_clear);
613 device_create_file(&new_client->dev, &dev_attr_cpu0_vid);
614
615 return 0; 599 return 0;
616 600
601exit_remove:
602 sysfs_remove_group(&new_client->dev.kobj, &adm9240_group);
617exit_detach: 603exit_detach:
618 i2c_detach_client(new_client); 604 i2c_detach_client(new_client);
619exit_free: 605exit_free:
@@ -635,6 +621,7 @@ static int adm9240_detach_client(struct i2c_client *client)
635 int err; 621 int err;
636 622
637 hwmon_device_unregister(data->class_dev); 623 hwmon_device_unregister(data->class_dev);
624 sysfs_remove_group(&client->dev.kobj, &adm9240_group);
638 625
639 if ((err = i2c_detach_client(client))) 626 if ((err = i2c_detach_client(client)))
640 return err; 627 return err;