Commit ed359056 authored by Vincent Whitchurch's avatar Vincent Whitchurch Committed by Guenter Roeck

hwmon: (pmbus) Fix vout margin caching

The code currently uses a zero margin to mean not cached, but this
results in the cache being bypassed if the (low) margin is set to zero,
leading to lots of unnecessary SMBus transactions in that case.  Use a
negative value instead.

Fixes: 07fb7627 ("hwmon: (pmbus) Introduce and use cached vout margins")
Signed-off-by: default avatarVincent Whitchurch <vincent.whitchurch@axis.com>
Link: https://lore.kernel.org/r/20220816144414.2358974-1-vincent.whitchurch@axis.comSigned-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 09e52d17
...@@ -2861,7 +2861,7 @@ static int pmbus_regulator_get_low_margin(struct i2c_client *client, int page) ...@@ -2861,7 +2861,7 @@ static int pmbus_regulator_get_low_margin(struct i2c_client *client, int page)
.data = -1, .data = -1,
}; };
if (!data->vout_low[page]) { if (data->vout_low[page] < 0) {
if (pmbus_check_word_register(client, page, PMBUS_MFR_VOUT_MIN)) if (pmbus_check_word_register(client, page, PMBUS_MFR_VOUT_MIN))
s.data = _pmbus_read_word_data(client, page, 0xff, s.data = _pmbus_read_word_data(client, page, 0xff,
PMBUS_MFR_VOUT_MIN); PMBUS_MFR_VOUT_MIN);
...@@ -2887,7 +2887,7 @@ static int pmbus_regulator_get_high_margin(struct i2c_client *client, int page) ...@@ -2887,7 +2887,7 @@ static int pmbus_regulator_get_high_margin(struct i2c_client *client, int page)
.data = -1, .data = -1,
}; };
if (!data->vout_high[page]) { if (data->vout_high[page] < 0) {
if (pmbus_check_word_register(client, page, PMBUS_MFR_VOUT_MAX)) if (pmbus_check_word_register(client, page, PMBUS_MFR_VOUT_MAX))
s.data = _pmbus_read_word_data(client, page, 0xff, s.data = _pmbus_read_word_data(client, page, 0xff,
PMBUS_MFR_VOUT_MAX); PMBUS_MFR_VOUT_MAX);
...@@ -3319,6 +3319,7 @@ int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info) ...@@ -3319,6 +3319,7 @@ int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info)
struct pmbus_data *data; struct pmbus_data *data;
size_t groups_num = 0; size_t groups_num = 0;
int ret; int ret;
int i;
char *name; char *name;
if (!info) if (!info)
...@@ -3352,6 +3353,11 @@ int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info) ...@@ -3352,6 +3353,11 @@ int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info)
data->currpage = -1; data->currpage = -1;
data->currphase = -1; data->currphase = -1;
for (i = 0; i < ARRAY_SIZE(data->vout_low); i++) {
data->vout_low[i] = -1;
data->vout_high[i] = -1;
}
ret = pmbus_init_common(client, data, info); ret = pmbus_init_common(client, data, info);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
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