Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit be38a6f9 authored by Andri Yngvason's avatar Andri Yngvason Committed by Marc Kleine-Budde
Browse files

can: move can_stats.bus_off++ from can_bus_off into can_change_state



In order to be able to move the stats increment from can_bus_off() into
can_change_state(), the increment had to be moved back into code that was using
can_bus_off() but not can_change_state().

As a side-effect, this patch fixes the following bugs:
 * Redundant call to can_bus_off() in c_can.
 * Bus-off counted twice in xilinx_can.

Signed-off-by: default avatarAndri Yngvason <andri.yngvason@marel.com>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent 0c490874
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -352,6 +352,7 @@ static int bfin_can_err(struct net_device *dev, u16 isrc, u16 status)
		netdev_dbg(dev, "bus-off mode interrupt\n");
		netdev_dbg(dev, "bus-off mode interrupt\n");
		state = CAN_STATE_BUS_OFF;
		state = CAN_STATE_BUS_OFF;
		cf->can_id |= CAN_ERR_BUSOFF;
		cf->can_id |= CAN_ERR_BUSOFF;
		priv->can.can_stats.bus_off++;
		can_bus_off(dev);
		can_bus_off(dev);
	}
	}


+1 −1
Original line number Original line Diff line number Diff line
@@ -866,7 +866,7 @@ static int c_can_handle_state_change(struct net_device *dev,
	case C_CAN_BUS_OFF:
	case C_CAN_BUS_OFF:
		/* bus-off state */
		/* bus-off state */
		priv->can.state = CAN_STATE_BUS_OFF;
		priv->can.state = CAN_STATE_BUS_OFF;
		can_bus_off(dev);
		priv->can.can_stats.bus_off++;
		break;
		break;
	default:
	default:
		break;
		break;
+1 −0
Original line number Original line Diff line number Diff line
@@ -535,6 +535,7 @@ static int cc770_err(struct net_device *dev, u8 status)
		cc770_write_reg(priv, control, CTRL_INI);
		cc770_write_reg(priv, control, CTRL_INI);
		cf->can_id |= CAN_ERR_BUSOFF;
		cf->can_id |= CAN_ERR_BUSOFF;
		priv->can.state = CAN_STATE_BUS_OFF;
		priv->can.state = CAN_STATE_BUS_OFF;
		priv->can.can_stats.bus_off++;
		can_bus_off(dev);
		can_bus_off(dev);
	} else if (status & STAT_WARN) {
	} else if (status & STAT_WARN) {
		cf->can_id |= CAN_ERR_CRTL;
		cf->can_id |= CAN_ERR_CRTL;
+2 −1
Original line number Original line Diff line number Diff line
@@ -289,6 +289,8 @@ static void can_update_state_error_stats(struct net_device *dev,
		priv->can_stats.error_passive++;
		priv->can_stats.error_passive++;
		break;
		break;
	case CAN_STATE_BUS_OFF:
	case CAN_STATE_BUS_OFF:
		priv->can_stats.bus_off++;
		break;
	default:
	default:
		break;
		break;
	};
	};
@@ -544,7 +546,6 @@ void can_bus_off(struct net_device *dev)
	netdev_dbg(dev, "bus-off\n");
	netdev_dbg(dev, "bus-off\n");


	netif_carrier_off(dev);
	netif_carrier_off(dev);
	priv->can_stats.bus_off++;


	if (priv->restart_ms)
	if (priv->restart_ms)
		mod_timer(&priv->restart_timer,
		mod_timer(&priv->restart_timer,
+1 −0
Original line number Original line Diff line number Diff line
@@ -1008,6 +1008,7 @@ static int ican3_handle_cevtind(struct ican3_dev *mod, struct ican3_msg *msg)
		if (status & SR_BS) {
		if (status & SR_BS) {
			state = CAN_STATE_BUS_OFF;
			state = CAN_STATE_BUS_OFF;
			cf->can_id |= CAN_ERR_BUSOFF;
			cf->can_id |= CAN_ERR_BUSOFF;
			mod->can.can_stats.bus_off++;
			can_bus_off(dev);
			can_bus_off(dev);
		} else if (status & SR_ES) {
		} else if (status & SR_ES) {
			if (rxerr >= 128 || txerr >= 128)
			if (rxerr >= 128 || txerr >= 128)
Loading