提交 2507abb3 编写于 作者: G Guenter Roeck

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: NGuenter Roeck <linux@roeck-us.net>
上级 a7c69118
...@@ -123,15 +123,28 @@ static int lm25066_write_word_data(struct i2c_client *client, int page, int reg, ...@@ -123,15 +123,28 @@ static int lm25066_write_word_data(struct i2c_client *client, int page, int reg,
int ret; int ret;
switch (reg) { 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: case PMBUS_IIN_OC_WARN_LIMIT:
word = ((s16)word < 0) ? 0 : clamp_val(word, 0, 0x0fff);
ret = pmbus_write_word_data(client, 0, ret = pmbus_write_word_data(client, 0,
LM25066_MFR_IIN_OC_WARN_LIMIT, LM25066_MFR_IIN_OC_WARN_LIMIT,
word); word);
pmbus_clear_cache(client);
break; break;
case PMBUS_PIN_OP_WARN_LIMIT: case PMBUS_PIN_OP_WARN_LIMIT:
word = ((s16)word < 0) ? 0 : clamp_val(word, 0, 0x0fff);
ret = pmbus_write_word_data(client, 0, ret = pmbus_write_word_data(client, 0,
LM25066_MFR_PIN_OP_WARN_LIMIT, LM25066_MFR_PIN_OP_WARN_LIMIT,
word); word);
pmbus_clear_cache(client);
break; break;
case PMBUS_VIRT_RESET_PIN_HISTORY: case PMBUS_VIRT_RESET_PIN_HISTORY:
ret = pmbus_write_byte(client, 0, LM25066_CLEAR_PIN_PEAK); ret = pmbus_write_byte(client, 0, LM25066_CLEAR_PIN_PEAK);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册