diff options
author | Hans de Goede <hdegoede@redhat.com> | 2009-01-07 10:37:33 -0500 |
---|---|---|
committer | Jean Delvare <khali@linux-fr.org> | 2009-01-07 10:37:33 -0500 |
commit | 453e308d773979f6bbdf4109df27101072f6524b (patch) | |
tree | 29faa75b7cb746fbece657e4488b0e63d40748bc /drivers | |
parent | 6e31eb2b297c7b6678e6e77393bb8d01b5228bda (diff) |
hwmon: (fschmd) Cleanups for watchdog support
Various small cleanups in preparation of adding watchdog support,
mostly removing _MASK postfix from defines which are not masks.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hwmon/fschmd.c | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/drivers/hwmon/fschmd.c b/drivers/hwmon/fschmd.c index 967170368933..c188b7135025 100644 --- a/drivers/hwmon/fschmd.c +++ b/drivers/hwmon/fschmd.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* fschmd.c | 1 | /* fschmd.c |
2 | * | 2 | * |
3 | * Copyright (C) 2007 Hans de Goede <j.w.r.degoede@hhs.nl> | 3 | * Copyright (C) 2007,2008 Hans de Goede <hdegoede@redhat.com> |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
@@ -63,7 +63,7 @@ I2C_CLIENT_INSMOD_5(fscpos, fscher, fscscy, fschrc, fschmd); | |||
63 | #define FSCHMD_REG_EVENT_STATE 0x04 | 63 | #define FSCHMD_REG_EVENT_STATE 0x04 |
64 | #define FSCHMD_REG_CONTROL 0x05 | 64 | #define FSCHMD_REG_CONTROL 0x05 |
65 | 65 | ||
66 | #define FSCHMD_CONTROL_ALERT_LED_MASK 0x01 | 66 | #define FSCHMD_CONTROL_ALERT_LED 0x01 |
67 | 67 | ||
68 | /* watchdog (support to be implemented) */ | 68 | /* watchdog (support to be implemented) */ |
69 | #define FSCHMD_REG_WDOG_PRESET 0x28 | 69 | #define FSCHMD_REG_WDOG_PRESET 0x28 |
@@ -115,8 +115,8 @@ static const u8 FSCHMD_REG_FAN_RIPPLE[5][6] = { | |||
115 | static const int FSCHMD_NO_FAN_SENSORS[5] = { 3, 3, 6, 4, 5 }; | 115 | static const int FSCHMD_NO_FAN_SENSORS[5] = { 3, 3, 6, 4, 5 }; |
116 | 116 | ||
117 | /* Fan status register bitmasks */ | 117 | /* Fan status register bitmasks */ |
118 | #define FSCHMD_FAN_ALARM_MASK 0x04 /* called fault by FSC! */ | 118 | #define FSCHMD_FAN_ALARM 0x04 /* called fault by FSC! */ |
119 | #define FSCHMD_FAN_NOT_PRESENT_MASK 0x08 /* not documented */ | 119 | #define FSCHMD_FAN_NOT_PRESENT 0x08 /* not documented */ |
120 | 120 | ||
121 | 121 | ||
122 | /* actual temperature registers */ | 122 | /* actual temperature registers */ |
@@ -158,14 +158,11 @@ static const u8 FSCHER_REG_TEMP_AUTOP2[] = { 0x75, 0x85, 0x95 }; */ | |||
158 | static const int FSCHMD_NO_TEMP_SENSORS[5] = { 3, 3, 4, 3, 5 }; | 158 | static const int FSCHMD_NO_TEMP_SENSORS[5] = { 3, 3, 4, 3, 5 }; |
159 | 159 | ||
160 | /* temp status register bitmasks */ | 160 | /* temp status register bitmasks */ |
161 | #define FSCHMD_TEMP_WORKING_MASK 0x01 | 161 | #define FSCHMD_TEMP_WORKING 0x01 |
162 | #define FSCHMD_TEMP_ALERT_MASK 0x02 | 162 | #define FSCHMD_TEMP_ALERT 0x02 |
163 | /* there only really is an alarm if the sensor is working and alert == 1 */ | 163 | /* there only really is an alarm if the sensor is working and alert == 1 */ |
164 | #define FSCHMD_TEMP_ALARM_MASK \ | 164 | #define FSCHMD_TEMP_ALARM_MASK \ |
165 | (FSCHMD_TEMP_WORKING_MASK | FSCHMD_TEMP_ALERT_MASK) | 165 | (FSCHMD_TEMP_WORKING | FSCHMD_TEMP_ALERT) |
166 | |||
167 | /* our driver name */ | ||
168 | #define FSCHMD_NAME "fschmd" | ||
169 | 166 | ||
170 | /* | 167 | /* |
171 | * Functions declarations | 168 | * Functions declarations |
@@ -195,7 +192,7 @@ MODULE_DEVICE_TABLE(i2c, fschmd_id); | |||
195 | static struct i2c_driver fschmd_driver = { | 192 | static struct i2c_driver fschmd_driver = { |
196 | .class = I2C_CLASS_HWMON, | 193 | .class = I2C_CLASS_HWMON, |
197 | .driver = { | 194 | .driver = { |
198 | .name = FSCHMD_NAME, | 195 | .name = "fschmd", |
199 | }, | 196 | }, |
200 | .probe = fschmd_probe, | 197 | .probe = fschmd_probe, |
201 | .remove = fschmd_remove, | 198 | .remove = fschmd_remove, |
@@ -300,7 +297,7 @@ static ssize_t show_temp_fault(struct device *dev, | |||
300 | struct fschmd_data *data = fschmd_update_device(dev); | 297 | struct fschmd_data *data = fschmd_update_device(dev); |
301 | 298 | ||
302 | /* bit 0 set means sensor working ok, so no fault! */ | 299 | /* bit 0 set means sensor working ok, so no fault! */ |
303 | if (data->temp_status[index] & FSCHMD_TEMP_WORKING_MASK) | 300 | if (data->temp_status[index] & FSCHMD_TEMP_WORKING) |
304 | return sprintf(buf, "0\n"); | 301 | return sprintf(buf, "0\n"); |
305 | else | 302 | else |
306 | return sprintf(buf, "1\n"); | 303 | return sprintf(buf, "1\n"); |
@@ -385,7 +382,7 @@ static ssize_t show_fan_alarm(struct device *dev, | |||
385 | int index = to_sensor_dev_attr(devattr)->index; | 382 | int index = to_sensor_dev_attr(devattr)->index; |
386 | struct fschmd_data *data = fschmd_update_device(dev); | 383 | struct fschmd_data *data = fschmd_update_device(dev); |
387 | 384 | ||
388 | if (data->fan_status[index] & FSCHMD_FAN_ALARM_MASK) | 385 | if (data->fan_status[index] & FSCHMD_FAN_ALARM) |
389 | return sprintf(buf, "1\n"); | 386 | return sprintf(buf, "1\n"); |
390 | else | 387 | else |
391 | return sprintf(buf, "0\n"); | 388 | return sprintf(buf, "0\n"); |
@@ -397,7 +394,7 @@ static ssize_t show_fan_fault(struct device *dev, | |||
397 | int index = to_sensor_dev_attr(devattr)->index; | 394 | int index = to_sensor_dev_attr(devattr)->index; |
398 | struct fschmd_data *data = fschmd_update_device(dev); | 395 | struct fschmd_data *data = fschmd_update_device(dev); |
399 | 396 | ||
400 | if (data->fan_status[index] & FSCHMD_FAN_NOT_PRESENT_MASK) | 397 | if (data->fan_status[index] & FSCHMD_FAN_NOT_PRESENT) |
401 | return sprintf(buf, "1\n"); | 398 | return sprintf(buf, "1\n"); |
402 | else | 399 | else |
403 | return sprintf(buf, "0\n"); | 400 | return sprintf(buf, "0\n"); |
@@ -449,7 +446,7 @@ static ssize_t show_alert_led(struct device *dev, | |||
449 | { | 446 | { |
450 | struct fschmd_data *data = fschmd_update_device(dev); | 447 | struct fschmd_data *data = fschmd_update_device(dev); |
451 | 448 | ||
452 | if (data->global_control & FSCHMD_CONTROL_ALERT_LED_MASK) | 449 | if (data->global_control & FSCHMD_CONTROL_ALERT_LED) |
453 | return sprintf(buf, "1\n"); | 450 | return sprintf(buf, "1\n"); |
454 | else | 451 | else |
455 | return sprintf(buf, "0\n"); | 452 | return sprintf(buf, "0\n"); |
@@ -467,9 +464,9 @@ static ssize_t store_alert_led(struct device *dev, | |||
467 | reg = i2c_smbus_read_byte_data(to_i2c_client(dev), FSCHMD_REG_CONTROL); | 464 | reg = i2c_smbus_read_byte_data(to_i2c_client(dev), FSCHMD_REG_CONTROL); |
468 | 465 | ||
469 | if (v) | 466 | if (v) |
470 | reg |= FSCHMD_CONTROL_ALERT_LED_MASK; | 467 | reg |= FSCHMD_CONTROL_ALERT_LED; |
471 | else | 468 | else |
472 | reg &= ~FSCHMD_CONTROL_ALERT_LED_MASK; | 469 | reg &= ~FSCHMD_CONTROL_ALERT_LED; |
473 | 470 | ||
474 | i2c_smbus_write_byte_data(to_i2c_client(dev), FSCHMD_REG_CONTROL, reg); | 471 | i2c_smbus_write_byte_data(to_i2c_client(dev), FSCHMD_REG_CONTROL, reg); |
475 | 472 | ||
@@ -683,11 +680,11 @@ static int fschmd_probe(struct i2c_client *client, | |||
683 | } | 680 | } |
684 | 681 | ||
685 | /* Read the special DMI table for fscher and newer chips */ | 682 | /* Read the special DMI table for fscher and newer chips */ |
686 | if (kind == fscher || kind >= fschrc) { | 683 | if ((kind == fscher || kind >= fschrc) && dmi_vref == -1) { |
687 | dmi_walk(fschmd_dmi_decode); | 684 | dmi_walk(fschmd_dmi_decode); |
688 | if (dmi_vref == -1) { | 685 | if (dmi_vref == -1) { |
689 | printk(KERN_WARNING FSCHMD_NAME | 686 | dev_warn(&client->dev, |
690 | ": Couldn't get voltage scaling factors from " | 687 | "Couldn't get voltage scaling factors from " |
691 | "BIOS DMI table, using builtin defaults\n"); | 688 | "BIOS DMI table, using builtin defaults\n"); |
692 | dmi_vref = 33; | 689 | dmi_vref = 33; |
693 | } | 690 | } |
@@ -736,7 +733,7 @@ static int fschmd_probe(struct i2c_client *client, | |||
736 | } | 733 | } |
737 | 734 | ||
738 | revision = i2c_smbus_read_byte_data(client, FSCHMD_REG_REVISION); | 735 | revision = i2c_smbus_read_byte_data(client, FSCHMD_REG_REVISION); |
739 | printk(KERN_INFO FSCHMD_NAME ": Detected FSC %s chip, revision: %d\n", | 736 | dev_info(&client->dev, "Detected FSC %s chip, revision: %d\n", |
740 | names[data->kind], (int) revision); | 737 | names[data->kind], (int) revision); |
741 | 738 | ||
742 | return 0; | 739 | return 0; |
@@ -798,7 +795,7 @@ static struct fschmd_data *fschmd_update_device(struct device *dev) | |||
798 | data->temp_act[i] < data->temp_max[i]) | 795 | data->temp_act[i] < data->temp_max[i]) |
799 | i2c_smbus_write_byte_data(client, | 796 | i2c_smbus_write_byte_data(client, |
800 | FSCHMD_REG_TEMP_STATE[data->kind][i], | 797 | FSCHMD_REG_TEMP_STATE[data->kind][i], |
801 | FSCHMD_TEMP_ALERT_MASK); | 798 | FSCHMD_TEMP_ALERT); |
802 | } | 799 | } |
803 | 800 | ||
804 | for (i = 0; i < FSCHMD_NO_FAN_SENSORS[data->kind]; i++) { | 801 | for (i = 0; i < FSCHMD_NO_FAN_SENSORS[data->kind]; i++) { |
@@ -816,11 +813,11 @@ static struct fschmd_data *fschmd_update_device(struct device *dev) | |||
816 | FSCHMD_REG_FAN_MIN[data->kind][i]); | 813 | FSCHMD_REG_FAN_MIN[data->kind][i]); |
817 | 814 | ||
818 | /* reset fan status if speed is back to > 0 */ | 815 | /* reset fan status if speed is back to > 0 */ |
819 | if ((data->fan_status[i] & FSCHMD_FAN_ALARM_MASK) && | 816 | if ((data->fan_status[i] & FSCHMD_FAN_ALARM) && |
820 | data->fan_act[i]) | 817 | data->fan_act[i]) |
821 | i2c_smbus_write_byte_data(client, | 818 | i2c_smbus_write_byte_data(client, |
822 | FSCHMD_REG_FAN_STATE[data->kind][i], | 819 | FSCHMD_REG_FAN_STATE[data->kind][i], |
823 | FSCHMD_FAN_ALARM_MASK); | 820 | FSCHMD_FAN_ALARM); |
824 | } | 821 | } |
825 | 822 | ||
826 | for (i = 0; i < 3; i++) | 823 | for (i = 0; i < 3; i++) |
@@ -857,7 +854,7 @@ static void __exit fschmd_exit(void) | |||
857 | i2c_del_driver(&fschmd_driver); | 854 | i2c_del_driver(&fschmd_driver); |
858 | } | 855 | } |
859 | 856 | ||
860 | MODULE_AUTHOR("Hans de Goede <j.w.r.degoede@hhs.nl>"); | 857 | MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>"); |
861 | MODULE_DESCRIPTION("FSC Poseidon, Hermes, Scylla, Heracles and " | 858 | MODULE_DESCRIPTION("FSC Poseidon, Hermes, Scylla, Heracles and " |
862 | "Heimdall driver"); | 859 | "Heimdall driver"); |
863 | MODULE_LICENSE("GPL"); | 860 | MODULE_LICENSE("GPL"); |