]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - drivers/net/irda/ks959-sir.c
drivers: irda: fix sign bug
[linux-2.6.git] / drivers / net / irda / ks959-sir.c
index 2e67ae015d916eae51ca1a2ceb666b7b6905e5a7..1046014dd6c2e1a19fbfe2f23163dbdc8a36c4c0 100644 (file)
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/kref.h>
 #include <linux/usb.h>
 #include <linux/device.h>
 #include <linux/crc32.h>
@@ -155,7 +154,7 @@ struct ks959_speedparams {
        __le32 baudrate;        /* baud rate, little endian */
        __u8 flags;
        __u8 reserved[3];
-} __attribute__ ((packed));
+} __packed;
 
 #define KS_DATA_5_BITS 0x00
 #define KS_DATA_6_BITS 0x01
@@ -174,7 +173,7 @@ struct ks959_cb {
        struct usb_device *usbdev;      /* init: probe_irda */
        struct net_device *netdev;      /* network layer */
        struct irlap_cb *irlap; /* The link layer we are binded to */
-       struct net_device_stats stats;  /* network statistics */
+
        struct qos_info qos;
 
        struct usb_ctrlrequest *tx_setuprequest;
@@ -366,7 +365,7 @@ static void ks959_send_irq(struct urb *urb)
                                case -EPIPE:
                                        break;
                                default:
-                                       kingsun->stats.tx_errors++;
+                                       netdev->stats.tx_errors++;
                                        netif_start_queue(netdev);
                                }
                        }
@@ -385,15 +384,13 @@ static void ks959_send_irq(struct urb *urb)
 /*
  * Called from net/core when new frame is available.
  */
-static int ks959_hard_xmit(struct sk_buff *skb, struct net_device *netdev)
+static netdev_tx_t ks959_hard_xmit(struct sk_buff *skb,
+                                        struct net_device *netdev)
 {
        struct ks959_cb *kingsun;
        unsigned int wraplen;
        int ret = 0;
 
-       if (skb == NULL || netdev == NULL)
-               return -EINVAL;
-
        netif_stop_queue(netdev);
 
        /* the IRDA wrapping routines don't deal with non linear skb */
@@ -416,19 +413,19 @@ static int ks959_hard_xmit(struct sk_buff *skb, struct net_device *netdev)
                case -EPIPE:
                        break;
                default:
-                       kingsun->stats.tx_errors++;
+                       netdev->stats.tx_errors++;
                        netif_start_queue(netdev);
                }
        } else {
-               kingsun->stats.tx_packets++;
-               kingsun->stats.tx_bytes += skb->len;
+               netdev->stats.tx_packets++;
+               netdev->stats.tx_bytes += skb->len;
 
        }
 
        dev_kfree_skb(skb);
        spin_unlock(&kingsun->lock);
 
-       return ret;
+       return NETDEV_TX_OK;
 }
 
 /* Receive callback function */
@@ -469,12 +466,11 @@ static void ks959_rcv_irq(struct urb *urb)
                         */
                        if (kingsun->rx_variable_xormask != 0) {
                                async_unwrap_char(kingsun->netdev,
-                                                 &kingsun->stats,
+                                                 &kingsun->netdev->stats,
                                                  &kingsun->rx_unwrap_buff,
                                                  bytes[i]);
                        }
                }
-               kingsun->netdev->last_rx = jiffies;
                do_gettimeofday(&kingsun->rx_time);
                kingsun->receiving =
                    (kingsun->rx_unwrap_buff.state != OUTSIDE_FRAME) ? 1 : 0;
@@ -669,15 +665,12 @@ static int ks959_net_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
        return ret;
 }
 
-/*
- * Get device stats (for /proc/net/dev and ifconfig)
- */
-static struct net_device_stats *ks959_net_get_stats(struct net_device *netdev)
-{
-       struct ks959_cb *kingsun = netdev_priv(netdev);
-       return &kingsun->stats;
-}
-
+static const struct net_device_ops ks959_ops = {
+       .ndo_start_xmit = ks959_hard_xmit,
+       .ndo_open       = ks959_net_open,
+       .ndo_stop       = ks959_net_close,
+       .ndo_do_ioctl   = ks959_net_ioctl,
+};
 /*
  * This routine is called by the USB subsystem for each new device
  * in the system. We need to check if the device is ours, and in
@@ -790,11 +783,7 @@ static int ks959_probe(struct usb_interface *intf,
        irda_qos_bits_to_value(&kingsun->qos);
 
        /* Override the network functions we need to use */
-       net->hard_start_xmit = ks959_hard_xmit;
-       net->open = ks959_net_open;
-       net->stop = ks959_net_close;
-       net->get_stats = ks959_net_get_stats;
-       net->do_ioctl = ks959_net_ioctl;
+       net->netdev_ops = &ks959_ops;
 
        ret = register_netdev(net);
        if (ret != 0)