From f86225ee432e7d0ca8bd6cca78b0a48af7ef2d25 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Tue, 6 Apr 2004 00:28:52 -0400 Subject: [PATCH] [PATCH] remove magic '31' for netdev priv. alignment [resend/rediff] // linux-2.6.5 // remove magic number of '31' from net_device and private alignment; --- drivers/net/net_init.c | 8 +++++--- include/linux/netdevice.h | 7 ++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/net/net_init.c b/drivers/net/net_init.c index 718108487c1e4..854bc2b70ceed 100644 --- a/drivers/net/net_init.c +++ b/drivers/net/net_init.c @@ -79,8 +79,9 @@ struct net_device *alloc_netdev(int sizeof_priv, const char *mask, /* ensure 32-byte alignment of both the device and private area */ - alloc_size = (sizeof(struct net_device) + 31) & ~31; - alloc_size += sizeof_priv + 31; + alloc_size = (sizeof(struct net_device) + NETDEV_ALIGN_CONST) + & ~NETDEV_ALIGN_CONST; + alloc_size += sizeof_priv + NETDEV_ALIGN_CONST; p = kmalloc (alloc_size, GFP_KERNEL); if (!p) { @@ -90,7 +91,8 @@ struct net_device *alloc_netdev(int sizeof_priv, const char *mask, memset(p, 0, alloc_size); - dev = (struct net_device *)(((long)p + 31) & ~31); + dev = (struct net_device *)(((long)p + NETDEV_ALIGN_CONST) + & ~NETDEV_ALIGN_CONST); dev->padded = (char *)dev - (char *)p; if (sizeof_priv) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 378777e11e94f..5c5a551fe630a 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -484,9 +484,14 @@ struct net_device int padded; }; +#define NETDEV_ALIGN 32 +#define NETDEV_ALIGN_CONST (NETDEV_ALIGN - 1) + static inline void *netdev_priv(struct net_device *dev) { - return (char *)dev + ((sizeof(struct net_device) + 31) & ~31); + return (char *)dev + ((sizeof(struct net_device) + + NETDEV_ALIGN_CONST) + & ~NETDEV_ALIGN_CONST); } #define SET_MODULE_OWNER(dev) do { } while (0) -- 2.53.0