Thread (67 messages) 67 messages, 5 authors, 2012-09-12

Re: [PATCH] can: export a safe netdev_priv wrapper for candev

From: Fabio Baltieri <hidden>
Date: 2012-09-10 18:28:17
Also in: lkml

Hi Kurt,

On Mon, Sep 10, 2012 at 04:25:07PM +0200, Kurt Van Dijck wrote:
quoted hunk ↗ jump to hunk
can: export a safe netdev_priv wrapper for candev

In net_device notifier calls, it was impossible to determine
if a CAN device is based on candev in a safe way.
This patch adds such test in order to access candev storage
from within those notifiers.

Signed-off-by: Kurt Van Dijck <redacted>
diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index 963e2cc..6c1e704 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -795,6 +795,18 @@ void unregister_candev(struct net_device *dev)
 }
 EXPORT_SYMBOL_GPL(unregister_candev);
 
+/*
+ * Test if a network device is a candev based device
+ * and return the can_priv* if so.
+ */
+struct can_priv *safe_candev_priv(struct net_device *dev)
+{
+	if ((dev->type != ARPHRD_CAN) || (dev->rtnl_link_ops != &can_link_ops))
+		return NULL;
+
+	return netdev_priv(dev);
+}
+
No EXPORT_SYMBOL_GPL here?

Looks good to me a part from that.

Fabio

-- 
Fabio Baltieri
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help