diff options
author | Jean Delvare <khali@linux-fr.org> | 2011-05-25 14:43:32 -0400 |
---|---|---|
committer | Jean Delvare <khali@endymion.delvare> | 2011-05-25 14:43:32 -0400 |
commit | 9c084dae5dc7ae0039e330230e70f2a5956e566a (patch) | |
tree | 1d0bb268081342ca1dee7a6c819cd459f409939d /drivers/hwmon | |
parent | 67b670ff04cdff1c9584ecdb22e297956664c9b5 (diff) |
hwmon: (max6650) Properly support the MAX6650
The MAX6650 has only one fan input.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: "Hans J. Koch" <hjk@hansjkoch.de>
Acked-by: Guenter Roeck <guenter.roeck@ericsson.com>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/max6650.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/drivers/hwmon/max6650.c b/drivers/hwmon/max6650.c index cced18626174..ece3aafa54b3 100644 --- a/drivers/hwmon/max6650.c +++ b/drivers/hwmon/max6650.c | |||
@@ -116,7 +116,8 @@ static struct max6650_data *max6650_update_device(struct device *dev); | |||
116 | */ | 116 | */ |
117 | 117 | ||
118 | static const struct i2c_device_id max6650_id[] = { | 118 | static const struct i2c_device_id max6650_id[] = { |
119 | { "max6650", 0 }, | 119 | { "max6650", 1 }, |
120 | { "max6651", 4 }, | ||
120 | { } | 121 | { } |
121 | }; | 122 | }; |
122 | MODULE_DEVICE_TABLE(i2c, max6650_id); | 123 | MODULE_DEVICE_TABLE(i2c, max6650_id); |
@@ -138,6 +139,7 @@ struct max6650_data | |||
138 | { | 139 | { |
139 | struct device *hwmon_dev; | 140 | struct device *hwmon_dev; |
140 | struct mutex update_lock; | 141 | struct mutex update_lock; |
142 | int nr_fans; | ||
141 | char valid; /* zero until following fields are valid */ | 143 | char valid; /* zero until following fields are valid */ |
142 | unsigned long last_updated; /* in jiffies */ | 144 | unsigned long last_updated; /* in jiffies */ |
143 | 145 | ||
@@ -489,9 +491,6 @@ static mode_t max6650_attrs_visible(struct kobject *kobj, struct attribute *a, | |||
489 | 491 | ||
490 | static struct attribute *max6650_attrs[] = { | 492 | static struct attribute *max6650_attrs[] = { |
491 | &sensor_dev_attr_fan1_input.dev_attr.attr, | 493 | &sensor_dev_attr_fan1_input.dev_attr.attr, |
492 | &sensor_dev_attr_fan2_input.dev_attr.attr, | ||
493 | &sensor_dev_attr_fan3_input.dev_attr.attr, | ||
494 | &sensor_dev_attr_fan4_input.dev_attr.attr, | ||
495 | &dev_attr_fan1_target.attr, | 494 | &dev_attr_fan1_target.attr, |
496 | &dev_attr_fan1_div.attr, | 495 | &dev_attr_fan1_div.attr, |
497 | &dev_attr_pwm1_enable.attr, | 496 | &dev_attr_pwm1_enable.attr, |
@@ -509,6 +508,17 @@ static struct attribute_group max6650_attr_grp = { | |||
509 | .is_visible = max6650_attrs_visible, | 508 | .is_visible = max6650_attrs_visible, |
510 | }; | 509 | }; |
511 | 510 | ||
511 | static struct attribute *max6651_attrs[] = { | ||
512 | &sensor_dev_attr_fan2_input.dev_attr.attr, | ||
513 | &sensor_dev_attr_fan3_input.dev_attr.attr, | ||
514 | &sensor_dev_attr_fan4_input.dev_attr.attr, | ||
515 | NULL | ||
516 | }; | ||
517 | |||
518 | static const struct attribute_group max6651_attr_grp = { | ||
519 | .attrs = max6651_attrs, | ||
520 | }; | ||
521 | |||
512 | /* | 522 | /* |
513 | * Real code | 523 | * Real code |
514 | */ | 524 | */ |
@@ -526,6 +536,7 @@ static int max6650_probe(struct i2c_client *client, | |||
526 | 536 | ||
527 | i2c_set_clientdata(client, data); | 537 | i2c_set_clientdata(client, data); |
528 | mutex_init(&data->update_lock); | 538 | mutex_init(&data->update_lock); |
539 | data->nr_fans = id->driver_data; | ||
529 | 540 | ||
530 | /* | 541 | /* |
531 | * Initialize the max6650 chip | 542 | * Initialize the max6650 chip |
@@ -537,6 +548,12 @@ static int max6650_probe(struct i2c_client *client, | |||
537 | err = sysfs_create_group(&client->dev.kobj, &max6650_attr_grp); | 548 | err = sysfs_create_group(&client->dev.kobj, &max6650_attr_grp); |
538 | if (err) | 549 | if (err) |
539 | goto err_free; | 550 | goto err_free; |
551 | /* 3 additional fan inputs for the MAX6651 */ | ||
552 | if (data->nr_fans == 4) { | ||
553 | err = sysfs_create_group(&client->dev.kobj, &max6651_attr_grp); | ||
554 | if (err) | ||
555 | goto err_remove; | ||
556 | } | ||
540 | 557 | ||
541 | data->hwmon_dev = hwmon_device_register(&client->dev); | 558 | data->hwmon_dev = hwmon_device_register(&client->dev); |
542 | if (!IS_ERR(data->hwmon_dev)) | 559 | if (!IS_ERR(data->hwmon_dev)) |
@@ -544,6 +561,9 @@ static int max6650_probe(struct i2c_client *client, | |||
544 | 561 | ||
545 | err = PTR_ERR(data->hwmon_dev); | 562 | err = PTR_ERR(data->hwmon_dev); |
546 | dev_err(&client->dev, "error registering hwmon device.\n"); | 563 | dev_err(&client->dev, "error registering hwmon device.\n"); |
564 | if (data->nr_fans == 4) | ||
565 | sysfs_remove_group(&client->dev.kobj, &max6651_attr_grp); | ||
566 | err_remove: | ||
547 | sysfs_remove_group(&client->dev.kobj, &max6650_attr_grp); | 567 | sysfs_remove_group(&client->dev.kobj, &max6650_attr_grp); |
548 | err_free: | 568 | err_free: |
549 | kfree(data); | 569 | kfree(data); |
@@ -554,8 +574,10 @@ static int max6650_remove(struct i2c_client *client) | |||
554 | { | 574 | { |
555 | struct max6650_data *data = i2c_get_clientdata(client); | 575 | struct max6650_data *data = i2c_get_clientdata(client); |
556 | 576 | ||
557 | sysfs_remove_group(&client->dev.kobj, &max6650_attr_grp); | ||
558 | hwmon_device_unregister(data->hwmon_dev); | 577 | hwmon_device_unregister(data->hwmon_dev); |
578 | if (data->nr_fans == 4) | ||
579 | sysfs_remove_group(&client->dev.kobj, &max6651_attr_grp); | ||
580 | sysfs_remove_group(&client->dev.kobj, &max6650_attr_grp); | ||
559 | kfree(data); | 581 | kfree(data); |
560 | return 0; | 582 | return 0; |
561 | } | 583 | } |
@@ -668,7 +690,7 @@ static struct max6650_data *max6650_update_device(struct device *dev) | |||
668 | MAX6650_REG_SPEED); | 690 | MAX6650_REG_SPEED); |
669 | data->config = i2c_smbus_read_byte_data(client, | 691 | data->config = i2c_smbus_read_byte_data(client, |
670 | MAX6650_REG_CONFIG); | 692 | MAX6650_REG_CONFIG); |
671 | for (i = 0; i < 4; i++) { | 693 | for (i = 0; i < data->nr_fans; i++) { |
672 | data->tach[i] = i2c_smbus_read_byte_data(client, | 694 | data->tach[i] = i2c_smbus_read_byte_data(client, |
673 | tach_reg[i]); | 695 | tach_reg[i]); |
674 | } | 696 | } |