From: Andy Shevchenko Date: Mon, 24 Mar 2025 14:39:29 +0000 (+0200) Subject: net: phy: Introduce PHY_ID_SIZE — minimum size for PHY ID string X-Git-Tag: v6.15-rc1~160^2~2^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2c5ac026fd1421cf6a78770b48570b2563ef40b7;p=thirdparty%2Flinux.git net: phy: Introduce PHY_ID_SIZE — minimum size for PHY ID string The PHY_ID_FMT defines the format specifier "%s:%02x" to form the PHY ID string, where the maximum of the first part is defined in MII_BUS_ID_SIZE, including NUL terminator, and the second part is implied to be 3 as the maximum address is limited to 32, meaning that 2 hex digits is more than enough, plus ':' (colon) delimiter. However, some drivers, which are using PHY_ID_FMT, customise buffer size and do that incorrectly. Introduce a new constant PHY_ID_SIZE that makes the minimum required size explicit, so drivers are encouraged to use it. Suggested-by: "Russell King (Oracle)" Signed-off-by: Andy Shevchenko Reviewed-by: Russell King (Oracle) Link: https://patch.msgid.link/20250324144751.1271761-2-andriy.shevchenko@linux.intel.com Signed-off-by: Jakub Kicinski --- diff --git a/include/linux/phy.h b/include/linux/phy.h index bfdbdc5389107..a2bfae80c4497 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -292,6 +292,7 @@ static inline long rgmii_clock(int speed) /* Used when trying to connect to a specific phy (mii bus id:phy device id) */ #define PHY_ID_FMT "%s:%02x" +#define PHY_ID_SIZE (MII_BUS_ID_SIZE + 3) #define MII_BUS_ID_SIZE 61