Skip to content

Commit ed35905

Browse files
vwaxgroeck
authored andcommitted
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: 07fb762 ("hwmon: (pmbus) Introduce and use cached vout margins") Signed-off-by: Vincent Whitchurch <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
1 parent 09e52d1 commit ed35905

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/hwmon/pmbus/pmbus_core.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2861,7 +2861,7 @@ static int pmbus_regulator_get_low_margin(struct i2c_client *client, int page)
28612861
.data = -1,
28622862
};
28632863

2864-
if (!data->vout_low[page]) {
2864+
if (data->vout_low[page] < 0) {
28652865
if (pmbus_check_word_register(client, page, PMBUS_MFR_VOUT_MIN))
28662866
s.data = _pmbus_read_word_data(client, page, 0xff,
28672867
PMBUS_MFR_VOUT_MIN);
@@ -2887,7 +2887,7 @@ static int pmbus_regulator_get_high_margin(struct i2c_client *client, int page)
28872887
.data = -1,
28882888
};
28892889

2890-
if (!data->vout_high[page]) {
2890+
if (data->vout_high[page] < 0) {
28912891
if (pmbus_check_word_register(client, page, PMBUS_MFR_VOUT_MAX))
28922892
s.data = _pmbus_read_word_data(client, page, 0xff,
28932893
PMBUS_MFR_VOUT_MAX);
@@ -3319,6 +3319,7 @@ int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info)
33193319
struct pmbus_data *data;
33203320
size_t groups_num = 0;
33213321
int ret;
3322+
int i;
33223323
char *name;
33233324

33243325
if (!info)
@@ -3352,6 +3353,11 @@ int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info)
33523353
data->currpage = -1;
33533354
data->currphase = -1;
33543355

3356+
for (i = 0; i < ARRAY_SIZE(data->vout_low); i++) {
3357+
data->vout_low[i] = -1;
3358+
data->vout_high[i] = -1;
3359+
}
3360+
33553361
ret = pmbus_init_common(client, data, info);
33563362
if (ret < 0)
33573363
return ret;

0 commit comments

Comments
 (0)