Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

3c505: use netstats in net_device structure

Use net_device_stats from net_device structure instead of local.
No need to memset it to 0, because it is allocated by kzalloc.

Signed-off-by: Paulius Zaleckas <paulius.zaleckas@teltonika.lt>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>

authored by

Paulius Zaleckas and committed by
Jeff Garzik
ba0f6cae dd32f7ef

+14 -17
+14 -16
drivers/net/3c505.c
··· 670 670 memcpy(adapter->current_dma.target, adapter->dma_buffer, adapter->current_dma.length); 671 671 } 672 672 skb->protocol = eth_type_trans(skb,dev); 673 - adapter->stats.rx_bytes += skb->len; 673 + dev->stats.rx_bytes += skb->len; 674 674 netif_rx(skb); 675 675 dev->last_rx = jiffies; 676 676 } ··· 773 773 * received board statistics 774 774 */ 775 775 case CMD_NETWORK_STATISTICS_RESPONSE: 776 - adapter->stats.rx_packets += adapter->irx_pcb.data.netstat.tot_recv; 777 - adapter->stats.tx_packets += adapter->irx_pcb.data.netstat.tot_xmit; 778 - adapter->stats.rx_crc_errors += adapter->irx_pcb.data.netstat.err_CRC; 779 - adapter->stats.rx_frame_errors += adapter->irx_pcb.data.netstat.err_align; 780 - adapter->stats.rx_fifo_errors += adapter->irx_pcb.data.netstat.err_ovrrun; 781 - adapter->stats.rx_over_errors += adapter->irx_pcb.data.netstat.err_res; 776 + dev->stats.rx_packets += adapter->irx_pcb.data.netstat.tot_recv; 777 + dev->stats.tx_packets += adapter->irx_pcb.data.netstat.tot_xmit; 778 + dev->stats.rx_crc_errors += adapter->irx_pcb.data.netstat.err_CRC; 779 + dev->stats.rx_frame_errors += adapter->irx_pcb.data.netstat.err_align; 780 + dev->stats.rx_fifo_errors += adapter->irx_pcb.data.netstat.err_ovrrun; 781 + dev->stats.rx_over_errors += adapter->irx_pcb.data.netstat.err_res; 782 782 adapter->got[CMD_NETWORK_STATISTICS] = 1; 783 783 if (elp_debug >= 3) 784 784 printk(KERN_DEBUG "%s: interrupt - statistics response received\n", dev->name); ··· 794 794 break; 795 795 switch (adapter->irx_pcb.data.xmit_resp.c_stat) { 796 796 case 0xffff: 797 - adapter->stats.tx_aborted_errors++; 797 + dev->stats.tx_aborted_errors++; 798 798 printk(KERN_INFO "%s: transmit timed out, network cable problem?\n", dev->name); 799 799 break; 800 800 case 0xfffe: 801 - adapter->stats.tx_fifo_errors++; 801 + dev->stats.tx_fifo_errors++; 802 802 printk(KERN_INFO "%s: transmit timed out, FIFO underrun\n", dev->name); 803 803 break; 804 804 } ··· 986 986 return false; 987 987 } 988 988 989 - adapter->stats.tx_bytes += nlen; 989 + dev->stats.tx_bytes += nlen; 990 990 991 991 /* 992 992 * send the adapter a transmit packet command. Ignore segment and offset ··· 1041 1041 1042 1042 static void elp_timeout(struct net_device *dev) 1043 1043 { 1044 - elp_device *adapter = dev->priv; 1045 1044 int stat; 1046 1045 1047 1046 stat = inb_status(dev->base_addr); ··· 1048 1049 if (elp_debug >= 1) 1049 1050 printk(KERN_DEBUG "%s: status %#02x\n", dev->name, stat); 1050 1051 dev->trans_start = jiffies; 1051 - adapter->stats.tx_dropped++; 1052 + dev->stats.tx_dropped++; 1052 1053 netif_wake_queue(dev); 1053 1054 } 1054 1055 ··· 1112 1113 /* If the device is closed, just return the latest stats we have, 1113 1114 - we cannot ask from the adapter without interrupts */ 1114 1115 if (!netif_running(dev)) 1115 - return &adapter->stats; 1116 + return &dev->stats; 1116 1117 1117 1118 /* send a get statistics command to the board */ 1118 1119 adapter->tx_pcb.command = CMD_NETWORK_STATISTICS; ··· 1125 1126 while (adapter->got[CMD_NETWORK_STATISTICS] == 0 && time_before(jiffies, timeout)); 1126 1127 if (time_after_eq(jiffies, timeout)) { 1127 1128 TIMEOUT_MSG(__LINE__); 1128 - return &adapter->stats; 1129 + return &dev->stats; 1129 1130 } 1130 1131 } 1131 1132 1132 1133 /* statistics are now up to date */ 1133 - return &adapter->stats; 1134 + return &dev->stats; 1134 1135 } 1135 1136 1136 1137 ··· 1570 1571 dev->set_multicast_list = elp_set_mc_list; /* local */ 1571 1572 dev->ethtool_ops = &netdev_ethtool_ops; /* local */ 1572 1573 1573 - memset(&(adapter->stats), 0, sizeof(struct net_device_stats)); 1574 1574 dev->mem_start = dev->mem_end = 0; 1575 1575 1576 1576 err = register_netdev(dev);
-1
drivers/net/3c505.h
··· 264 264 pcb_struct rx_pcb; /* PCB for foreground receiving */ 265 265 pcb_struct itx_pcb; /* PCB for background sending */ 266 266 pcb_struct irx_pcb; /* PCB for background receiving */ 267 - struct net_device_stats stats; 268 267 269 268 void *dma_buffer; 270 269