net: introduce CAN specific pointer in the struct net_device
[sfrench/cifs-2.6.git] / net / can / j1939 / main.c
index bb914d8b42168243cf43d1e657a298eea97be27f..da3a7a7bcff2ba0e48104a5cb5de97c7701531f1 100644 (file)
@@ -140,9 +140,9 @@ static struct j1939_priv *j1939_priv_create(struct net_device *ndev)
 static inline void j1939_priv_set(struct net_device *ndev,
                                  struct j1939_priv *priv)
 {
-       struct can_ml_priv *can_ml_priv = ndev->ml_priv;
+       struct can_ml_priv *can_ml = can_get_ml_priv(ndev);
 
-       can_ml_priv->j1939_priv = priv;
+       can_ml->j1939_priv = priv;
 }
 
 static void __j1939_priv_release(struct kref *kref)
@@ -211,12 +211,9 @@ static void __j1939_rx_release(struct kref *kref)
 /* get pointer to priv without increasing ref counter */
 static inline struct j1939_priv *j1939_ndev_to_priv(struct net_device *ndev)
 {
-       struct can_ml_priv *can_ml_priv = ndev->ml_priv;
+       struct can_ml_priv *can_ml = can_get_ml_priv(ndev);
 
-       if (!can_ml_priv)
-               return NULL;
-
-       return can_ml_priv->j1939_priv;
+       return can_ml->j1939_priv;
 }
 
 static struct j1939_priv *j1939_priv_get_by_ndev_locked(struct net_device *ndev)
@@ -225,9 +222,6 @@ static struct j1939_priv *j1939_priv_get_by_ndev_locked(struct net_device *ndev)
 
        lockdep_assert_held(&j1939_netdev_lock);
 
-       if (ndev->type != ARPHRD_CAN)
-               return NULL;
-
        priv = j1939_ndev_to_priv(ndev);
        if (priv)
                j1939_priv_get(priv);
@@ -348,15 +342,16 @@ static int j1939_netdev_notify(struct notifier_block *nb,
                               unsigned long msg, void *data)
 {
        struct net_device *ndev = netdev_notifier_info_to_dev(data);
+       struct can_ml_priv *can_ml = can_get_ml_priv(ndev);
        struct j1939_priv *priv;
 
+       if (!can_ml)
+               goto notify_done;
+
        priv = j1939_priv_get_by_ndev(ndev);
        if (!priv)
                goto notify_done;
 
-       if (ndev->type != ARPHRD_CAN)
-               goto notify_put;
-
        switch (msg) {
        case NETDEV_DOWN:
                j1939_cancel_active_session(priv, NULL);
@@ -365,7 +360,6 @@ static int j1939_netdev_notify(struct notifier_block *nb,
                break;
        }
 
-notify_put:
        j1939_priv_put(priv);
 
 notify_done: