The txgbe driver currently defines DECLARE_PHY_INTERFACE_MASK_ZERO() locally, but incorrectly uses PHY_INTERFACE_MODE_MAX as the array length instead of BITS_TO_LONGS(). This allocates significantly more space on the stack than necessary. Move the macro to include/linux/phy.h and build it on top of DECLARE_PHY_INTERFACE_MASK() to correctly size the bitmap, while still initializing the stack variable to zero. Signed-off-by: Coia Prant Cc: Jiawen Wu --- drivers/net/ethernet/wangxun/txgbe/txgbe_type.h | 3 --- include/linux/phy.h | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_type.h b/drivers/net/ethernet/wangxun/txgbe/txgbe_type.h index 757d1ce8d3ad..8071464c7b90 100644 --- a/drivers/net/ethernet/wangxun/txgbe/txgbe_type.h +++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_type.h @@ -315,9 +315,6 @@ void txgbe_up(struct wx *wx); int txgbe_setup_tc(struct net_device *dev, u8 tc); void txgbe_do_reset(struct net_device *netdev, bool reinit); -#define DECLARE_PHY_INTERFACE_MASK_ZERO(name) \ - unsigned long name[PHY_INTERFACE_MODE_MAX] = { 0, } - #define TXGBE_LINK_SPEED_UNKNOWN 0 #define TXGBE_LINK_SPEED_10GB_FULL 4 #define TXGBE_LINK_SPEED_25GB_FULL 0x10 diff --git a/include/linux/phy.h b/include/linux/phy.h index 21afc2082b17..43aba23109fa 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -159,6 +159,9 @@ typedef enum { #define DECLARE_PHY_INTERFACE_MASK(name) \ DECLARE_BITMAP(name, PHY_INTERFACE_MODE_MAX) +#define DECLARE_PHY_INTERFACE_MASK_ZERO(name) \ + DECLARE_PHY_INTERFACE_MASK(name) = { 0, } + static inline void phy_interface_zero(unsigned long *intf) { bitmap_zero(intf, PHY_INTERFACE_MODE_MAX); -- 2.47.3