]> rtime.felk.cvut.cz Git - socketcan-devel.git/blobdiff - kernel/2.6/drivers/net/can/ems_usb.c
can: make the number of echo skb's configurable
[socketcan-devel.git] / kernel / 2.6 / drivers / net / can / ems_usb.c
index 2d1aadf0d7f5fc677718aa5bc55853c178b044f4..2b106cb35c5d7c9f87f1a1f4556fc62c1a1db9f6 100644 (file)
@@ -226,7 +226,7 @@ MODULE_DEVICE_TABLE(usb, ems_usb_table);
 #define CPC_HEADER_SIZE 4
 
 #define MAX_RX_URBS 10
-#define MAX_TX_URBS CAN_ECHO_SKB_MAX
+#define MAX_TX_URBS 4
 
 struct ems_usb;
 
@@ -333,7 +333,9 @@ static void ems_usb_rx_can_msg(struct ems_usb *dev, struct ems_cpc_msg *msg)
 
        netif_rx(skb);
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
        dev->netdev->last_rx = jiffies;
+#endif
        stats->rx_packets++;
        stats->rx_bytes += cf->can_dlc;
 }
@@ -418,7 +420,9 @@ static void ems_usb_rx_err(struct ems_usb *dev, struct ems_cpc_msg *msg)
 
        netif_rx(skb);
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
        dev->netdev->last_rx = jiffies;
+#endif
        stats->rx_packets++;
        stats->rx_bytes += cf->can_dlc;
 }
@@ -762,7 +766,12 @@ static int ems_usb_open(struct net_device *netdev)
        return 0;
 }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
 static int ems_usb_start_xmit(struct sk_buff *skb, struct net_device *netdev)
+#else
+static netdev_tx_t ems_usb_start_xmit(struct sk_buff *skb,
+                                     struct net_device *netdev)
+#endif
 {
        struct ems_usb *dev = netdev_priv(netdev);
        struct ems_tx_urb_context *context = NULL;
@@ -885,22 +894,22 @@ nomem:
        return NETDEV_TX_OK;
 }
 
-static int ems_usb_close(struct net_device *dev)
+static int ems_usb_close(struct net_device *netdev)
 {
-       struct ems_usb *priv = netdev_priv(dev);
+       struct ems_usb *dev = netdev_priv(netdev);
 
-       netif_stop_queue(dev);
+       netif_stop_queue(netdev);
 
        /* Stop polling */
-       unlink_all_urbs(priv);
+       unlink_all_urbs(dev);
 
        /* Set CAN controller to reset mode */
-       if (ems_usb_write_mode(priv, SJA1000_MOD_RM))
-               dev_warn(ND2D(dev), "couldn't stop device");
+       if (ems_usb_write_mode(dev, SJA1000_MOD_RM))
+               dev_warn(ND2D(netdev), "couldn't stop device");
 
-       close_candev(dev);
+       close_candev(netdev);
 
-       priv->open_time = 0;
+       dev->open_time = 0;
 
        return 0;
 }
@@ -925,20 +934,20 @@ static struct can_bittiming_const ems_usb_bittiming_const = {
        .brp_inc = 1,
 };
 
-static int ems_usb_set_mode(struct net_device *dev, enum can_mode mode)
+static int ems_usb_set_mode(struct net_device *netdev, enum can_mode mode)
 {
-       struct ems_usb *priv = netdev_priv(dev);
+       struct ems_usb *dev = netdev_priv(netdev);
 
-       if (!priv->open_time)
+       if (!dev->open_time)
                return -EINVAL;
 
        switch (mode) {
        case CAN_MODE_START:
-               if (ems_usb_write_mode(priv, SJA1000_MOD_NORMAL))
-                       dev_warn(ND2D(dev), "couldn't start device");
+               if (ems_usb_write_mode(dev, SJA1000_MOD_NORMAL))
+                       dev_warn(ND2D(netdev), "couldn't start device");
 
-               if (netif_queue_stopped(dev))
-                       netif_wake_queue(dev);
+               if (netif_queue_stopped(netdev))
+                       netif_wake_queue(netdev);
                break;
 
        default:
@@ -1009,7 +1018,7 @@ static int ems_usb_probe(struct usb_interface *intf,
        struct ems_usb *dev;
        int i, err;
 
-       netdev = alloc_candev(sizeof(struct ems_usb));
+       netdev = alloc_candev(sizeof(struct ems_usb), MAX_TX_URBS);
        if (!netdev) {
                dev_err(ND2D(netdev), "Couldn't alloc candev\n");
                return -ENOMEM;