net: Push protocol type directly down to header_ops->cache()
[firefly-linux-kernel-4.4.55.git] / drivers / net / plip.c
index ec0349e84a8a8cd093977a50d3f9aa0879b291e7..a9e9ca8a86edbe2c4d7e7c9f7718420842e8aa6c 100644 (file)
@@ -152,7 +152,7 @@ static int plip_hard_header(struct sk_buff *skb, struct net_device *dev,
                             unsigned short type, const void *daddr,
                            const void *saddr, unsigned len);
 static int plip_hard_header_cache(const struct neighbour *neigh,
-                                  struct hh_cache *hh);
+                                  struct hh_cache *hh, __be16 type);
 static int plip_open(struct net_device *dev);
 static int plip_close(struct net_device *dev);
 static int plip_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
@@ -995,8 +995,10 @@ plip_tx_packet(struct sk_buff *skb, struct net_device *dev)
 static void
 plip_rewrite_address(const struct net_device *dev, struct ethhdr *eth)
 {
-       const struct in_device *in_dev = dev->ip_ptr;
+       const struct in_device *in_dev;
 
+       rcu_read_lock();
+       in_dev = __in_dev_get_rcu(dev);
        if (in_dev) {
                /* Any address will do - we take the first */
                const struct in_ifaddr *ifa = in_dev->ifa_list;
@@ -1006,6 +1008,7 @@ plip_rewrite_address(const struct net_device *dev, struct ethhdr *eth)
                        memcpy(eth->h_dest+2, &ifa->ifa_address, 4);
                }
        }
+       rcu_read_unlock();
 }
 
 static int
@@ -1023,11 +1026,11 @@ plip_hard_header(struct sk_buff *skb, struct net_device *dev,
 }
 
 static int plip_hard_header_cache(const struct neighbour *neigh,
-                                 struct hh_cache *hh)
+                                 struct hh_cache *hh, __be16 type)
 {
        int ret;
 
-       ret = eth_header_cache(neigh, hh);
+       ret = eth_header_cache(neigh, hh, type);
        if (ret == 0) {
                struct ethhdr *eth;
 
@@ -1088,7 +1091,8 @@ plip_open(struct net_device *dev)
           when the device address isn't identical to the address of a
           received frame, the kernel incorrectly drops it).             */
 
-       if ((in_dev=dev->ip_ptr) != NULL) {
+       in_dev=__in_dev_get_rtnl(dev);
+       if (in_dev) {
                /* Any address will do - we take the first. We already
                   have the first two bytes filled with 0xfc, from
                   plip_init_dev(). */
@@ -1279,7 +1283,6 @@ static void plip_attach (struct parport *port)
                if (!nl->pardev) {
                        printk(KERN_ERR "%s: parport_register failed\n", name);
                        goto err_free_dev;
-                       return;
                }
 
                plip_init_netdev(dev);