Skip to content

Commit 4798a71

Browse files
Jon Masondavem330
authored andcommitted
of_mdio: move of_mdio_parse_addr to header file
The of_mdio_parse_addr() helper function is useful to other code, but the module dependency chain causes issues. To work around this, we can move of_mdio_parse_addr() to be an inline function in the header file. This gets rid of the dependencies and still allows for the reuse of code. Reported-by: Liviu Dudau <[email protected]> Signed-off-by: Jon Mason <[email protected]> Fixes: 342fa19 ("mdio: mux: make child bus walking more permissive and errors more verbose") Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent efe5f9c commit 4798a71

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

drivers/of/of_mdio.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -119,28 +119,6 @@ static void of_mdiobus_register_device(struct mii_bus *mdio,
119119
child->name, addr);
120120
}
121121

122-
int of_mdio_parse_addr(struct device *dev, const struct device_node *np)
123-
{
124-
u32 addr;
125-
int ret;
126-
127-
ret = of_property_read_u32(np, "reg", &addr);
128-
if (ret < 0) {
129-
dev_err(dev, "%s has invalid PHY address\n", np->full_name);
130-
return ret;
131-
}
132-
133-
/* A PHY must have a reg property in the range [0-31] */
134-
if (addr >= PHY_MAX_ADDR) {
135-
dev_err(dev, "%s PHY address %i is too large\n",
136-
np->full_name, addr);
137-
return -EINVAL;
138-
}
139-
140-
return addr;
141-
}
142-
EXPORT_SYMBOL(of_mdio_parse_addr);
143-
144122
/* The following is a list of PHY compatible strings which appear in
145123
* some DTBs. The compatible string is never matched against a PHY
146124
* driver, so is pointless. We only expect devices which are not PHYs

include/linux/of_mdio.h

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,33 @@ struct phy_device *of_phy_attach(struct net_device *dev,
2727
phy_interface_t iface);
2828

2929
extern struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np);
30-
extern int of_mdio_parse_addr(struct device *dev, const struct device_node *np);
3130
extern int of_phy_register_fixed_link(struct device_node *np);
3231
extern void of_phy_deregister_fixed_link(struct device_node *np);
3332
extern bool of_phy_is_fixed_link(struct device_node *np);
3433

34+
35+
static inline int of_mdio_parse_addr(struct device *dev,
36+
const struct device_node *np)
37+
{
38+
u32 addr;
39+
int ret;
40+
41+
ret = of_property_read_u32(np, "reg", &addr);
42+
if (ret < 0) {
43+
dev_err(dev, "%s has invalid PHY address\n", np->full_name);
44+
return ret;
45+
}
46+
47+
/* A PHY must have a reg property in the range [0-31] */
48+
if (addr >= PHY_MAX_ADDR) {
49+
dev_err(dev, "%s PHY address %i is too large\n",
50+
np->full_name, addr);
51+
return -EINVAL;
52+
}
53+
54+
return addr;
55+
}
56+
3557
#else /* CONFIG_OF_MDIO */
3658
static inline int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
3759
{

0 commit comments

Comments
 (0)