Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: phy: introduce phy_id_compare_vendor() PHY ID helper

Introduce phy_id_compare_vendor() PHY ID helper to compare a PHY ID with
the PHY ID Vendor using the generic PHY ID Vendor mask.

While at it also rework the PHY_ID_MATCH macro and move the mask to
dedicated define so that PHY driver can make use of the mask if needed.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20250823134431.4854-1-ansuelsmth@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Christian Marangi and committed by
Jakub Kicinski
1abe21ef 3c149179

+20 -3
+20 -3
include/linux/phy.h
··· 1268 1268 #define to_phy_driver(d) container_of_const(to_mdio_common_driver(d), \ 1269 1269 struct phy_driver, mdiodrv) 1270 1270 1271 - #define PHY_ID_MATCH_EXACT(id) .phy_id = (id), .phy_id_mask = GENMASK(31, 0) 1272 - #define PHY_ID_MATCH_MODEL(id) .phy_id = (id), .phy_id_mask = GENMASK(31, 4) 1273 - #define PHY_ID_MATCH_VENDOR(id) .phy_id = (id), .phy_id_mask = GENMASK(31, 10) 1271 + #define PHY_ID_MATCH_EXTACT_MASK GENMASK(31, 0) 1272 + #define PHY_ID_MATCH_MODEL_MASK GENMASK(31, 4) 1273 + #define PHY_ID_MATCH_VENDOR_MASK GENMASK(31, 10) 1274 + 1275 + #define PHY_ID_MATCH_EXACT(id) .phy_id = (id), .phy_id_mask = PHY_ID_MATCH_EXTACT_MASK 1276 + #define PHY_ID_MATCH_MODEL(id) .phy_id = (id), .phy_id_mask = PHY_ID_MATCH_MODEL_MASK 1277 + #define PHY_ID_MATCH_VENDOR(id) .phy_id = (id), .phy_id_mask = PHY_ID_MATCH_VENDOR_MASK 1274 1278 1275 1279 /** 1276 1280 * phy_id_compare - compare @id1 with @id2 taking account of @mask ··· 1288 1284 static inline bool phy_id_compare(u32 id1, u32 id2, u32 mask) 1289 1285 { 1290 1286 return !((id1 ^ id2) & mask); 1287 + } 1288 + 1289 + /** 1290 + * phy_id_compare_vendor - compare @id with @vendor mask 1291 + * @id: PHY ID 1292 + * @vendor_mask: PHY Vendor mask 1293 + * 1294 + * Return: true if the bits from @id match @vendor using the 1295 + * generic PHY Vendor mask. 1296 + */ 1297 + static inline bool phy_id_compare_vendor(u32 id, u32 vendor_mask) 1298 + { 1299 + return phy_id_compare(id, vendor_mask, PHY_ID_MATCH_VENDOR_MASK); 1291 1300 } 1292 1301 1293 1302 /**