summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/sfc/mcdi_mon.c
diff options
context:
space:
mode:
authorAlexandre Rames <arames@solarflare.com>2013-07-03 12:47:34 +0400
committerBen Hutchings <bhutchings@solarflare.com>2013-08-28 01:29:48 +0400
commit8c4e720f181f251948c52913c74a86f68aed9c50 (patch)
treed04c3551f2673d837d6935f3afdb2990461a23bc /drivers/net/ethernet/sfc/mcdi_mon.c
parent3dced740c243f454a9b83fbe73133911d5c6ce8d (diff)
downloadlinux-8c4e720f181f251948c52913c74a86f68aed9c50.tar.xz
sfc: Return an error code when a sensor is busy.
[bwh: Also name this new state, though we don't expect to see it in an event] Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Diffstat (limited to 'drivers/net/ethernet/sfc/mcdi_mon.c')
-rw-r--r--drivers/net/ethernet/sfc/mcdi_mon.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/net/ethernet/sfc/mcdi_mon.c b/drivers/net/ethernet/sfc/mcdi_mon.c
index 958c73faa523..544889bacecc 100644
--- a/drivers/net/ethernet/sfc/mcdi_mon.c
+++ b/drivers/net/ethernet/sfc/mcdi_mon.c
@@ -54,6 +54,7 @@ static const char *const sensor_status_names[] = {
[MC_CMD_SENSOR_STATE_WARNING] = "Warning",
[MC_CMD_SENSOR_STATE_FATAL] = "Fatal",
[MC_CMD_SENSOR_STATE_BROKEN] = "Device failure",
+ [MC_CMD_SENSOR_STATE_NO_READING] = "No reading",
};
void efx_mcdi_sensor_event(struct efx_nic *efx, efx_qword_t *ev)
@@ -144,13 +145,17 @@ static ssize_t efx_mcdi_mon_show_value(struct device *dev,
struct efx_mcdi_mon_attribute *mon_attr =
container_of(attr, struct efx_mcdi_mon_attribute, dev_attr);
efx_dword_t entry;
- unsigned int value;
+ unsigned int value, state;
int rc;
rc = efx_mcdi_mon_get_entry(dev, mon_attr->index, &entry);
if (rc)
return rc;
+ state = EFX_DWORD_FIELD(entry, MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_STATE);
+ if (state == MC_CMD_SENSOR_STATE_NO_READING)
+ return -EBUSY;
+
value = EFX_DWORD_FIELD(entry, MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_VALUE);
/* Convert temperature from degrees to milli-degrees Celsius */