Skip to content

Commit 8b11c20

Browse files
brgldavem330
authored andcommitted
phy: un-inline devm_mdiobus_register()
Functions should only be static inline if they're very short. This devres helper is already over 10 lines and it will grow soon as we'll be improving upon its approach. Pull it into mdio_devres.c. Signed-off-by: Bartosz Golaszewski <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent bd8ff6d commit 8b11c20

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

drivers/net/phy/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
libphy-y := phy.o phy-c45.o phy-core.o phy_device.o \
55
linkmode.o
6-
mdio-bus-y += mdio_bus.o mdio_device.o
6+
mdio-bus-y += mdio_bus.o mdio_device.o mdio_devres.o
77

88
ifdef CONFIG_MDIO_DEVICE
99
obj-y += mdio-boardinfo.o

drivers/net/phy/mdio_devres.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
3+
#include <linux/phy.h>
4+
5+
int __devm_mdiobus_register(struct mii_bus *bus, struct module *owner)
6+
{
7+
int ret;
8+
9+
if (!bus->is_managed)
10+
return -EPERM;
11+
12+
ret = __mdiobus_register(bus, owner);
13+
if (!ret)
14+
bus->is_managed_registered = 1;
15+
16+
return ret;
17+
}
18+
EXPORT_SYMBOL(__devm_mdiobus_register);

include/linux/phy.h

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -322,20 +322,9 @@ static inline struct mii_bus *mdiobus_alloc(void)
322322
}
323323

324324
int __mdiobus_register(struct mii_bus *bus, struct module *owner);
325+
int __devm_mdiobus_register(struct mii_bus *bus, struct module *owner);
325326
#define mdiobus_register(bus) __mdiobus_register(bus, THIS_MODULE)
326-
static inline int devm_mdiobus_register(struct mii_bus *bus)
327-
{
328-
int ret;
329-
330-
if (!bus->is_managed)
331-
return -EPERM;
332-
333-
ret = mdiobus_register(bus);
334-
if (!ret)
335-
bus->is_managed_registered = 1;
336-
337-
return ret;
338-
}
327+
#define devm_mdiobus_register(bus) __devm_mdiobus_register(bus, THIS_MODULE)
339328

340329
void mdiobus_unregister(struct mii_bus *bus);
341330
void mdiobus_free(struct mii_bus *bus);

0 commit comments

Comments
 (0)