net: mdio: fix owner field for mdio buses registered using device-tree
[ Upstream commit 99669259f3361d759219811e670b7e0742668556 ]
Bus ownership is wrong when using of_mdiobus_register() to register an mdio
bus. That function is not inline, so when it calls mdiobus_register() the wrong
THIS_MODULE value is captured.
Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
Fixes: 90eff9096c
("net: phy: Allow splitting MDIO bus/device support from PHYs")
[florian: fix kdoc, added Fixes tag]
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
1b333766ea
commit
d04dac7fae
@@ -238,21 +238,23 @@ bool of_mdiobus_child_is_phy(struct device_node *child)
|
|||||||
EXPORT_SYMBOL(of_mdiobus_child_is_phy);
|
EXPORT_SYMBOL(of_mdiobus_child_is_phy);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* of_mdiobus_register - Register mii_bus and create PHYs from the device tree
|
* __of_mdiobus_register - Register mii_bus and create PHYs from the device tree
|
||||||
* @mdio: pointer to mii_bus structure
|
* @mdio: pointer to mii_bus structure
|
||||||
* @np: pointer to device_node of MDIO bus.
|
* @np: pointer to device_node of MDIO bus.
|
||||||
|
* @owner: module owning the @mdio object.
|
||||||
*
|
*
|
||||||
* This function registers the mii_bus structure and registers a phy_device
|
* This function registers the mii_bus structure and registers a phy_device
|
||||||
* for each child node of @np.
|
* for each child node of @np.
|
||||||
*/
|
*/
|
||||||
int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
|
int __of_mdiobus_register(struct mii_bus *mdio, struct device_node *np,
|
||||||
|
struct module *owner)
|
||||||
{
|
{
|
||||||
struct device_node *child;
|
struct device_node *child;
|
||||||
bool scanphys = false;
|
bool scanphys = false;
|
||||||
int addr, rc;
|
int addr, rc;
|
||||||
|
|
||||||
if (!np)
|
if (!np)
|
||||||
return mdiobus_register(mdio);
|
return __mdiobus_register(mdio, owner);
|
||||||
|
|
||||||
/* Do not continue if the node is disabled */
|
/* Do not continue if the node is disabled */
|
||||||
if (!of_device_is_available(np))
|
if (!of_device_is_available(np))
|
||||||
@@ -272,7 +274,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
|
|||||||
of_property_read_u32(np, "reset-post-delay-us", &mdio->reset_post_delay_us);
|
of_property_read_u32(np, "reset-post-delay-us", &mdio->reset_post_delay_us);
|
||||||
|
|
||||||
/* Register the MDIO bus */
|
/* Register the MDIO bus */
|
||||||
rc = mdiobus_register(mdio);
|
rc = __mdiobus_register(mdio, owner);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
@@ -336,7 +338,7 @@ unregister:
|
|||||||
mdiobus_unregister(mdio);
|
mdiobus_unregister(mdio);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(of_mdiobus_register);
|
EXPORT_SYMBOL(__of_mdiobus_register);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* of_mdio_find_device - Given a device tree node, find the mdio_device
|
* of_mdio_find_device - Given a device tree node, find the mdio_device
|
||||||
|
@@ -98,13 +98,14 @@ EXPORT_SYMBOL(__devm_mdiobus_register);
|
|||||||
|
|
||||||
#if IS_ENABLED(CONFIG_OF_MDIO)
|
#if IS_ENABLED(CONFIG_OF_MDIO)
|
||||||
/**
|
/**
|
||||||
* devm_of_mdiobus_register - Resource managed variant of of_mdiobus_register()
|
* __devm_of_mdiobus_register - Resource managed variant of of_mdiobus_register()
|
||||||
* @dev: Device to register mii_bus for
|
* @dev: Device to register mii_bus for
|
||||||
* @mdio: MII bus structure to register
|
* @mdio: MII bus structure to register
|
||||||
* @np: Device node to parse
|
* @np: Device node to parse
|
||||||
|
* @owner: Owning module
|
||||||
*/
|
*/
|
||||||
int devm_of_mdiobus_register(struct device *dev, struct mii_bus *mdio,
|
int __devm_of_mdiobus_register(struct device *dev, struct mii_bus *mdio,
|
||||||
struct device_node *np)
|
struct device_node *np, struct module *owner)
|
||||||
{
|
{
|
||||||
struct mdiobus_devres *dr;
|
struct mdiobus_devres *dr;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -117,7 +118,7 @@ int devm_of_mdiobus_register(struct device *dev, struct mii_bus *mdio,
|
|||||||
if (!dr)
|
if (!dr)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
ret = of_mdiobus_register(mdio, np);
|
ret = __of_mdiobus_register(mdio, np, owner);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
devres_free(dr);
|
devres_free(dr);
|
||||||
return ret;
|
return ret;
|
||||||
@@ -127,7 +128,7 @@ int devm_of_mdiobus_register(struct device *dev, struct mii_bus *mdio,
|
|||||||
devres_add(dev, dr);
|
devres_add(dev, dr);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(devm_of_mdiobus_register);
|
EXPORT_SYMBOL(__devm_of_mdiobus_register);
|
||||||
#endif /* CONFIG_OF_MDIO */
|
#endif /* CONFIG_OF_MDIO */
|
||||||
|
|
||||||
MODULE_LICENSE("GPL");
|
MODULE_LICENSE("GPL");
|
||||||
|
@@ -14,9 +14,25 @@
|
|||||||
|
|
||||||
#if IS_ENABLED(CONFIG_OF_MDIO)
|
#if IS_ENABLED(CONFIG_OF_MDIO)
|
||||||
bool of_mdiobus_child_is_phy(struct device_node *child);
|
bool of_mdiobus_child_is_phy(struct device_node *child);
|
||||||
int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np);
|
int __of_mdiobus_register(struct mii_bus *mdio, struct device_node *np,
|
||||||
int devm_of_mdiobus_register(struct device *dev, struct mii_bus *mdio,
|
struct module *owner);
|
||||||
struct device_node *np);
|
|
||||||
|
static inline int of_mdiobus_register(struct mii_bus *mdio,
|
||||||
|
struct device_node *np)
|
||||||
|
{
|
||||||
|
return __of_mdiobus_register(mdio, np, THIS_MODULE);
|
||||||
|
}
|
||||||
|
|
||||||
|
int __devm_of_mdiobus_register(struct device *dev, struct mii_bus *mdio,
|
||||||
|
struct device_node *np, struct module *owner);
|
||||||
|
|
||||||
|
static inline int devm_of_mdiobus_register(struct device *dev,
|
||||||
|
struct mii_bus *mdio,
|
||||||
|
struct device_node *np)
|
||||||
|
{
|
||||||
|
return __devm_of_mdiobus_register(dev, mdio, np, THIS_MODULE);
|
||||||
|
}
|
||||||
|
|
||||||
struct mdio_device *of_mdio_find_device(struct device_node *np);
|
struct mdio_device *of_mdio_find_device(struct device_node *np);
|
||||||
struct phy_device *of_phy_find_device(struct device_node *phy_np);
|
struct phy_device *of_phy_find_device(struct device_node *phy_np);
|
||||||
struct phy_device *
|
struct phy_device *
|
||||||
|
Reference in New Issue
Block a user