Skip to contentSkip to conversation

can: various fixes to the device driver interface

PATCH In review Wolfgang Grandegger 2 participants 5 messages Jul 20, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover can: various fixes to the device driver interface

Hello,

this patch series fixes the following issues with CAN device driver interface and the SJA1000 driver:

[PATCH 1/3] can: sja1000: remove duplicated includes
[PATCH 2/3] can: restart device even if dev_alloc_skb() fails [PATCH 3/3] can: switch carrier on if device was stopped while in bus-off state

Wolfgang.

#1 lore raw

PATCH 1/3 can: sja1000: remove duplicated includes

Remove duplicated #include('s) in
drivers/net/can/sja1000/sja1000.c

---
 drivers/net/can/sja1000/sja1000.c |    1 -
 1 file changed, 1 deletion(-)
drivers/net/can/sja1000/sja1000.c +0 -1
Index: net-next-2.6/drivers/net/can/sja1000/sja1000.c
===================================================================
@@ -63,7 +63,6 @@
 #include <linux/can.h>
 #include <linux/can/dev.h>
 #include <linux/can/error.h>
-#include <linux/can/dev.h>
 
 #include "sja1000.h"
 
#2 lore raw

PATCH 2/3 can: restart device even if dev_alloc_skb() fails

In reply to Wolfgang Grandegger

If dev_alloc_skb() failed in can_restart(), the device was left behind in the bus-off state. This patch restarts the device nevertheless.

---
 drivers/net/can/dev.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/can/dev.c +2 -2
Index: net-next-2.6/drivers/net/can/dev.c
===================================================================
@@ -346,7 +346,7 @@
 	skb = dev_alloc_skb(sizeof(struct can_frame));
 	if (skb == NULL) {
 		err = -ENOMEM;
-		goto out;
+		goto restart;
 	}
 	skb->dev = dev;
 	skb->protocol = htons(ETH_P_CAN);
@@ -361,13 +361,13 @@
 	stats->rx_packets++;
 	stats->rx_bytes += cf->can_dlc;
 
+restart:
 	dev_dbg(dev->dev.parent, "restarted\n");
 	priv->can_stats.restarts++;
 
 	/* Now restart the device */
 	err = priv->do_set_mode(dev, CAN_MODE_START);
 
-out:
 	netif_carrier_on(dev);
 	if (err)
 		dev_err(dev->dev.parent, "Error %d during restart", err);
#3 lore raw

PATCH 3/3 can: switch carrier on if device was stopped while in bus-off state

In reply to Wolfgang Grandegger

This patch fixes a problem when a device is stopped while in the bus-off state. Then the carrier remains off forever.

---
 drivers/net/can/dev.c |    4 ++++
 1 file changed, 4 insertions(+)
drivers/net/can/dev.c +4 -0
Index: net-next-2.6/drivers/net/can/dev.c
===================================================================
@@ -473,6 +473,10 @@
 		return -EINVAL;
 	}
 
+	/* Switch carrier on if device was stopped while in bus-off state */
+	if (!netif_carrier_ok(dev))
+		netif_carrier_on(dev);
+
 	setup_timer(&priv->restart_timer, can_restart, (unsigned long)dev);
 
 	return 0;
maintainer
#4 lore raw
In reply to Wolfgang Grandegger

From: Wolfgang Grandegger <[email protected]>
Date: Mon, 20 Jul 2009 16:06:38 +0200

Quoted 6 lines

this patch series fixes the following issues with CAN device driver interface and the SJA1000 driver:

[PATCH 1/3] can: sja1000: remove duplicated includes
[PATCH 2/3] can: restart device even if dev_alloc_skb() fails [PATCH 3/3] can: switch carrier on if device was stopped while in bus-off state

All applied, thanks.