Commit 9c084dae5dc7ae0039e330230e70f2a5956e566a
Committed by
Jean Delvare
1 parent
67b670ff04
Exists in
master
and in
4 other branches
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>
Showing 2 changed files with 36 additions and 10 deletions Side-by-side Diff
Documentation/hwmon/max6650
... | ... | @@ -2,10 +2,14 @@ |
2 | 2 | ===================== |
3 | 3 | |
4 | 4 | Supported chips: |
5 | - * Maxim 6650 / 6651 | |
5 | + * Maxim MAX6650 | |
6 | 6 | Prefix: 'max6650' |
7 | 7 | Addresses scanned: none |
8 | 8 | Datasheet: http://pdfserv.maxim-ic.com/en/ds/MAX6650-MAX6651.pdf |
9 | + * Maxim MAX6651 | |
10 | + Prefix: 'max6651' | |
11 | + Addresses scanned: none | |
12 | + Datasheet: http://pdfserv.maxim-ic.com/en/ds/MAX6650-MAX6651.pdf | |
9 | 13 | |
10 | 14 | Authors: |
11 | 15 | Hans J. Koch <hjk@hansjkoch.de> |
12 | 16 | |
... | ... | @@ -15,10 +19,10 @@ |
15 | 19 | Description |
16 | 20 | ----------- |
17 | 21 | |
18 | -This driver implements support for the Maxim 6650/6651 | |
22 | +This driver implements support for the Maxim MAX6650 and MAX6651. | |
19 | 23 | |
20 | -The 2 devices are very similar, but the Maxim 6550 has a reduced feature | |
21 | -set, e.g. only one fan-input, instead of 4 for the 6651. | |
24 | +The 2 devices are very similar, but the MAX6550 has a reduced feature | |
25 | +set, e.g. only one fan-input, instead of 4 for the MAX6651. | |
22 | 26 | |
23 | 27 | The driver is not able to distinguish between the 2 devices. |
24 | 28 |
drivers/hwmon/max6650.c
... | ... | @@ -116,7 +116,8 @@ |
116 | 116 | */ |
117 | 117 | |
118 | 118 | static const struct i2c_device_id max6650_id[] = { |
119 | - { "max6650", 0 }, | |
119 | + { "max6650", 1 }, | |
120 | + { "max6651", 4 }, | |
120 | 121 | { } |
121 | 122 | }; |
122 | 123 | MODULE_DEVICE_TABLE(i2c, max6650_id); |
... | ... | @@ -138,6 +139,7 @@ |
138 | 139 | { |
139 | 140 | struct device *hwmon_dev; |
140 | 141 | struct mutex update_lock; |
142 | + int nr_fans; | |
141 | 143 | char valid; /* zero until following fields are valid */ |
142 | 144 | unsigned long last_updated; /* in jiffies */ |
143 | 145 | |
... | ... | @@ -489,9 +491,6 @@ |
489 | 491 | |
490 | 492 | static struct attribute *max6650_attrs[] = { |
491 | 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 | 494 | &dev_attr_fan1_target.attr, |
496 | 495 | &dev_attr_fan1_div.attr, |
497 | 496 | &dev_attr_pwm1_enable.attr, |
... | ... | @@ -509,6 +508,17 @@ |
509 | 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 | 523 | * Real code |
514 | 524 | */ |
... | ... | @@ -526,6 +536,7 @@ |
526 | 536 | |
527 | 537 | i2c_set_clientdata(client, data); |
528 | 538 | mutex_init(&data->update_lock); |
539 | + data->nr_fans = id->driver_data; | |
529 | 540 | |
530 | 541 | /* |
531 | 542 | * Initialize the max6650 chip |
... | ... | @@ -537,6 +548,12 @@ |
537 | 548 | err = sysfs_create_group(&client->dev.kobj, &max6650_attr_grp); |
538 | 549 | if (err) |
539 | 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 | 558 | data->hwmon_dev = hwmon_device_register(&client->dev); |
542 | 559 | if (!IS_ERR(data->hwmon_dev)) |
... | ... | @@ -544,6 +561,9 @@ |
544 | 561 | |
545 | 562 | err = PTR_ERR(data->hwmon_dev); |
546 | 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 | 567 | sysfs_remove_group(&client->dev.kobj, &max6650_attr_grp); |
548 | 568 | err_free: |
549 | 569 | kfree(data); |
550 | 570 | |
... | ... | @@ -554,8 +574,10 @@ |
554 | 574 | { |
555 | 575 | struct max6650_data *data = i2c_get_clientdata(client); |
556 | 576 | |
557 | - sysfs_remove_group(&client->dev.kobj, &max6650_attr_grp); | |
558 | 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 | 581 | kfree(data); |
560 | 582 | return 0; |
561 | 583 | } |
... | ... | @@ -668,7 +690,7 @@ |
668 | 690 | MAX6650_REG_SPEED); |
669 | 691 | data->config = i2c_smbus_read_byte_data(client, |
670 | 692 | MAX6650_REG_CONFIG); |
671 | - for (i = 0; i < 4; i++) { | |
693 | + for (i = 0; i < data->nr_fans; i++) { | |
672 | 694 | data->tach[i] = i2c_smbus_read_byte_data(client, |
673 | 695 | tach_reg[i]); |
674 | 696 | } |