Skip to content

Commit

Permalink
sfc: Refactor efx_mcdi_poll() by introducing efx_mcdi_poll_once()
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
  • Loading branch information
Robert Stonehouse authored and Ben Hutchings committed Dec 6, 2013
1 parent 2ec0301 commit 5731d7b
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions drivers/net/ethernet/sfc/mcdi.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ struct efx_mcdi_async_param {
static void efx_mcdi_timeout_async(unsigned long context);
static int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating,
bool *was_attached_out);
static bool efx_mcdi_poll_once(struct efx_nic *efx);

static inline struct efx_mcdi_iface *efx_mcdi(struct efx_nic *efx)
{
Expand Down Expand Up @@ -237,6 +238,21 @@ static void efx_mcdi_read_response_header(struct efx_nic *efx)
}
}

static bool efx_mcdi_poll_once(struct efx_nic *efx)
{
struct efx_mcdi_iface *mcdi = efx_mcdi(efx);

rmb();
if (!efx->type->mcdi_poll_response(efx))
return false;

spin_lock_bh(&mcdi->iface_lock);
efx_mcdi_read_response_header(efx);
spin_unlock_bh(&mcdi->iface_lock);

return true;
}

static int efx_mcdi_poll(struct efx_nic *efx)
{
struct efx_mcdi_iface *mcdi = efx_mcdi(efx);
Expand Down Expand Up @@ -272,18 +288,13 @@ static int efx_mcdi_poll(struct efx_nic *efx)

time = jiffies;

rmb();
if (efx->type->mcdi_poll_response(efx))
if (efx_mcdi_poll_once(efx))
break;

if (time_after(time, finish))
return -ETIMEDOUT;
}

spin_lock_bh(&mcdi->iface_lock);
efx_mcdi_read_response_header(efx);
spin_unlock_bh(&mcdi->iface_lock);

/* Return rc=0 like wait_event_timeout() */
return 0;
}
Expand Down

0 comments on commit 5731d7b

Please sign in to comment.