netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* netdev->priv and netdev_priv(dev)
@ 2008-01-29 20:10 Krzysztof Halasa
  2008-01-29 20:42 ` Stephen Hemminger
  0 siblings, 1 reply; 3+ messages in thread
From: Krzysztof Halasa @ 2008-01-29 20:10 UTC (permalink / raw)
  To: netdev

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;
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-01-29 21:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-29 20:10 netdev->priv and netdev_priv(dev) Krzysztof Halasa
2008-01-29 20:42 ` Stephen Hemminger
2008-01-29 21:52   ` Krzysztof Halasa

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).