Skip to content

Commit 543887d

Browse files
committed
Merge branch 'mdiobus-module-owner'
Florian Fainelli says: ==================== ACPI/DT mdiobus module owner fixes This patch series fixes wrong mdiobus module ownership for MDIO buses registered from DT or ACPI. Thanks Maxime for providing the first patch and making me see that ACPI also had the same issue. Changes in v2: - fixed missing kdoc in the first patch ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 4203d84 + 30b605b commit 543887d

File tree

5 files changed

+46
-18
lines changed

5 files changed

+46
-18
lines changed

drivers/net/mdio/acpi_mdio.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,26 @@ MODULE_AUTHOR("Calvin Johnson <calvin.johnson@oss.nxp.com>");
1818
MODULE_LICENSE("GPL");
1919

2020
/**
21-
* acpi_mdiobus_register - Register mii_bus and create PHYs from the ACPI ASL.
21+
* __acpi_mdiobus_register - Register mii_bus and create PHYs from the ACPI ASL.
2222
* @mdio: pointer to mii_bus structure
2323
* @fwnode: pointer to fwnode of MDIO bus. This fwnode is expected to represent
24+
* @owner: module owning this @mdio object.
2425
* an ACPI device object corresponding to the MDIO bus and its children are
2526
* expected to correspond to the PHY devices on that bus.
2627
*
2728
* This function registers the mii_bus structure and registers a phy_device
2829
* for each child node of @fwnode.
2930
*/
30-
int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode)
31+
int __acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode,
32+
struct module *owner)
3133
{
3234
struct fwnode_handle *child;
3335
u32 addr;
3436
int ret;
3537

3638
/* Mask out all PHYs from auto probing. */
3739
mdio->phy_mask = GENMASK(31, 0);
38-
ret = mdiobus_register(mdio);
40+
ret = __mdiobus_register(mdio, owner);
3941
if (ret)
4042
return ret;
4143

@@ -55,4 +57,4 @@ int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode)
5557
}
5658
return 0;
5759
}
58-
EXPORT_SYMBOL(acpi_mdiobus_register);
60+
EXPORT_SYMBOL(__acpi_mdiobus_register);

drivers/net/mdio/of_mdio.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,21 +139,23 @@ bool of_mdiobus_child_is_phy(struct device_node *child)
139139
EXPORT_SYMBOL(of_mdiobus_child_is_phy);
140140

141141
/**
142-
* of_mdiobus_register - Register mii_bus and create PHYs from the device tree
142+
* __of_mdiobus_register - Register mii_bus and create PHYs from the device tree
143143
* @mdio: pointer to mii_bus structure
144144
* @np: pointer to device_node of MDIO bus.
145+
* @owner: module owning the @mdio object.
145146
*
146147
* This function registers the mii_bus structure and registers a phy_device
147148
* for each child node of @np.
148149
*/
149-
int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
150+
int __of_mdiobus_register(struct mii_bus *mdio, struct device_node *np,
151+
struct module *owner)
150152
{
151153
struct device_node *child;
152154
bool scanphys = false;
153155
int addr, rc;
154156

155157
if (!np)
156-
return mdiobus_register(mdio);
158+
return __mdiobus_register(mdio, owner);
157159

158160
/* Do not continue if the node is disabled */
159161
if (!of_device_is_available(np))
@@ -172,7 +174,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
172174
of_property_read_u32(np, "reset-post-delay-us", &mdio->reset_post_delay_us);
173175

174176
/* Register the MDIO bus */
175-
rc = mdiobus_register(mdio);
177+
rc = __mdiobus_register(mdio, owner);
176178
if (rc)
177179
return rc;
178180

@@ -236,7 +238,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
236238
mdiobus_unregister(mdio);
237239
return rc;
238240
}
239-
EXPORT_SYMBOL(of_mdiobus_register);
241+
EXPORT_SYMBOL(__of_mdiobus_register);
240242

241243
/**
242244
* of_mdio_find_device - Given a device tree node, find the mdio_device

drivers/net/phy/mdio_devres.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,14 @@ EXPORT_SYMBOL(__devm_mdiobus_register);
9898

9999
#if IS_ENABLED(CONFIG_OF_MDIO)
100100
/**
101-
* devm_of_mdiobus_register - Resource managed variant of of_mdiobus_register()
101+
* __devm_of_mdiobus_register - Resource managed variant of of_mdiobus_register()
102102
* @dev: Device to register mii_bus for
103103
* @mdio: MII bus structure to register
104104
* @np: Device node to parse
105+
* @owner: Owning module
105106
*/
106-
int devm_of_mdiobus_register(struct device *dev, struct mii_bus *mdio,
107-
struct device_node *np)
107+
int __devm_of_mdiobus_register(struct device *dev, struct mii_bus *mdio,
108+
struct device_node *np, struct module *owner)
108109
{
109110
struct mdiobus_devres *dr;
110111
int ret;
@@ -117,7 +118,7 @@ int devm_of_mdiobus_register(struct device *dev, struct mii_bus *mdio,
117118
if (!dr)
118119
return -ENOMEM;
119120

120-
ret = of_mdiobus_register(mdio, np);
121+
ret = __of_mdiobus_register(mdio, np, owner);
121122
if (ret) {
122123
devres_free(dr);
123124
return ret;
@@ -127,7 +128,7 @@ int devm_of_mdiobus_register(struct device *dev, struct mii_bus *mdio,
127128
devres_add(dev, dr);
128129
return 0;
129130
}
130-
EXPORT_SYMBOL(devm_of_mdiobus_register);
131+
EXPORT_SYMBOL(__devm_of_mdiobus_register);
131132
#endif /* CONFIG_OF_MDIO */
132133

133134
MODULE_LICENSE("GPL");

include/linux/acpi_mdio.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@
99
#include <linux/phy.h>
1010

1111
#if IS_ENABLED(CONFIG_ACPI_MDIO)
12-
int acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode);
12+
int __acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode,
13+
struct module *owner);
14+
15+
static inline int
16+
acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *handle)
17+
{
18+
return __acpi_mdiobus_register(mdio, handle, THIS_MODULE);
19+
}
1320
#else /* CONFIG_ACPI_MDIO */
1421
static inline int
1522
acpi_mdiobus_register(struct mii_bus *mdio, struct fwnode_handle *fwnode)

include/linux/of_mdio.h

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,25 @@
1414

1515
#if IS_ENABLED(CONFIG_OF_MDIO)
1616
bool of_mdiobus_child_is_phy(struct device_node *child);
17-
int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np);
18-
int devm_of_mdiobus_register(struct device *dev, struct mii_bus *mdio,
19-
struct device_node *np);
17+
int __of_mdiobus_register(struct mii_bus *mdio, struct device_node *np,
18+
struct module *owner);
19+
20+
static inline int of_mdiobus_register(struct mii_bus *mdio,
21+
struct device_node *np)
22+
{
23+
return __of_mdiobus_register(mdio, np, THIS_MODULE);
24+
}
25+
26+
int __devm_of_mdiobus_register(struct device *dev, struct mii_bus *mdio,
27+
struct device_node *np, struct module *owner);
28+
29+
static inline int devm_of_mdiobus_register(struct device *dev,
30+
struct mii_bus *mdio,
31+
struct device_node *np)
32+
{
33+
return __devm_of_mdiobus_register(dev, mdio, np, THIS_MODULE);
34+
}
35+
2036
struct mdio_device *of_mdio_find_device(struct device_node *np);
2137
struct phy_device *of_phy_find_device(struct device_node *phy_np);
2238
struct phy_device *

0 commit comments

Comments
 (0)