summaryrefslogtreecommitdiffstats
path: root/drivers/net/can/dev.c
diff options
context:
space:
mode:
authorKurt Van Dijck <kurt.van.dijck@eia.be>2012-12-18 18:50:56 +0100
committerMarc Kleine-Budde <mkl@pengutronix.de>2013-01-26 16:58:59 +0100
commitbf03a5379cd3492fbeca42111340581ba9dee0b8 (patch)
treec4a4a93c0645d66a0dcb8f718739696b4240c8ab /drivers/net/can/dev.c
parent996a953de02ffb852c9ac736f4e892008ed68884 (diff)
downloadop-kernel-dev-bf03a5379cd3492fbeca42111340581ba9dee0b8.zip
op-kernel-dev-bf03a5379cd3492fbeca42111340581ba9dee0b8.tar.gz
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 <kurt.van.dijck@eia.be> Acked-by: Oliver Hartkopp <socketcan@hartkopp.net> Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers/net/can/dev.c')
-rw-r--r--drivers/net/can/dev.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index 8233e5e..13e7380 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -794,6 +794,19 @@ 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);
+}
+EXPORT_SYMBOL_GPL(safe_candev_priv);
+
static __init int can_dev_init(void)
{
int err;
OpenPOWER on IntegriCloud