diff options
Diffstat (limited to 'drivers/hwmon/lm63.c')
-rw-r--r-- | drivers/hwmon/lm63.c | 89 |
1 files changed, 52 insertions, 37 deletions
diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c index 00a50bea7cbd..d69f3cf07122 100644 --- a/drivers/hwmon/lm63.c +++ b/drivers/hwmon/lm63.c | |||
@@ -46,6 +46,7 @@ | |||
46 | #include <linux/hwmon.h> | 46 | #include <linux/hwmon.h> |
47 | #include <linux/err.h> | 47 | #include <linux/err.h> |
48 | #include <linux/mutex.h> | 48 | #include <linux/mutex.h> |
49 | #include <linux/sysfs.h> | ||
49 | 50 | ||
50 | /* | 51 | /* |
51 | * Addresses to scan | 52 | * Addresses to scan |
@@ -370,6 +371,42 @@ static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6); | |||
370 | /* Raw alarm file for compatibility */ | 371 | /* Raw alarm file for compatibility */ |
371 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 372 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
372 | 373 | ||
374 | static struct attribute *lm63_attributes[] = { | ||
375 | &dev_attr_pwm1.attr, | ||
376 | &dev_attr_pwm1_enable.attr, | ||
377 | &sensor_dev_attr_temp1_input.dev_attr.attr, | ||
378 | &sensor_dev_attr_temp2_input.dev_attr.attr, | ||
379 | &sensor_dev_attr_temp2_min.dev_attr.attr, | ||
380 | &sensor_dev_attr_temp1_max.dev_attr.attr, | ||
381 | &sensor_dev_attr_temp2_max.dev_attr.attr, | ||
382 | &sensor_dev_attr_temp2_crit.dev_attr.attr, | ||
383 | &dev_attr_temp2_crit_hyst.attr, | ||
384 | |||
385 | &sensor_dev_attr_temp2_crit_alarm.dev_attr.attr, | ||
386 | &sensor_dev_attr_temp2_input_fault.dev_attr.attr, | ||
387 | &sensor_dev_attr_temp2_min_alarm.dev_attr.attr, | ||
388 | &sensor_dev_attr_temp2_max_alarm.dev_attr.attr, | ||
389 | &sensor_dev_attr_temp1_max_alarm.dev_attr.attr, | ||
390 | &dev_attr_alarms.attr, | ||
391 | NULL | ||
392 | }; | ||
393 | |||
394 | static const struct attribute_group lm63_group = { | ||
395 | .attrs = lm63_attributes, | ||
396 | }; | ||
397 | |||
398 | static struct attribute *lm63_attributes_fan1[] = { | ||
399 | &sensor_dev_attr_fan1_input.dev_attr.attr, | ||
400 | &sensor_dev_attr_fan1_min.dev_attr.attr, | ||
401 | |||
402 | &sensor_dev_attr_fan1_min_alarm.dev_attr.attr, | ||
403 | NULL | ||
404 | }; | ||
405 | |||
406 | static const struct attribute_group lm63_group_fan1 = { | ||
407 | .attrs = lm63_attributes_fan1, | ||
408 | }; | ||
409 | |||
373 | /* | 410 | /* |
374 | * Real code | 411 | * Real code |
375 | */ | 412 | */ |
@@ -456,50 +493,26 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind) | |||
456 | lm63_init_client(new_client); | 493 | lm63_init_client(new_client); |
457 | 494 | ||
458 | /* Register sysfs hooks */ | 495 | /* Register sysfs hooks */ |
459 | data->class_dev = hwmon_device_register(&new_client->dev); | 496 | if ((err = sysfs_create_group(&new_client->dev.kobj, |
460 | if (IS_ERR(data->class_dev)) { | 497 | &lm63_group))) |
461 | err = PTR_ERR(data->class_dev); | ||
462 | goto exit_detach; | 498 | goto exit_detach; |
499 | if (data->config & 0x04) { /* tachometer enabled */ | ||
500 | if ((err = sysfs_create_group(&new_client->dev.kobj, | ||
501 | &lm63_group_fan1))) | ||
502 | goto exit_remove_files; | ||
463 | } | 503 | } |
464 | 504 | ||
465 | if (data->config & 0x04) { /* tachometer enabled */ | 505 | data->class_dev = hwmon_device_register(&new_client->dev); |
466 | device_create_file(&new_client->dev, | 506 | if (IS_ERR(data->class_dev)) { |
467 | &sensor_dev_attr_fan1_input.dev_attr); | 507 | err = PTR_ERR(data->class_dev); |
468 | device_create_file(&new_client->dev, | 508 | goto exit_remove_files; |
469 | &sensor_dev_attr_fan1_min.dev_attr); | ||
470 | device_create_file(&new_client->dev, | ||
471 | &sensor_dev_attr_fan1_min_alarm.dev_attr); | ||
472 | } | 509 | } |
473 | device_create_file(&new_client->dev, &dev_attr_pwm1); | ||
474 | device_create_file(&new_client->dev, &dev_attr_pwm1_enable); | ||
475 | device_create_file(&new_client->dev, | ||
476 | &sensor_dev_attr_temp1_input.dev_attr); | ||
477 | device_create_file(&new_client->dev, | ||
478 | &sensor_dev_attr_temp2_input.dev_attr); | ||
479 | device_create_file(&new_client->dev, | ||
480 | &sensor_dev_attr_temp2_min.dev_attr); | ||
481 | device_create_file(&new_client->dev, | ||
482 | &sensor_dev_attr_temp1_max.dev_attr); | ||
483 | device_create_file(&new_client->dev, | ||
484 | &sensor_dev_attr_temp2_max.dev_attr); | ||
485 | device_create_file(&new_client->dev, | ||
486 | &sensor_dev_attr_temp2_crit.dev_attr); | ||
487 | device_create_file(&new_client->dev, &dev_attr_temp2_crit_hyst); | ||
488 | |||
489 | device_create_file(&new_client->dev, | ||
490 | &sensor_dev_attr_temp2_input_fault.dev_attr); | ||
491 | device_create_file(&new_client->dev, | ||
492 | &sensor_dev_attr_temp2_min_alarm.dev_attr); | ||
493 | device_create_file(&new_client->dev, | ||
494 | &sensor_dev_attr_temp1_max_alarm.dev_attr); | ||
495 | device_create_file(&new_client->dev, | ||
496 | &sensor_dev_attr_temp2_max_alarm.dev_attr); | ||
497 | device_create_file(&new_client->dev, | ||
498 | &sensor_dev_attr_temp2_crit_alarm.dev_attr); | ||
499 | device_create_file(&new_client->dev, &dev_attr_alarms); | ||
500 | 510 | ||
501 | return 0; | 511 | return 0; |
502 | 512 | ||
513 | exit_remove_files: | ||
514 | sysfs_remove_group(&new_client->dev.kobj, &lm63_group); | ||
515 | sysfs_remove_group(&new_client->dev.kobj, &lm63_group_fan1); | ||
503 | exit_detach: | 516 | exit_detach: |
504 | i2c_detach_client(new_client); | 517 | i2c_detach_client(new_client); |
505 | exit_free: | 518 | exit_free: |
@@ -549,6 +562,8 @@ static int lm63_detach_client(struct i2c_client *client) | |||
549 | int err; | 562 | int err; |
550 | 563 | ||
551 | hwmon_device_unregister(data->class_dev); | 564 | hwmon_device_unregister(data->class_dev); |
565 | sysfs_remove_group(&client->dev.kobj, &lm63_group); | ||
566 | sysfs_remove_group(&client->dev.kobj, &lm63_group_fan1); | ||
552 | 567 | ||
553 | if ((err = i2c_detach_client(client))) | 568 | if ((err = i2c_detach_client(client))) |
554 | return err; | 569 | return err; |