From patchwork Mon Jul 5 12:14:09 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kulikov Vasiliy X-Patchwork-Id: 57894 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4C8F4B6F19 for ; Mon, 5 Jul 2010 22:16:32 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758473Ab0GEMOU (ORCPT ); Mon, 5 Jul 2010 08:14:20 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:52064 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758560Ab0GEMOR (ORCPT ); Mon, 5 Jul 2010 08:14:17 -0400 Received: by mail-wy0-f174.google.com with SMTP id 23so2387763wyf.19 for ; Mon, 05 Jul 2010 05:14:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=GqnVSEYUlPPJCbB2VaYP74FczaZRXJVzYTVouetSC1w=; b=EnqWXGCxKYKJHgNgUNcOtsO56JPflzYPQv2V4GCx+k7WuXZ5LGyA3pIwMPSfqRVDEy FFMP+YAILU8vDCVWOn2JrgrKLoJDMMaIpctckW61KzjGAt6CFxgT2Tdj949bNPpVoIBp igjzO1qK4YnbcorB8woVGavCA1qCkH+c+gzw0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=wpTyDcaCK1Hjnx9oyuY2qfWyLjVi5l3v3SjFXz1ny0UWKYxVH9W1iiArxodBn3BlGO IrD+UIkrH4jnIp6gsVmnAwMO6mRq9UIcb+xLks/sVsaVZ9zSrK1OAV3C6QqeYjvZLdcC UGxOnSIGkYR7xoRwue04yZ0jE0IbboNz2ky3s= Received: by 10.213.108.69 with SMTP id e5mr2025018ebp.39.1278332053985; Mon, 05 Jul 2010 05:14:13 -0700 (PDT) Received: from localhost (ppp85-140-163-91.pppoe.mtu-net.ru [85.140.163.91]) by mx.google.com with ESMTPS id z55sm34780699eeh.15.2010.07.05.05.14.12 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 05 Jul 2010 05:14:13 -0700 (PDT) From: Kulikov Vasiliy To: Kernel Janitors Cc: "David S. Miller" , Joe Perches , Eric Dumazet , Patrick McHardy , Tejun Heo , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] mac89x0: Use the instance of net_device_stats from net_device. Date: Mon, 5 Jul 2010 16:14:09 +0400 Message-Id: <1278332051-17760-1-git-send-email-segooon@gmail.com> X-Mailer: git-send-email 1.7.0.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Since net_device has an instance of net_device_stats, we can remove the instance of this from the adapter structure. Signed-off-by: Kulikov Vasiliy --- drivers/net/mac89x0.c | 52 +++++++++++++++++++++++++++--------------------- 1 files changed, 29 insertions(+), 23 deletions(-) diff --git a/drivers/net/mac89x0.c b/drivers/net/mac89x0.c index 69fa4ef..669b317 100644 --- a/drivers/net/mac89x0.c +++ b/drivers/net/mac89x0.c @@ -110,7 +110,6 @@ static unsigned int net_debug = NET_DEBUG; /* Information that need to be kept for each board. */ struct net_local { - struct net_device_stats stats; int chip_type; /* one of: CS8900, CS8920, CS8920M */ char chip_revision; /* revision letter of the chip ('A'...) */ int send_cmd; /* the propercommand used to send a packet. */ @@ -444,13 +443,18 @@ static irqreturn_t net_interrupt(int irq, void *dev_id) net_rx(dev); break; case ISQ_TRANSMITTER_EVENT: - lp->stats.tx_packets++; + dev->stats.tx_packets++; netif_wake_queue(dev); - if ((status & TX_OK) == 0) lp->stats.tx_errors++; - if (status & TX_LOST_CRS) lp->stats.tx_carrier_errors++; - if (status & TX_SQE_ERROR) lp->stats.tx_heartbeat_errors++; - if (status & TX_LATE_COL) lp->stats.tx_window_errors++; - if (status & TX_16_COL) lp->stats.tx_aborted_errors++; + if ((status & TX_OK) == 0) + dev->stats.tx_errors++; + if (status & TX_LOST_CRS) + dev->stats.tx_carrier_errors++; + if (status & TX_SQE_ERROR) + dev->stats.tx_heartbeat_errors++; + if (status & TX_LATE_COL) + dev->stats.tx_window_errors++; + if (status & TX_16_COL) + dev->stats.tx_aborted_errors++; break; case ISQ_BUFFER_EVENT: if (status & READY_FOR_TX) { @@ -469,10 +473,10 @@ static irqreturn_t net_interrupt(int irq, void *dev_id) } break; case ISQ_RX_MISS_EVENT: - lp->stats.rx_missed_errors += (status >>6); + dev->stats.rx_missed_errors += (status >> 6); break; case ISQ_TX_COL_EVENT: - lp->stats.collisions += (status >>6); + dev->stats.collisions += (status >> 6); break; } } @@ -483,19 +487,22 @@ static irqreturn_t net_interrupt(int irq, void *dev_id) static void net_rx(struct net_device *dev) { - struct net_local *lp = netdev_priv(dev); struct sk_buff *skb; int status, length; status = readreg(dev, PP_RxStatus); if ((status & RX_OK) == 0) { - lp->stats.rx_errors++; - if (status & RX_RUNT) lp->stats.rx_length_errors++; - if (status & RX_EXTRA_DATA) lp->stats.rx_length_errors++; - if (status & RX_CRC_ERROR) if (!(status & (RX_EXTRA_DATA|RX_RUNT))) + dev->stats.rx_errors++; + if (status & RX_RUNT) + dev->stats.rx_length_errors++; + if (status & RX_EXTRA_DATA) + dev->stats.rx_length_errors++; + if ((status & RX_CRC_ERROR) && + !(status & (RX_EXTRA_DATA|RX_RUNT))) /* per str 172 */ - lp->stats.rx_crc_errors++; - if (status & RX_DRIBBLE) lp->stats.rx_frame_errors++; + dev->stats.rx_crc_errors++; + if (status & RX_DRIBBLE) + dev->stats.rx_frame_errors++; return; } @@ -504,7 +511,7 @@ net_rx(struct net_device *dev) skb = alloc_skb(length, GFP_ATOMIC); if (skb == NULL) { printk("%s: Memory squeeze, dropping packet.\n", dev->name); - lp->stats.rx_dropped++; + dev->stats.rx_dropped++; return; } skb_put(skb, length); @@ -519,8 +526,8 @@ net_rx(struct net_device *dev) skb->protocol=eth_type_trans(skb,dev); netif_rx(skb); - lp->stats.rx_packets++; - lp->stats.rx_bytes += length; + dev->stats.rx_packets++; + dev->stats.rx_bytes += length; } /* The inverse routine to net_open(). */ @@ -548,16 +555,15 @@ net_close(struct net_device *dev) static struct net_device_stats * net_get_stats(struct net_device *dev) { - struct net_local *lp = netdev_priv(dev); unsigned long flags; local_irq_save(flags); /* Update the statistics from the device registers. */ - lp->stats.rx_missed_errors += (readreg(dev, PP_RxMiss) >> 6); - lp->stats.collisions += (readreg(dev, PP_TxCol) >> 6); + dev->stats.rx_missed_errors += (readreg(dev, PP_RxMiss) >> 6); + dev->stats.collisions += (readreg(dev, PP_TxCol) >> 6); local_irq_restore(flags); - return &lp->stats; + return &dev->stats; } static void set_multicast_list(struct net_device *dev)