}
EXPORT_SYMBOL(of_mdiobus_child_is_phy);
+static void __of_mdiobus_unregister_callback(struct mii_bus *mdio)
+{
+ of_node_put(mdio->dev.of_node);
+}
+
/**
* __of_mdiobus_register - Register mii_bus and create PHYs from the device tree
* @mdio: pointer to mii_bus structure
* the device tree are populated after the bus has been registered */
mdio->phy_mask = ~0;
+ mdio->__unregister_callback = __of_mdiobus_unregister_callback;
+ of_node_get(np);
device_set_node(&mdio->dev, of_fwnode_handle(np));
/* Get bus level PHY reset GPIO details */
/* Register the MDIO bus */
rc = __mdiobus_register(mdio, owner);
if (rc)
- return rc;
+ goto put_node;
/* Loop over the child nodes and register a phy_device for each phy */
for_each_available_child_of_node(np, child) {
unregister:
of_node_put(child);
mdiobus_unregister(mdio);
+
+put_node:
+ of_node_put(np);
return rc;
}
EXPORT_SYMBOL(__of_mdiobus_register);
gpiod_set_value_cansleep(bus->reset_gpiod, 1);
device_del(&bus->dev);
+
+ if (bus->__unregister_callback)
+ bus->__unregister_callback(bus);
}
EXPORT_SYMBOL(mdiobus_unregister);
/** @shared: shared state across different PHYs */
struct phy_package_shared *shared[PHY_MAX_ADDR];
+
+ /** @__unregister_callback: called at the last step of unregistration */
+ void (*__unregister_callback)(struct mii_bus *bus);
};
#define to_mii_bus(d) container_of(d, struct mii_bus, dev)