]> rtime.felk.cvut.cz Git - socketcan-devel.git/commitdiff
Update acces to netstats for 2.6.29
authorhartkopp <hartkopp@030b6a49-0b11-0410-94ab-b0dab22257f2>
Thu, 15 Jan 2009 08:30:18 +0000 (08:30 +0000)
committerhartkopp <hartkopp@030b6a49-0b11-0410-94ab-b0dab22257f2>
Thu, 15 Jan 2009 08:30:18 +0000 (08:30 +0000)
---
The successor of dev->get_stats(dev) in 2.6.29 is dev_get_stats(dev)
which provides a const(!) pointer for read only access to the stats.
As the usual current method to access the stats is to reference
dev->stats directly as stats is part of the struce netdevice
since 2.6.23 this patch implements this method of access now.
For kernels < 2.6.23 the netstats are part of the private data
and only this is handled by a separate wrapper now.
The idea was also to get a proper source code after strip-src.

git-svn-id: svn://svn.berlios.de//socketcan/trunk@901 030b6a49-0b11-0410-94ab-b0dab22257f2

kernel/2.6/drivers/net/can/dev.c
kernel/2.6/drivers/net/can/mscan/mscan.c
kernel/2.6/drivers/net/can/old/i82527/i82527.c
kernel/2.6/drivers/net/can/old/sja1000/sja1000.c
kernel/2.6/drivers/net/can/sja1000/sja1000.c
kernel/2.6/drivers/net/can/slcan.c
kernel/2.6/drivers/net/can/softing/softing_main.c
kernel/2.6/include/linux/can/dev.h

index 1c1a96c9e66c6e0c7cfca87f0673c2ab9f1b19fd..b700ce9d5a7d8a48b2abba8f7ac7c244170f82c4 100644 (file)
@@ -233,12 +233,13 @@ int can_set_bittiming(struct net_device *dev)
 EXPORT_SYMBOL(can_set_bittiming);
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
-static struct net_device_stats *can_get_stats(struct net_device *dev)
+struct net_device_stats *can_get_stats(struct net_device *dev)
 {
        struct can_priv *priv = netdev_priv(dev);
 
        return &priv->net_stats;
 }
+EXPORT_SYMBOL(can_get_stats);
 #endif
 
 static void can_setup(struct net_device *dev)
@@ -252,9 +253,6 @@ static void can_setup(struct net_device *dev)
        /* New-style flags. */
        dev->flags = IFF_NOARP;
        dev->features = NETIF_F_NO_CSUM;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
-       dev->get_stats = can_get_stats;
-#endif
 }
 
 /*
@@ -303,7 +301,11 @@ void can_flush_echo_skb(struct net_device *dev)
 {
        struct can_priv *priv = netdev_priv(dev);
 #ifdef FIXME
-       struct net_device_stats *stats = dev->get_stats(dev);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+       struct net_device_stats *stats = can_get_stats(dev);
+#else
+       struct net_device_stats *stats = &dev->stats;
+#endif
 #endif
        int i;
 
@@ -379,7 +381,11 @@ EXPORT_SYMBOL(can_get_echo_skb);
 int can_restart_now(struct net_device *dev)
 {
        struct can_priv *priv = netdev_priv(dev);
-       struct net_device_stats *stats = dev->get_stats(dev);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+       struct net_device_stats *stats = can_get_stats(dev);
+#else
+       struct net_device_stats *stats = &dev->stats;
+#endif
        struct sk_buff *skb;
        struct can_frame *cf;
        int err;
index e1fa5ce7a6c86e35ad476988f1015ac7510f6779..af72e78aa71ebbab8f14d1a7c666204c51704af5 100644 (file)
@@ -345,7 +345,11 @@ static int mscan_rx_poll(struct net_device *dev, int *budget)
        int quota = min(dev->quota, *budget);
 #endif
        struct mscan_regs *regs = (struct mscan_regs *)dev->base_addr;
-       struct net_device_stats *stats = dev->get_stats(dev);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+       struct net_device_stats *stats = can_get_stats(dev);
+#else
+       struct net_device_stats *stats = &dev->stats;
+#endif
        int npackets = 0;
        int ret = 1;
        struct sk_buff *skb;
@@ -495,7 +499,11 @@ static irqreturn_t mscan_isr(int irq, void *dev_id)
        struct net_device *dev = (struct net_device *)dev_id;
        struct mscan_priv *priv = netdev_priv(dev);
        struct mscan_regs *regs = (struct mscan_regs *)dev->base_addr;
-       struct net_device_stats *stats = dev->get_stats(dev);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+       struct net_device_stats *stats = can_get_stats(dev);
+#else
+       struct net_device_stats *stats = &dev->stats;
+#endif
        u8 cantier, cantflg, canrflg;
        irqreturn_t ret = IRQ_NONE;
 
index 77e5a80c84c51c72314ebeff1e2ee08b09e92a2c..6439f892630c07f95efe28bdf8bb435f8e1f3571 100644 (file)
@@ -165,6 +165,16 @@ static struct net_device* can_create_netdev(int dev_num, int hw_regs);
 static int  can_set_drv_name(void);
 int set_reset_mode(struct net_device *dev);
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+static struct net_device_stats *can_get_stats(struct net_device *dev)
+{
+       struct can_priv *priv = netdev_priv(dev);
+
+       /* TODO: read statistics from chip */
+       return &priv->stats;
+}
+#endif
+
 static int i82527_probe_chip(unsigned long base)
 {
        // Check if hardware reset is still inactive OR
@@ -564,7 +574,11 @@ static void chipset_init_trx(struct net_device *dev)
  */
 static int can_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
-       struct net_device_stats *stats = dev->get_stats(dev);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+       struct net_device_stats *stats = can_get_stats(dev);
+#else
+       struct net_device_stats *stats = &dev->stats;
+#endif
        struct can_frame *cf    = (struct can_frame*)skb->data;
        unsigned long base      = dev->base_addr;
        uint8_t dlc;
@@ -637,7 +651,11 @@ static int can_start_xmit(struct sk_buff *skb, struct net_device *dev)
 static void can_tx_timeout(struct net_device *dev)
 {
        struct can_priv *priv = netdev_priv(dev);
-       struct net_device_stats *stats = dev->get_stats(dev);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+       struct net_device_stats *stats = can_get_stats(dev);
+#else
+       struct net_device_stats *stats = &dev->stats;
+#endif
 
        stats->tx_errors++;
 
@@ -719,7 +737,11 @@ static void can_restart_now(struct net_device *dev)
  */
 static void can_rx(struct net_device *dev, int obj)
 {
-       struct net_device_stats *stats = dev->get_stats(dev);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+       struct net_device_stats *stats = can_get_stats(dev);
+#else
+       struct net_device_stats *stats = &dev->stats;
+#endif
        unsigned long base = dev->base_addr;
        struct can_frame *cf;
        struct sk_buff  *skb;
@@ -781,16 +803,6 @@ static void can_rx(struct net_device *dev, int obj)
        stats->rx_bytes += dlc;
 }
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
-static struct net_device_stats *can_get_stats(struct net_device *dev)
-{
-       struct can_priv *priv = netdev_priv(dev);
-
-       /* TODO: read statistics from chip */
-       return &priv->stats;
-}
-#endif
-
 /*
  * I82527 interrupt handler
  */
@@ -802,7 +814,11 @@ static irqreturn_t can_interrupt(int irq, void *dev_id)
 {
        struct net_device *dev  = (struct net_device*)dev_id;
        struct can_priv *priv   = netdev_priv(dev);
-       struct net_device_stats *stats = dev->get_stats(dev);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+       struct net_device_stats *stats = can_get_stats(dev);
+#else
+       struct net_device_stats *stats = &dev->stats;
+#endif
        unsigned long base      = dev->base_addr;
        uint8_t irqreg;
        uint8_t lastIrqreg;
@@ -1068,9 +1084,6 @@ void can_netdev_setup(struct net_device *dev)
        dev->open                       = can_open;
        dev->stop                       = can_close;
        dev->hard_start_xmit            = can_start_xmit;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
-       dev->get_stats                  = can_get_stats;
-#endif
 
        dev->tx_timeout                 = can_tx_timeout;
        dev->watchdog_timeo             = TX_TIMEOUT;
index b729f2af7831fe5bfdadb0c96982bb73a79cb696..98f9cf1b8b48fdf54fe6b7c33686dceb85cd3728 100644 (file)
@@ -198,6 +198,16 @@ static struct net_device* can_create_netdev(int dev_num, int hw_regs);
 static int  can_set_drv_name(void);
 int set_reset_mode(struct net_device *dev);
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+static struct net_device_stats *can_get_stats(struct net_device *dev)
+{
+       struct can_priv *priv = netdev_priv(dev);
+
+       /* TODO: read statistics from chip */
+       return &priv->stats;
+}
+#endif
+
 static int sja1000_probe_chip(unsigned long base)
 {
        if (base && (hw_readreg(base, 0) == 0xFF)) {
@@ -497,7 +507,11 @@ static void chipset_init_trx(struct net_device *dev)
 static int can_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        struct can_priv  *priv  = netdev_priv(dev);
-       struct net_device_stats *stats = dev->get_stats(dev);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+       struct net_device_stats *stats = can_get_stats(dev);
+#else
+       struct net_device_stats *stats = &dev->stats;
+#endif
        struct can_frame *cf    = (struct can_frame*)skb->data;
        unsigned long base      = dev->base_addr;
        uint8_t fi;
@@ -589,7 +603,11 @@ static int can_start_xmit(struct sk_buff *skb, struct net_device *dev)
 static void can_tx_timeout(struct net_device *dev)
 {
        struct can_priv *priv = netdev_priv(dev);
-       struct net_device_stats *stats = dev->get_stats(dev);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+       struct net_device_stats *stats = can_get_stats(dev);
+#else
+       struct net_device_stats *stats = &dev->stats;
+#endif
 
        stats->tx_errors++;
 
@@ -669,7 +687,11 @@ static void can_restart_now(struct net_device *dev)
 
 static void can_rx(struct net_device *dev)
 {
-       struct net_device_stats *stats = dev->get_stats(dev);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+       struct net_device_stats *stats = can_get_stats(dev);
+#else
+       struct net_device_stats *stats = &dev->stats;
+#endif
        unsigned long base = dev->base_addr;
        struct can_frame *cf;
        struct sk_buff  *skb;
@@ -727,16 +749,6 @@ static void can_rx(struct net_device *dev)
        stats->rx_bytes += dlc;
 }
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
-static struct net_device_stats *can_get_stats(struct net_device *dev)
-{
-       struct can_priv *priv = netdev_priv(dev);
-
-       /* TODO: read statistics from chip */
-       return &priv->stats;
-}
-#endif
-
 /*
  * SJA1000 interrupt handler
  */
@@ -748,7 +760,11 @@ static irqreturn_t can_interrupt(int irq, void *dev_id)
 {
        struct net_device *dev  = (struct net_device*)dev_id;
        struct can_priv *priv   = netdev_priv(dev);
-       struct net_device_stats *stats = dev->get_stats(dev);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+       struct net_device_stats *stats = can_get_stats(dev);
+#else
+       struct net_device_stats *stats = &dev->stats;
+#endif
        unsigned long base      = dev->base_addr;
        uint8_t isrc, status, ecc, alc;
        int n = 0;
@@ -1028,9 +1044,6 @@ void can_netdev_setup(struct net_device *dev)
        dev->open                       = can_open;
        dev->stop                       = can_close;
        dev->hard_start_xmit            = can_start_xmit;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
-       dev->get_stats                  = can_get_stats;
-#endif
 
        dev->tx_timeout                 = can_tx_timeout;
        dev->watchdog_timeo             = TX_TIMEOUT;
index 739760053efb1ffe44803644c7152de1f2b15a36..43775f821ef1f249316463d977f8f1a9164860c8 100644 (file)
@@ -361,7 +361,11 @@ static void chipset_init(struct net_device *dev)
 static int sja1000_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        struct sja1000_priv *priv = netdev_priv(dev);
-       struct net_device_stats *stats = dev->get_stats(dev);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+       struct net_device_stats *stats = can_get_stats(dev);
+#else
+       struct net_device_stats *stats = &dev->stats;
+#endif
        struct can_frame *cf = (struct can_frame *)skb->data;
        uint8_t fi;
        uint8_t dlc;
@@ -408,7 +412,11 @@ static int sja1000_start_xmit(struct sk_buff *skb, struct net_device *dev)
 static void sja1000_rx(struct net_device *dev)
 {
        struct sja1000_priv *priv = netdev_priv(dev);
-       struct net_device_stats *stats = dev->get_stats(dev);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+       struct net_device_stats *stats = can_get_stats(dev);
+#else
+       struct net_device_stats *stats = &dev->stats;
+#endif
        struct can_frame *cf;
        struct sk_buff *skb;
        uint8_t fi;
@@ -468,7 +476,11 @@ static int sja1000_err(struct net_device *dev,
                       uint8_t isrc, uint8_t status, int n)
 {
        struct sja1000_priv *priv = netdev_priv(dev);
-       struct net_device_stats *stats = dev->get_stats(dev);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+       struct net_device_stats *stats = can_get_stats(dev);
+#else
+       struct net_device_stats *stats = &dev->stats;
+#endif
        struct can_frame *cf;
        struct sk_buff *skb;
        enum can_state state = priv->can.state;
@@ -609,7 +621,11 @@ irqreturn_t sja1000_interrupt(int irq, void *dev_id)
 {
        struct net_device *dev = (struct net_device *)dev_id;
        struct sja1000_priv *priv = netdev_priv(dev);
-       struct net_device_stats *stats = dev->get_stats(dev);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+       struct net_device_stats *stats = can_get_stats(dev);
+#else
+       struct net_device_stats *stats = &dev->stats;
+#endif
        uint8_t isrc, status;
        int n = 0;
 
index 162002600ebb5fe158041bb8774ba19ae33fd9b3..8ba00eace32501a93223704901a353aa77f37ed6 100644 (file)
@@ -162,6 +162,17 @@ struct slcan {
 
 static struct net_device **slcan_devs;
 
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+/* Netdevice get statistics request */
+static struct net_device_stats *slc_get_stats(struct net_device *dev)
+{
+       struct slcan *sl = netdev_priv(dev);
+
+       return &sl->stats;
+}
+#endif
+
  /************************************************************************
   *                    SLCAN ENCAPSULATION FORMAT                       *
   ************************************************************************/
@@ -219,7 +230,11 @@ static int asc2nibble(char c)
 /* Send one completely decapsulated can_frame to the network layer */
 static void slc_bump(struct slcan *sl)
 {
-       struct net_device_stats *stats = sl->dev->get_stats(sl->dev);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+       struct net_device_stats *stats = slc_get_stats(sl->dev);
+#else
+       struct net_device_stats *stats = &sl->dev->stats;
+#endif
        struct sk_buff *skb;
        struct can_frame cf;
        int i, dlc_pos, tmp;
@@ -288,7 +303,11 @@ static void slc_bump(struct slcan *sl)
 /* parse tty input stream */
 static void slcan_unesc(struct slcan *sl, unsigned char s)
 {
-       struct net_device_stats *stats = sl->dev->get_stats(sl->dev);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+       struct net_device_stats *stats = slc_get_stats(sl->dev);
+#else
+       struct net_device_stats *stats = &sl->dev->stats;
+#endif
 
        if ((s == '\r') || (s == '\a')) { /* CR or BEL ends the pdu */
                if (!test_and_clear_bit(SLF_ERROR, &sl->flags) &&
@@ -316,7 +335,11 @@ static void slcan_unesc(struct slcan *sl, unsigned char s)
 /* Encapsulate one can_frame and stuff into a TTY queue. */
 static void slc_encaps(struct slcan *sl, struct can_frame *cf)
 {
-       struct net_device_stats *stats = sl->dev->get_stats(sl->dev);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+       struct net_device_stats *stats = slc_get_stats(sl->dev);
+#else
+       struct net_device_stats *stats = &sl->dev->stats;
+#endif
        int actual, idx, i;
        char cmd;
 
@@ -371,7 +394,11 @@ static void slcan_write_wakeup(struct tty_struct *tty)
 {
        int actual;
        struct slcan *sl = (struct slcan *) tty->disc_data;
-       struct net_device_stats *stats = sl->dev->get_stats(sl->dev);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+       struct net_device_stats *stats = slc_get_stats(sl->dev);
+#else
+       struct net_device_stats *stats = &sl->dev->stats;
+#endif
 
        /* First make sure we're connected. */
        if (!sl || sl->magic != SLCAN_MAGIC || !netif_running(sl->dev))
@@ -495,25 +522,12 @@ static int slc_open(struct net_device *dev)
        return 0;
 }
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
-/* Netdevice get statistics request */
-static struct net_device_stats *slc_get_stats(struct net_device *dev)
-{
-       struct slcan *sl = netdev_priv(dev);
-
-       return (&sl->stats);
-}
-#endif
-
 /* Netdevice register callback */
 static void slc_setup(struct net_device *dev)
 {
        dev->open               = slc_open;
        dev->destructor         = free_netdev;
        dev->stop               = slc_close;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
-       dev->get_stats          = slc_get_stats;
-#endif
        dev->hard_start_xmit    = slc_xmit;
 
        dev->hard_header_len    = 0;
@@ -556,7 +570,11 @@ static void slcan_receive_buf(struct tty_struct *tty,
                              const unsigned char *cp, char *fp, int count)
 {
        struct slcan *sl = (struct slcan *) tty->disc_data;
-       struct net_device_stats *stats = sl->dev->get_stats(sl->dev);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+       struct net_device_stats *stats = slc_get_stats(sl->dev);
+#else
+       struct net_device_stats *stats = &sl->dev->stats;
+#endif
 
        if (!sl || sl->magic != SLCAN_MAGIC ||
            !netif_running(sl->dev))
index a271bae79bc213d37ff1338536b3e9e9d10dd0b1..19ec72e5dbe58581e67d5e5ed10cfd89466b1619 100644 (file)
@@ -209,7 +209,11 @@ static int softing_dev_svc_once(struct softing *card)
                if (cmd & CMD_BUS2)
                        bus = card->bus[1];
 
-               stats = bus->netdev->get_stats(bus->netdev);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+               stats = can_get_stats(bus->netdev);
+#else
+               stats = &bus->netdev->stats;
+#endif
                if (cmd & CMD_ERR) {
                        u8 can_state;
                        u8 state;
index 305c6e05cec338362784e47140cc6a810ede426c..5db4c2e8dce7e2e7336e47513127356815aa60ba 100644 (file)
@@ -127,6 +127,10 @@ struct can_priv {
 #define IFF_ECHO IFF_LOOPBACK
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+struct net_device_stats *can_get_stats(struct net_device *dev);
+#endif
+
 struct net_device *alloc_candev(int sizeof_priv);
 void free_candev(struct net_device *dev);