summaryrefslogtreecommitdiff
path: root/drivers/hwmon/pmbus/ltc2978.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2015-08-16 03:02:09 +0300
committerGuenter Roeck <linux@roeck-us.net>2015-08-17 21:55:55 +0300
commit8582bcc8ebb21375b37f337c58ca783b997a0355 (patch)
treedaf94b261cbb8b9658b4dcedde594a5a6de920f4 /drivers/hwmon/pmbus/ltc2978.c
parent2238835c5ce9f8eae5cb4dd6a6c05a6c82743282 (diff)
downloadlinux-8582bcc8ebb21375b37f337c58ca783b997a0355.tar.xz
hwmon: (ltc2978) Introduce feature flags
It is becoming cumbersom to track per-chip feature support. Introduce feature flag to simplify the code. Tested-by: Michael Jones <mike@proclivis.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/pmbus/ltc2978.c')
-rw-r--r--drivers/hwmon/pmbus/ltc2978.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/drivers/hwmon/pmbus/ltc2978.c b/drivers/hwmon/pmbus/ltc2978.c
index e153ffd59ab0..48cbb5794e30 100644
--- a/drivers/hwmon/pmbus/ltc2978.c
+++ b/drivers/hwmon/pmbus/ltc2978.c
@@ -97,10 +97,14 @@ struct ltc2978_data {
u16 pin_min, pin_max;
u16 temp2_max;
struct pmbus_driver_info info;
+ u32 features;
};
-
#define to_ltc2978_data(x) container_of(x, struct ltc2978_data, info)
+#define FEAT_CLEAR_PEAKS BIT(0)
+
+#define has_clear_peaks(d) ((d)->features & FEAT_CLEAR_PEAKS)
+
static inline int lin11_to_val(int data)
{
s16 e = ((s16)data) >> 11;
@@ -374,13 +378,12 @@ static int ltc3883_read_word_data(struct i2c_client *client, int page, int reg)
return ret;
}
-static int ltc2978_clear_peaks(struct i2c_client *client, int page,
- enum chips id)
+static int ltc2978_clear_peaks(struct ltc2978_data *data,
+ struct i2c_client *client, int page)
{
int ret;
- if (id == ltc3880 || id == ltc3882 || id == ltc3883 || id == ltc3887 ||
- id == ltm4676)
+ if (has_clear_peaks(data))
ret = pmbus_write_byte(client, 0, LTC3880_MFR_CLEAR_PEAKS);
else
ret = pmbus_write_byte(client, page, PMBUS_CLEAR_FAULTS);
@@ -399,36 +402,36 @@ static int ltc2978_write_word_data(struct i2c_client *client, int page,
case PMBUS_VIRT_RESET_IIN_HISTORY:
data->iin_max = 0x7c00;
data->iin_min = 0x7bff;
- ret = ltc2978_clear_peaks(client, 0, data->id);
+ ret = ltc2978_clear_peaks(data, client, 0);
break;
case PMBUS_VIRT_RESET_PIN_HISTORY:
data->pin_max = 0x7c00;
data->pin_min = 0x7bff;
- ret = ltc2978_clear_peaks(client, 0, data->id);
+ ret = ltc2978_clear_peaks(data, client, 0);
break;
case PMBUS_VIRT_RESET_IOUT_HISTORY:
data->iout_max[page] = 0x7c00;
data->iout_min[page] = 0xfbff;
- ret = ltc2978_clear_peaks(client, page, data->id);
+ ret = ltc2978_clear_peaks(data, client, page);
break;
case PMBUS_VIRT_RESET_TEMP2_HISTORY:
data->temp2_max = 0x7c00;
- ret = ltc2978_clear_peaks(client, page, data->id);
+ ret = ltc2978_clear_peaks(data, client, page);
break;
case PMBUS_VIRT_RESET_VOUT_HISTORY:
data->vout_min[page] = 0xffff;
data->vout_max[page] = 0;
- ret = ltc2978_clear_peaks(client, page, data->id);
+ ret = ltc2978_clear_peaks(data, client, page);
break;
case PMBUS_VIRT_RESET_VIN_HISTORY:
data->vin_min = 0x7bff;
data->vin_max = 0x7c00;
- ret = ltc2978_clear_peaks(client, page, data->id);
+ ret = ltc2978_clear_peaks(data, client, page);
break;
case PMBUS_VIRT_RESET_TEMP_HISTORY:
data->temp_min[page] = 0x7bff;
data->temp_max[page] = 0x7c00;
- ret = ltc2978_clear_peaks(client, page, data->id);
+ ret = ltc2978_clear_peaks(data, client, page);
break;
default:
ret = -ENODATA;
@@ -603,6 +606,7 @@ static int ltc2978_probe(struct i2c_client *client,
case ltc3880:
case ltc3887:
case ltm4676:
+ data->features |= FEAT_CLEAR_PEAKS;
info->read_word_data = ltc3880_read_word_data;
info->pages = LTC3880_NUM_PAGES;
info->func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_IIN
@@ -617,6 +621,7 @@ static int ltc2978_probe(struct i2c_client *client,
| PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP;
break;
case ltc3882:
+ data->features |= FEAT_CLEAR_PEAKS;
info->read_word_data = ltc3880_read_word_data;
info->pages = LTC3880_NUM_PAGES;
info->func[0] = PMBUS_HAVE_VIN
@@ -631,6 +636,7 @@ static int ltc2978_probe(struct i2c_client *client,
| PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP;
break;
case ltc3883:
+ data->features |= FEAT_CLEAR_PEAKS;
info->read_word_data = ltc3883_read_word_data;
info->pages = LTC3883_NUM_PAGES;
info->func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_IIN