Skip to content

Commit

Permalink
phy: un-inline devm_mdiobus_register()
Browse files Browse the repository at this point in the history
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 <bgolaszewski@baylibre.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Bartosz Golaszewski authored and David S. Miller committed Jun 30, 2020
1 parent bd8ff6d commit 8b11c20
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion drivers/net/phy/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

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

ifdef CONFIG_MDIO_DEVICE
obj-y += mdio-boardinfo.o
Expand Down
18 changes: 18 additions & 0 deletions drivers/net/phy/mdio_devres.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: GPL-2.0-or-later

#include <linux/phy.h>

int __devm_mdiobus_register(struct mii_bus *bus, struct module *owner)
{
int ret;

if (!bus->is_managed)
return -EPERM;

ret = __mdiobus_register(bus, owner);
if (!ret)
bus->is_managed_registered = 1;

return ret;
}
EXPORT_SYMBOL(__devm_mdiobus_register);
15 changes: 2 additions & 13 deletions include/linux/phy.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,20 +322,9 @@ static inline struct mii_bus *mdiobus_alloc(void)
}

int __mdiobus_register(struct mii_bus *bus, struct module *owner);
int __devm_mdiobus_register(struct mii_bus *bus, struct module *owner);
#define mdiobus_register(bus) __mdiobus_register(bus, THIS_MODULE)
static inline int devm_mdiobus_register(struct mii_bus *bus)
{
int ret;

if (!bus->is_managed)
return -EPERM;

ret = mdiobus_register(bus);
if (!ret)
bus->is_managed_registered = 1;

return ret;
}
#define devm_mdiobus_register(bus) __devm_mdiobus_register(bus, THIS_MODULE)

void mdiobus_unregister(struct mii_bus *bus);
void mdiobus_free(struct mii_bus *bus);
Expand Down

0 comments on commit 8b11c20

Please sign in to comment.