Skip to content

Commit

Permalink
hwmon: (occ) Store error condition for rate-limited polls
Browse files Browse the repository at this point in the history
The OCC driver limits the rate of sending poll commands to the OCC. If a
user reads a hwmon entry after a poll response resulted in an error and
is rate-limited, the error is invisible to the user. Fix this by storing
the last error and returning that in the rate-limited case.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
  • Loading branch information
Eddie James authored and groeck committed Apr 16, 2019
1 parent 5c090ab commit b5c46a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions drivers/hwmon/occ/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ static int occ_poll(struct occ *occ)
/* mutex should already be locked if necessary */
rc = occ->send_cmd(occ, cmd);
if (rc) {
occ->last_error = rc;
if (occ->error_count++ > OCC_ERROR_COUNT_THRESHOLD)
occ->error = rc;

Expand All @@ -149,6 +150,7 @@ static int occ_poll(struct occ *occ)

/* clear error since communication was successful */
occ->error_count = 0;
occ->last_error = 0;
occ->error = 0;

/* check for safe state */
Expand Down Expand Up @@ -210,6 +212,8 @@ int occ_update_response(struct occ *occ)
if (time_after(jiffies, occ->last_update + OCC_UPDATE_FREQUENCY)) {
rc = occ_poll(occ);
occ->last_update = jiffies;
} else {
rc = occ->last_error;
}

mutex_unlock(&occ->lock);
Expand Down
3 changes: 2 additions & 1 deletion drivers/hwmon/occ/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ struct occ {
struct attribute_group group;
const struct attribute_group *groups[2];

int error; /* latest transfer error */
int error; /* final transfer error after retry */
int last_error; /* latest transfer error */
unsigned int error_count; /* number of xfr errors observed */
unsigned long last_safe; /* time OCC entered "safe" state */

Expand Down

0 comments on commit b5c46a5

Please sign in to comment.