Commit 0dea4d03 authored by Russell King's avatar Russell King Committed by David S. Miller
Browse files

net: sfp: report error on failure to read sfp soft status



Report a rate-limited error if we fail to read the SFP soft status,
and preserve the current status in that case. This avoids I2C bus
errors from triggering a link flap.

Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d8e419da
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -442,13 +442,20 @@ static unsigned int sfp_soft_get_state(struct sfp *sfp)
{
	unsigned int state = 0;
	u8 status;
	int ret;

	if (sfp_read(sfp, true, SFP_STATUS, &status, sizeof(status)) ==
		     sizeof(status)) {
	ret = sfp_read(sfp, true, SFP_STATUS, &status, sizeof(status));
	if (ret == sizeof(status)) {
		if (status & SFP_STATUS_RX_LOS)
			state |= SFP_F_LOS;
		if (status & SFP_STATUS_TX_FAULT)
			state |= SFP_F_TX_FAULT;
	} else {
		dev_err_ratelimited(sfp->dev,
				    "failed to read SFP soft status: %d\n",
				    ret);
		/* Preserve the current state */
		state = sfp->state;
	}

	return state & sfp->state_soft_mask;