aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/netdevice.h5
-rw-r--r--net/core/dev.c9
-rw-r--r--net/mac80211/main.c8
3 files changed, 7 insertions, 15 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 371ece521e58..14efce33c002 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -905,7 +905,6 @@ struct net_device
905#define to_net_dev(d) container_of(d, struct net_device, dev) 905#define to_net_dev(d) container_of(d, struct net_device, dev)
906 906
907#define NETDEV_ALIGN 32 907#define NETDEV_ALIGN 32
908#define NETDEV_ALIGN_CONST (NETDEV_ALIGN - 1)
909 908
910static inline 909static inline
911struct netdev_queue *netdev_get_tx_queue(const struct net_device *dev, 910struct netdev_queue *netdev_get_tx_queue(const struct net_device *dev,
@@ -976,9 +975,7 @@ static inline bool netdev_uses_trailer_tags(struct net_device *dev)
976 */ 975 */
977static inline void *netdev_priv(const struct net_device *dev) 976static inline void *netdev_priv(const struct net_device *dev)
978{ 977{
979 return (char *)dev + ((sizeof(struct net_device) 978 return (char *)dev + ALIGN(sizeof(struct net_device), NETDEV_ALIGN);
980 + NETDEV_ALIGN_CONST)
981 & ~NETDEV_ALIGN_CONST);
982} 979}
983 980
984/* Set the sysfs physical device reference for the network logical device 981/* Set the sysfs physical device reference for the network logical device
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))
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index 6b7e92eaab47..e37770ced53c 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -735,9 +735,7 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
735 * +-------------------------+ 735 * +-------------------------+
736 * 736 *
737 */ 737 */
738 priv_size = ((sizeof(struct ieee80211_local) + 738 priv_size = ALIGN(sizeof(*local), NETDEV_ALIGN) + priv_data_len;
739 NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST) +
740 priv_data_len;
741 739
742 wiphy = wiphy_new(&mac80211_config_ops, priv_size); 740 wiphy = wiphy_new(&mac80211_config_ops, priv_size);
743 741
@@ -754,9 +752,7 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
754 752
755 local->hw.wiphy = wiphy; 753 local->hw.wiphy = wiphy;
756 754
757 local->hw.priv = (char *)local + 755 local->hw.priv = (char *)local + ALIGN(sizeof(*local), NETDEV_ALIGN);
758 ((sizeof(struct ieee80211_local) +
759 NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST);
760 756
761 BUG_ON(!ops->tx); 757 BUG_ON(!ops->tx);
762 BUG_ON(!ops->start); 758 BUG_ON(!ops->start);