From patchwork Fri Sep 24 09:51:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 65633 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 D899DB70F1 for ; Fri, 24 Sep 2010 19:52:02 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752459Ab0IXJv4 (ORCPT ); Fri, 24 Sep 2010 05:51:56 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:39225 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752230Ab0IXJv4 (ORCPT ); Fri, 24 Sep 2010 05:51:56 -0400 Received: by fxm3 with SMTP id 3so602269fxm.19 for ; Fri, 24 Sep 2010 02:51:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:cc :content-type:date:message-id:mime-version:x-mailer :content-transfer-encoding; bh=lSDJC4xazlT5B0zdUxyIo4kdh3192tlsCSXYj1jUXrE=; b=hMufXhHFPYzVt+ERqV8A0SZNC5cugA6y7Ze8uSY6SNMg5Ibr4cQGUUZqA9cVUQkOM6 4j/dP5vVsgeYDPLBiEV1VTBGLTzMBYHqVzNbyjAoaTnS4mdlzj6MW/x5KZClBXjaj+fP da5Eel/wkeQfW95QI01PNWZUby6lhVaE9jzwM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; b=p+lFn3Z99c5dlbDEqE2iLvVcTIgxnYT3/tIdX2s8zAFovXsZvP8UiOdzdysqgDO0CH 1XDZGLpaZQ1uRCSjHNI8nCgHwF27yVzxVhs6ZyTq0Gb0d572nbf+rYaQ4spgMktDdFHG i77tROt70kH1f/9j9akE0YcWZmvL+DdpkMwYM= Received: by 10.223.116.68 with SMTP id l4mr3198439faq.98.1285321914719; Fri, 24 Sep 2010 02:51:54 -0700 (PDT) Received: from [10.150.51.212] (gw0.net.jmsp.net [212.23.165.14]) by mx.google.com with ESMTPS id b9sm856897faq.7.2010.09.24.02.51.53 (version=SSLv3 cipher=RC4-MD5); Fri, 24 Sep 2010 02:51:53 -0700 (PDT) Subject: [PATCH net-next-2.6] net: loopback driver cleanup From: Eric Dumazet To: David Miller Cc: netdev Date: Fri, 24 Sep 2010 11:51:51 +0200 Message-ID: <1285321911.2503.48.camel@edumazet-laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org loopback driver uses dev->ml_priv to store its percpu stats pointer. It uses ugly casts "(void __percpu __force *)" to shut up sparse complains. Define an union to better document we use ml_priv in loopback driver and define a lstats field with appropriate types. Signed-off-by: Eric Dumazet --- drivers/net/loopback.c | 20 +++++--------------- include/linux/netdevice.h | 6 ++++-- 2 files changed, 9 insertions(+), 17 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c index 9a09967..4b0e30b 100644 --- a/drivers/net/loopback.c +++ b/drivers/net/loopback.c @@ -74,7 +74,6 @@ struct pcpu_lstats { static netdev_tx_t loopback_xmit(struct sk_buff *skb, struct net_device *dev) { - struct pcpu_lstats __percpu *pcpu_lstats; struct pcpu_lstats *lb_stats; int len; @@ -83,8 +82,7 @@ static netdev_tx_t loopback_xmit(struct sk_buff *skb, skb->protocol = eth_type_trans(skb, dev); /* it's OK to use per_cpu_ptr() because BHs are off */ - pcpu_lstats = (void __percpu __force *)dev->ml_priv; - lb_stats = this_cpu_ptr(pcpu_lstats); + lb_stats = this_cpu_ptr(dev->lstats); len = skb->len; if (likely(netif_rx(skb) == NET_RX_SUCCESS)) { @@ -101,19 +99,17 @@ static netdev_tx_t loopback_xmit(struct sk_buff *skb, static struct rtnl_link_stats64 *loopback_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) { - const struct pcpu_lstats __percpu *pcpu_lstats; u64 bytes = 0; u64 packets = 0; u64 drops = 0; int i; - pcpu_lstats = (void __percpu __force *)dev->ml_priv; for_each_possible_cpu(i) { const struct pcpu_lstats *lb_stats; u64 tbytes, tpackets; unsigned int start; - lb_stats = per_cpu_ptr(pcpu_lstats, i); + lb_stats = per_cpu_ptr(dev->lstats, i); do { start = u64_stats_fetch_begin(&lb_stats->syncp); tbytes = lb_stats->bytes; @@ -147,22 +143,16 @@ static const struct ethtool_ops loopback_ethtool_ops = { static int loopback_dev_init(struct net_device *dev) { - struct pcpu_lstats __percpu *lstats; - - lstats = alloc_percpu(struct pcpu_lstats); - if (!lstats) + dev->lstats = alloc_percpu(struct pcpu_lstats); + if (!dev->lstats) return -ENOMEM; - dev->ml_priv = (void __force *)lstats; return 0; } static void loopback_dev_free(struct net_device *dev) { - struct pcpu_lstats __percpu *lstats = - (void __percpu __force *)dev->ml_priv; - - free_percpu(lstats); + free_percpu(dev->lstats); free_netdev(dev); } diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index f7f1302..65ae79c 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1050,8 +1050,10 @@ struct net_device { #endif /* mid-layer private */ - void *ml_priv; - + union { + void *ml_priv; + struct pcpu_lstats __percpu *lstats; /* loopback stats */ + }; /* GARP */ struct garp_port *garp_port;