]> rtime.felk.cvut.cz Git - socketcan-devel.git/blobdiff - kernel/2.6/drivers/net/can/esd_pci331.c
can: provide library functions for skb allocation
[socketcan-devel.git] / kernel / 2.6 / drivers / net / can / esd_pci331.c
index 5fe879d7ab0e10f421be1fb943c418634e3a5764..534c762cdc7affec20a9c6e3f3e7f717e8ebd84a 100644 (file)
@@ -439,7 +439,7 @@ static int esd331_create_err_frame(struct net_device *dev, canid_t idflags,
        struct can_frame *cf;
        struct sk_buff *skb;
 
-       skb = dev_alloc_skb(sizeof(*cf));
+       skb = alloc_can_err_skb(dev, &cf);
        if (unlikely(skb == NULL))
                return -ENOMEM;
 
@@ -449,18 +449,12 @@ static int esd331_create_err_frame(struct net_device *dev, canid_t idflags,
        stats = &dev->stats;
 #endif
 
-       skb->dev = dev;
-       skb->protocol = htons(ETH_P_CAN);
-       cf = (struct can_frame *)skb_put(skb, sizeof(*cf));
-       memset(cf, 0, sizeof(*cf));
-
-       cf->can_id = CAN_ERR_FLAG | idflags;
-       cf->can_dlc = CAN_ERR_DLC;
+       cf->can_id |= idflags;
        cf->data[1] = d1;
 
        netif_rx(skb);
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
        dev->last_rx = jiffies;
 #endif
        stats->rx_packets++;
@@ -481,15 +475,11 @@ static void esd331_irq_rx(struct net_device *dev, struct esd331_can_msg *msg,
        struct sk_buff *skb;
        int i;
 
-       skb = netdev_alloc_skb(dev, sizeof(*cfrm));
+       skb = alloc_can_skb(dev, &cfrm);
        if (unlikely(skb == NULL)) {
                stats->rx_dropped++;
                return;
        }
-       skb->protocol = htons(ETH_P_CAN);
-
-       cfrm = (struct can_frame *)skb_put(skb, sizeof(*cfrm));
-       memset(cfrm, 0, sizeof(*cfrm));
 
        if (eff) {
                cfrm->can_id = (msg->id << 16);
@@ -513,7 +503,7 @@ static void esd331_irq_rx(struct net_device *dev, struct esd331_can_msg *msg,
 
        netif_rx(skb);
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
        dev->last_rx = jiffies;
 #endif
        stats->rx_packets++;
@@ -692,7 +682,7 @@ static int esd331_close(struct net_device *dev)
        return 0;
 }
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
 static int esd331_start_xmit(struct sk_buff *skb, struct net_device *dev)
 #else
 static netdev_tx_t esd331_start_xmit(struct sk_buff *skb,