net: mdio: add mdio_device_get() and mdio_device_put()
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Fri, 26 May 2023 10:14:24 +0000 (11:14 +0100)
committerJakub Kicinski <kuba@kernel.org>
Tue, 30 May 2023 04:46:53 +0000 (21:46 -0700)
Add two new operations for a mdio device to manage the refcount on the
underlying struct device. This will be used by mdio PCS drivers to
simplify the creation and destruction handling, making it easier for
users to get it correct.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/linux/mdio.h

index 0670cc6e067c8a1014bf5a116f6fc0dc8cedb4ff..c1b7008826e5b6a59a016e27417c635007d8d39d 100644 (file)
@@ -106,6 +106,16 @@ int mdio_driver_register(struct mdio_driver *drv);
 void mdio_driver_unregister(struct mdio_driver *drv);
 int mdio_device_bus_match(struct device *dev, struct device_driver *drv);
 
+static inline void mdio_device_get(struct mdio_device *mdiodev)
+{
+       get_device(&mdiodev->dev);
+}
+
+static inline void mdio_device_put(struct mdio_device *mdiodev)
+{
+       mdio_device_free(mdiodev);
+}
+
 static inline bool mdio_phy_id_is_c45(int phy_id)
 {
        return (phy_id & MDIO_PHY_ID_C45) && !(phy_id & ~MDIO_PHY_ID_C45_MASK);