netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Krzysztof Halasa <khc@pm.waw.pl>
To: <netdev@vger.kernel.org>
Subject: netdev->priv and netdev_priv(dev)
Date: Tue, 29 Jan 2008 21:10:00 +0100	[thread overview]
Message-ID: <m3tzkwv1ev.fsf@maximus.localdomain> (raw)

A commit few months ago introduced a change:

--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
 
 static inline void *netdev_priv(const struct net_device *dev)
 {
-       return (char *)dev + ((sizeof(struct net_device)
-                                       + NETDEV_ALIGN_CONST)
-                               & ~NETDEV_ALIGN_CONST);
+       return dev->priv;
 }
 
This change caused some problems for drivers which used
netdev_priv(dev) and dev->priv for different purposes.


The following patch restores previous behaviour.

Signed-off-by: Krzysztof Halasa <khc@pm.waw.pl>

--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -584,7 +584,10 @@ struct net_device
 
 static inline void *netdev_priv(const struct net_device *dev)
 {
-	return dev->priv;
+	return (char *)dev + ((sizeof(struct net_device) +
+			       sizeof(struct net_device_subqueue) *
+			       (dev->egress_subqueue_count - 1) +
+			       NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST);
 }
 
 #define SET_MODULE_OWNER(dev) do { } while (0)
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3693,13 +3693,8 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name,
 		(((long)p + NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST);
 	dev->padded = (char *)dev - (char *)p;
 
-	if (sizeof_priv) {
-		dev->priv = ((char *)dev +
-			     ((sizeof(struct net_device) +
-			       (sizeof(struct net_device_subqueue) *
-				(queue_count - 1)) + NETDEV_ALIGN_CONST)
-			      & ~NETDEV_ALIGN_CONST));
-	}
+	if (sizeof_priv)
+		dev->priv = netdev_priv(dev);
 
 	dev->egress_subqueue_count = queue_count;
 

             reply	other threads:[~2008-01-29 20:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-29 20:10 Krzysztof Halasa [this message]
2008-01-29 20:42 ` netdev->priv and netdev_priv(dev) Stephen Hemminger
2008-01-29 21:52   ` Krzysztof Halasa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3tzkwv1ev.fsf@maximus.localdomain \
    --to=khc@pm.waw.pl \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).