diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2009-05-27 00:42:37 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-05-27 18:47:06 -0400 |
commit | 1ce8e7b57b3a4527ef83da1c5c7bd8a6b9d87b56 (patch) | |
tree | 095536a47e40fdb621c1f959637fa63f57a4ccf2 /net/core/dev.c | |
parent | 0bb32417ff0f6ac385e4eec3ef6641950bbb3694 (diff) |
net: ALIGN/PTR_ALIGN cleanup in alloc_netdev_mq()/netdev_priv()
Use ALIGN() and PTR_ALIGN() macros instead of handcoding them.
Get rid of NETDEV_ALIGN_CONST ugly define
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/dev.c')
-rw-r--r-- | net/core/dev.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index ed4550fd9ece..32ceee17896e 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -4988,18 +4988,18 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name, | |||
4988 | struct netdev_queue *tx; | 4988 | struct netdev_queue *tx; |
4989 | struct net_device *dev; | 4989 | struct net_device *dev; |
4990 | size_t alloc_size; | 4990 | size_t alloc_size; |
4991 | void *p; | 4991 | struct net_device *p; |
4992 | 4992 | ||
4993 | BUG_ON(strlen(name) >= sizeof(dev->name)); | 4993 | BUG_ON(strlen(name) >= sizeof(dev->name)); |
4994 | 4994 | ||
4995 | alloc_size = sizeof(struct net_device); | 4995 | alloc_size = sizeof(struct net_device); |
4996 | if (sizeof_priv) { | 4996 | if (sizeof_priv) { |
4997 | /* ensure 32-byte alignment of private area */ | 4997 | /* ensure 32-byte alignment of private area */ |
4998 | alloc_size = (alloc_size + NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST; | 4998 | alloc_size = ALIGN(alloc_size, NETDEV_ALIGN); |
4999 | alloc_size += sizeof_priv; | 4999 | alloc_size += sizeof_priv; |
5000 | } | 5000 | } |
5001 | /* ensure 32-byte alignment of whole construct */ | 5001 | /* ensure 32-byte alignment of whole construct */ |
5002 | alloc_size += NETDEV_ALIGN_CONST; | 5002 | alloc_size += NETDEV_ALIGN - 1; |
5003 | 5003 | ||
5004 | p = kzalloc(alloc_size, GFP_KERNEL); | 5004 | p = kzalloc(alloc_size, GFP_KERNEL); |
5005 | if (!p) { | 5005 | if (!p) { |
@@ -5014,8 +5014,7 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name, | |||
5014 | goto free_p; | 5014 | goto free_p; |
5015 | } | 5015 | } |
5016 | 5016 | ||
5017 | dev = (struct net_device *) | 5017 | dev = PTR_ALIGN(p, NETDEV_ALIGN); |
5018 | (((long)p + NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST); | ||
5019 | dev->padded = (char *)dev - (char *)p; | 5018 | dev->padded = (char *)dev - (char *)p; |
5020 | 5019 | ||
5021 | if (dev_addr_init(dev)) | 5020 | if (dev_addr_init(dev)) |