Commit 453e308d authored by Hans de Goede's avatar Hans de Goede Committed by Jean Delvare

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: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
parent 6e31eb2b
/* fschmd.c /* fschmd.c
* *
* Copyright (C) 2007 Hans de Goede <j.w.r.degoede@hhs.nl> * Copyright (C) 2007,2008 Hans de Goede <hdegoede@redhat.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * 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,7 +63,7 @@ I2C_CLIENT_INSMOD_5(fscpos, fscher, fscscy, fschrc, fschmd);
#define FSCHMD_REG_EVENT_STATE 0x04 #define FSCHMD_REG_EVENT_STATE 0x04
#define FSCHMD_REG_CONTROL 0x05 #define FSCHMD_REG_CONTROL 0x05
#define FSCHMD_CONTROL_ALERT_LED_MASK 0x01 #define FSCHMD_CONTROL_ALERT_LED 0x01
/* watchdog (support to be implemented) */ /* watchdog (support to be implemented) */
#define FSCHMD_REG_WDOG_PRESET 0x28 #define FSCHMD_REG_WDOG_PRESET 0x28
...@@ -115,8 +115,8 @@ static const u8 FSCHMD_REG_FAN_RIPPLE[5][6] = { ...@@ -115,8 +115,8 @@ static const u8 FSCHMD_REG_FAN_RIPPLE[5][6] = {
static const int FSCHMD_NO_FAN_SENSORS[5] = { 3, 3, 6, 4, 5 }; static const int FSCHMD_NO_FAN_SENSORS[5] = { 3, 3, 6, 4, 5 };
/* Fan status register bitmasks */ /* Fan status register bitmasks */
#define FSCHMD_FAN_ALARM_MASK 0x04 /* called fault by FSC! */ #define FSCHMD_FAN_ALARM 0x04 /* called fault by FSC! */
#define FSCHMD_FAN_NOT_PRESENT_MASK 0x08 /* not documented */ #define FSCHMD_FAN_NOT_PRESENT 0x08 /* not documented */
/* actual temperature registers */ /* actual temperature registers */
...@@ -158,14 +158,11 @@ static const u8 FSCHER_REG_TEMP_AUTOP2[] = { 0x75, 0x85, 0x95 }; */ ...@@ -158,14 +158,11 @@ static const u8 FSCHER_REG_TEMP_AUTOP2[] = { 0x75, 0x85, 0x95 }; */
static const int FSCHMD_NO_TEMP_SENSORS[5] = { 3, 3, 4, 3, 5 }; static const int FSCHMD_NO_TEMP_SENSORS[5] = { 3, 3, 4, 3, 5 };
/* temp status register bitmasks */ /* temp status register bitmasks */
#define FSCHMD_TEMP_WORKING_MASK 0x01 #define FSCHMD_TEMP_WORKING 0x01
#define FSCHMD_TEMP_ALERT_MASK 0x02 #define FSCHMD_TEMP_ALERT 0x02
/* there only really is an alarm if the sensor is working and alert == 1 */ /* there only really is an alarm if the sensor is working and alert == 1 */
#define FSCHMD_TEMP_ALARM_MASK \ #define FSCHMD_TEMP_ALARM_MASK \
(FSCHMD_TEMP_WORKING_MASK | FSCHMD_TEMP_ALERT_MASK) (FSCHMD_TEMP_WORKING | FSCHMD_TEMP_ALERT)
/* our driver name */
#define FSCHMD_NAME "fschmd"
/* /*
* Functions declarations * Functions declarations
...@@ -195,7 +192,7 @@ MODULE_DEVICE_TABLE(i2c, fschmd_id); ...@@ -195,7 +192,7 @@ MODULE_DEVICE_TABLE(i2c, fschmd_id);
static struct i2c_driver fschmd_driver = { static struct i2c_driver fschmd_driver = {
.class = I2C_CLASS_HWMON, .class = I2C_CLASS_HWMON,
.driver = { .driver = {
.name = FSCHMD_NAME, .name = "fschmd",
}, },
.probe = fschmd_probe, .probe = fschmd_probe,
.remove = fschmd_remove, .remove = fschmd_remove,
...@@ -300,7 +297,7 @@ static ssize_t show_temp_fault(struct device *dev, ...@@ -300,7 +297,7 @@ static ssize_t show_temp_fault(struct device *dev,
struct fschmd_data *data = fschmd_update_device(dev); struct fschmd_data *data = fschmd_update_device(dev);
/* bit 0 set means sensor working ok, so no fault! */ /* bit 0 set means sensor working ok, so no fault! */
if (data->temp_status[index] & FSCHMD_TEMP_WORKING_MASK) if (data->temp_status[index] & FSCHMD_TEMP_WORKING)
return sprintf(buf, "0\n"); return sprintf(buf, "0\n");
else else
return sprintf(buf, "1\n"); return sprintf(buf, "1\n");
...@@ -385,7 +382,7 @@ static ssize_t show_fan_alarm(struct device *dev, ...@@ -385,7 +382,7 @@ static ssize_t show_fan_alarm(struct device *dev,
int index = to_sensor_dev_attr(devattr)->index; int index = to_sensor_dev_attr(devattr)->index;
struct fschmd_data *data = fschmd_update_device(dev); struct fschmd_data *data = fschmd_update_device(dev);
if (data->fan_status[index] & FSCHMD_FAN_ALARM_MASK) if (data->fan_status[index] & FSCHMD_FAN_ALARM)
return sprintf(buf, "1\n"); return sprintf(buf, "1\n");
else else
return sprintf(buf, "0\n"); return sprintf(buf, "0\n");
...@@ -397,7 +394,7 @@ static ssize_t show_fan_fault(struct device *dev, ...@@ -397,7 +394,7 @@ static ssize_t show_fan_fault(struct device *dev,
int index = to_sensor_dev_attr(devattr)->index; int index = to_sensor_dev_attr(devattr)->index;
struct fschmd_data *data = fschmd_update_device(dev); struct fschmd_data *data = fschmd_update_device(dev);
if (data->fan_status[index] & FSCHMD_FAN_NOT_PRESENT_MASK) if (data->fan_status[index] & FSCHMD_FAN_NOT_PRESENT)
return sprintf(buf, "1\n"); return sprintf(buf, "1\n");
else else
return sprintf(buf, "0\n"); return sprintf(buf, "0\n");
...@@ -449,7 +446,7 @@ static ssize_t show_alert_led(struct device *dev, ...@@ -449,7 +446,7 @@ static ssize_t show_alert_led(struct device *dev,
{ {
struct fschmd_data *data = fschmd_update_device(dev); struct fschmd_data *data = fschmd_update_device(dev);
if (data->global_control & FSCHMD_CONTROL_ALERT_LED_MASK) if (data->global_control & FSCHMD_CONTROL_ALERT_LED)
return sprintf(buf, "1\n"); return sprintf(buf, "1\n");
else else
return sprintf(buf, "0\n"); return sprintf(buf, "0\n");
...@@ -467,9 +464,9 @@ static ssize_t store_alert_led(struct device *dev, ...@@ -467,9 +464,9 @@ static ssize_t store_alert_led(struct device *dev,
reg = i2c_smbus_read_byte_data(to_i2c_client(dev), FSCHMD_REG_CONTROL); reg = i2c_smbus_read_byte_data(to_i2c_client(dev), FSCHMD_REG_CONTROL);
if (v) if (v)
reg |= FSCHMD_CONTROL_ALERT_LED_MASK; reg |= FSCHMD_CONTROL_ALERT_LED;
else else
reg &= ~FSCHMD_CONTROL_ALERT_LED_MASK; reg &= ~FSCHMD_CONTROL_ALERT_LED;
i2c_smbus_write_byte_data(to_i2c_client(dev), FSCHMD_REG_CONTROL, reg); i2c_smbus_write_byte_data(to_i2c_client(dev), FSCHMD_REG_CONTROL, reg);
...@@ -683,11 +680,11 @@ static int fschmd_probe(struct i2c_client *client, ...@@ -683,11 +680,11 @@ static int fschmd_probe(struct i2c_client *client,
} }
/* Read the special DMI table for fscher and newer chips */ /* Read the special DMI table for fscher and newer chips */
if (kind == fscher || kind >= fschrc) { if ((kind == fscher || kind >= fschrc) && dmi_vref == -1) {
dmi_walk(fschmd_dmi_decode); dmi_walk(fschmd_dmi_decode);
if (dmi_vref == -1) { if (dmi_vref == -1) {
printk(KERN_WARNING FSCHMD_NAME dev_warn(&client->dev,
": Couldn't get voltage scaling factors from " "Couldn't get voltage scaling factors from "
"BIOS DMI table, using builtin defaults\n"); "BIOS DMI table, using builtin defaults\n");
dmi_vref = 33; dmi_vref = 33;
} }
...@@ -736,7 +733,7 @@ static int fschmd_probe(struct i2c_client *client, ...@@ -736,7 +733,7 @@ static int fschmd_probe(struct i2c_client *client,
} }
revision = i2c_smbus_read_byte_data(client, FSCHMD_REG_REVISION); revision = i2c_smbus_read_byte_data(client, FSCHMD_REG_REVISION);
printk(KERN_INFO FSCHMD_NAME ": Detected FSC %s chip, revision: %d\n", dev_info(&client->dev, "Detected FSC %s chip, revision: %d\n",
names[data->kind], (int) revision); names[data->kind], (int) revision);
return 0; return 0;
...@@ -798,7 +795,7 @@ static struct fschmd_data *fschmd_update_device(struct device *dev) ...@@ -798,7 +795,7 @@ static struct fschmd_data *fschmd_update_device(struct device *dev)
data->temp_act[i] < data->temp_max[i]) data->temp_act[i] < data->temp_max[i])
i2c_smbus_write_byte_data(client, i2c_smbus_write_byte_data(client,
FSCHMD_REG_TEMP_STATE[data->kind][i], FSCHMD_REG_TEMP_STATE[data->kind][i],
FSCHMD_TEMP_ALERT_MASK); FSCHMD_TEMP_ALERT);
} }
for (i = 0; i < FSCHMD_NO_FAN_SENSORS[data->kind]; i++) { 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,11 +813,11 @@ static struct fschmd_data *fschmd_update_device(struct device *dev)
FSCHMD_REG_FAN_MIN[data->kind][i]); FSCHMD_REG_FAN_MIN[data->kind][i]);
/* reset fan status if speed is back to > 0 */ /* reset fan status if speed is back to > 0 */
if ((data->fan_status[i] & FSCHMD_FAN_ALARM_MASK) && if ((data->fan_status[i] & FSCHMD_FAN_ALARM) &&
data->fan_act[i]) data->fan_act[i])
i2c_smbus_write_byte_data(client, i2c_smbus_write_byte_data(client,
FSCHMD_REG_FAN_STATE[data->kind][i], FSCHMD_REG_FAN_STATE[data->kind][i],
FSCHMD_FAN_ALARM_MASK); FSCHMD_FAN_ALARM);
} }
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
...@@ -857,7 +854,7 @@ static void __exit fschmd_exit(void) ...@@ -857,7 +854,7 @@ static void __exit fschmd_exit(void)
i2c_del_driver(&fschmd_driver); i2c_del_driver(&fschmd_driver);
} }
MODULE_AUTHOR("Hans de Goede <j.w.r.degoede@hhs.nl>"); MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>");
MODULE_DESCRIPTION("FSC Poseidon, Hermes, Scylla, Heracles and " MODULE_DESCRIPTION("FSC Poseidon, Hermes, Scylla, Heracles and "
"Heimdall driver"); "Heimdall driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment