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

net: phy: add support for a common probe between shared PHYs

Shared PHYs (PHYs in the same hardware package) may have shared
registers and their drivers would usually need to share information.
There is currently a way to have a shared (part of the) init, by using
phy_package_init_once(). This patch extends the logic to share parts of
the probe to allow sharing the initialization of locks or resources
retrieval.

Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Antoine Tenart and committed by
David S. Miller
0ef44e5c 7b0cc34a

+15 -3
+15 -3
include/linux/phy.h
··· 244 244 }; 245 245 246 246 /* used as bit number in atomic bitops */ 247 - #define PHY_SHARED_F_INIT_DONE 0 247 + #define PHY_SHARED_F_INIT_DONE 0 248 + #define PHY_SHARED_F_PROBE_DONE 1 248 249 249 250 /* 250 251 * The Bus class for PHYs. Devices which provide access to ··· 1567 1566 return __mdiobus_write(phydev->mdio.bus, shared->addr, regnum, val); 1568 1567 } 1569 1568 1570 - static inline bool phy_package_init_once(struct phy_device *phydev) 1569 + static inline bool __phy_package_set_once(struct phy_device *phydev, 1570 + unsigned int b) 1571 1571 { 1572 1572 struct phy_package_shared *shared = phydev->shared; 1573 1573 1574 1574 if (!shared) 1575 1575 return false; 1576 1576 1577 - return !test_and_set_bit(PHY_SHARED_F_INIT_DONE, &shared->flags); 1577 + return !test_and_set_bit(b, &shared->flags); 1578 + } 1579 + 1580 + static inline bool phy_package_init_once(struct phy_device *phydev) 1581 + { 1582 + return __phy_package_set_once(phydev, PHY_SHARED_F_INIT_DONE); 1583 + } 1584 + 1585 + static inline bool phy_package_probe_once(struct phy_device *phydev) 1586 + { 1587 + return __phy_package_set_once(phydev, PHY_SHARED_F_PROBE_DONE); 1578 1588 } 1579 1589 1580 1590 extern struct bus_type mdio_bus_type;