Commit 5216dff2 authored by Eddie James's avatar Eddie James Committed by Guenter Roeck

hwmon: (occ) Fix poll rate limiting

The poll rate limiter time was initialized at zero. This breaks the
comparison in time_after if jiffies is large. Switch to storing the
next update time rather than the previous time, and initialize the
time when the device is probed.

Fixes: c10e753d ("hwmon (occ): Add sensor types and versions")
Signed-off-by: default avatarEddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20210429151336.18980-1-eajames@linux.ibm.comSigned-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 726c945a
...@@ -217,9 +217,9 @@ int occ_update_response(struct occ *occ) ...@@ -217,9 +217,9 @@ int occ_update_response(struct occ *occ)
return rc; return rc;
/* limit the maximum rate of polling the OCC */ /* limit the maximum rate of polling the OCC */
if (time_after(jiffies, occ->last_update + OCC_UPDATE_FREQUENCY)) { if (time_after(jiffies, occ->next_update)) {
rc = occ_poll(occ); rc = occ_poll(occ);
occ->last_update = jiffies; occ->next_update = jiffies + OCC_UPDATE_FREQUENCY;
} else { } else {
rc = occ->last_error; rc = occ->last_error;
} }
...@@ -1165,6 +1165,7 @@ int occ_setup(struct occ *occ, const char *name) ...@@ -1165,6 +1165,7 @@ int occ_setup(struct occ *occ, const char *name)
return rc; return rc;
} }
occ->next_update = jiffies + OCC_UPDATE_FREQUENCY;
occ_parse_poll_response(occ); occ_parse_poll_response(occ);
rc = occ_setup_sensor_attrs(occ); rc = occ_setup_sensor_attrs(occ);
......
...@@ -99,7 +99,7 @@ struct occ { ...@@ -99,7 +99,7 @@ struct occ {
u8 poll_cmd_data; /* to perform OCC poll command */ u8 poll_cmd_data; /* to perform OCC poll command */
int (*send_cmd)(struct occ *occ, u8 *cmd); int (*send_cmd)(struct occ *occ, u8 *cmd);
unsigned long last_update; unsigned long next_update;
struct mutex lock; /* lock OCC access */ struct mutex lock; /* lock OCC access */
struct device *hwmon; struct device *hwmon;
......
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