Ditto for mcp251x but against mainline. Just a question I noted studying the error frames: it looks to me that there isn't an error frame saying "the situation is come back to normality" (I mean error-active). Is this normal or I'm just missing something?
>From dd026c6b7d09dace124f7f632e0403988d907ab2 Mon Sep 17 00:00:00 2001 From: Christian Pellegrin <[email protected]> Date: Sun, 7 Feb 2010 09:29:37 +0100 Subject: [PATCH] reenable reporting of bus errors --- drivers/net/can/mcp251x.c | 23 ++++++++++++++++------- include/linux/can/netlink.h | 1 + 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c index a9e475e..2608817 100644 --- a/drivers/net/can/mcp251x.c +++ b/drivers/net/can/mcp251x.c @@ -510,11 +510,14 @@ static int mcp251x_set_normal_mode(struct spi_device *spi) { struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev); unsigned long timeout; + unsigned int intmask = CANINTE_ERRIE | CANINTE_TX2IE | CANINTE_TX1IE | + CANINTE_TX0IE | CANINTE_RX1IE | CANINTE_RX0IE; + + if (priv->can.ctrlmode & CAN_CTRLMODE_BUS_ERROR) + intmask |= CANINTE_MERRE; /* Enable interrupts */ - mcp251x_write_reg(spi, CANINTE, - CANINTE_ERRIE | CANINTE_TX2IE | CANINTE_TX1IE | - CANINTE_TX0IE | CANINTE_RX1IE | CANINTE_RX0IE); + mcp251x_write_reg(spi, CANINTE, intmask); if (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK) { /* Put device into loopback mode */ @@ -880,7 +883,7 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id) } priv->can.state = new_state; - if (intf & CANINTF_ERRIF) { + if ((intf & CANINTF_ERRIF) || (intf & CANINTF_MERRF)) { /* Handle overflow counters */ if (eflag & (EFLG_RX0OVR | EFLG_RX1OVR)) { if (eflag & EFLG_RX0OVR) @@ -890,7 +893,13 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id) can_id |= CAN_ERR_CRTL; data1 |= CAN_ERR_CRTL_RX_OVERFLOW; } - mcp251x_error_skb(net, can_id, data1); + /* Handle TX/RX errors */ + if (intf & CANINTF_MERRF) { + priv->can.can_stats.bus_error++; + can_id |= CAN_ERR_BUSERROR; + } + if (can_id) + mcp251x_error_skb(net, can_id, data1); } if (priv->can.state == CAN_STATE_BUS_OFF) { @@ -914,7 +923,6 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id) } netif_wake_queue(net); } - } mutex_unlock(&priv->mcp_lock); return IRQ_HANDLED; @@ -1009,7 +1017,8 @@ static int __devinit mcp251x_can_probe(struct spi_device *spi) priv->can.do_set_mode = mcp251x_do_set_mode; priv->can.clock.freq = pdata->oscillator_frequency / 2; priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES | - CAN_CTRLMODE_LOOPBACK | CAN_CTRLMODE_LISTENONLY; + CAN_CTRLMODE_LOOPBACK | CAN_CTRLMODE_LISTENONLY | + CAN_CTRLMODE_BUS_ERROR; priv->net = net; dev_set_drvdata(&spi->dev, priv); diff --git a/include/linux/can/netlink.h b/include/linux/can/netlink.h index 7c860e8..49960e4 100644 --- a/include/linux/can/netlink.h +++ b/include/linux/can/netlink.h @@ -81,6 +81,7 @@ struct can_ctrlmode { #define CAN_CTRLMODE_LISTENONLY 0x2 /* Listen-only mode */ #define CAN_CTRLMODE_3_SAMPLES 0x4 /* Triple sampling mode */ #define CAN_CTRLMODE_ONE_SHOT 0x8 /* One-Shot mode */ +#define CAN_CTRLMODE_BUS_ERROR 0x10 /* Bus-error support mode */ /* * CAN device statistics -- 1.5.6.5 -- Christian Pellegrin, see http://www.evolware.org/chri/ "Real Programmers don't play tennis, or any other sport which requires you to change clothes. Mountain climbing is OK, and Real Programmers wear their climbing boots to work in case a mountain should suddenly spring up in the middle of the computer room." _______________________________________________ Socketcan-users mailing list [email protected] https://lists.berlios.de/mailman/listinfo/socketcan-users
