summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/pmbus
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2013-02-06 20:49:12 -0800
committerGuenter Roeck <linux@roeck-us.net>2013-04-07 21:16:41 -0700
commit2507abb3a7a89fa496769f2a224585e77f5fb195 (patch)
tree2bd25baa3f298c247ad3c55769a9e78403837aaf /drivers/hwmon/pmbus
parenta7c69118bdc8647db0e15defa9e399df21a48890 (diff)
downloadlinux-2507abb3a7a89fa496769f2a224585e77f5fb195.tar.bz2
hwmon: (pmbus/lm25066) Clamp limit attributes
Limits on all supported sensors and chips have to be within 0..0x0fff, and limits are always positive. Clamp written values in chip driver. Also clear value cache to ensure that the actually written value is read back and reported correctly. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/pmbus')
-rw-r--r--drivers/hwmon/pmbus/lm25066.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c
index 5489d70015c2..f9f0c93e4a3d 100644
--- a/drivers/hwmon/pmbus/lm25066.c
+++ b/drivers/hwmon/pmbus/lm25066.c
@@ -123,15 +123,28 @@ static int lm25066_write_word_data(struct i2c_client *client, int page, int reg,
int ret;
switch (reg) {
+ case PMBUS_VOUT_UV_WARN_LIMIT:
+ case PMBUS_OT_FAULT_LIMIT:
+ case PMBUS_OT_WARN_LIMIT:
+ case PMBUS_VIN_UV_WARN_LIMIT:
+ case PMBUS_VIN_OV_WARN_LIMIT:
+ word = ((s16)word < 0) ? 0 : clamp_val(word, 0, 0x0fff);
+ ret = pmbus_write_word_data(client, 0, reg, word);
+ pmbus_clear_cache(client);
+ break;
case PMBUS_IIN_OC_WARN_LIMIT:
+ word = ((s16)word < 0) ? 0 : clamp_val(word, 0, 0x0fff);
ret = pmbus_write_word_data(client, 0,
LM25066_MFR_IIN_OC_WARN_LIMIT,
word);
+ pmbus_clear_cache(client);
break;
case PMBUS_PIN_OP_WARN_LIMIT:
+ word = ((s16)word < 0) ? 0 : clamp_val(word, 0, 0x0fff);
ret = pmbus_write_word_data(client, 0,
LM25066_MFR_PIN_OP_WARN_LIMIT,
word);
+ pmbus_clear_cache(client);
break;
case PMBUS_VIRT_RESET_PIN_HISTORY:
ret = pmbus_write_byte(client, 0, LM25066_CLEAR_PIN_PEAK);