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.
Unified · Split
| @@ -3,7 +3,7 @@ · 2 unmodified lines | ||
| 3 | 3 | |
| 4 | 4 | libphy-y := phy.o phy-c45.o phy-core.o phy_device.o \ |
| 5 | 5 | 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 | |
| 7 | 7 | |
| 8 | 8 | ifdef CONFIG_MDIO_DEVICE |
| 9 | 9 | obj-y += mdio-boardinfo.o |
| @@ -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); | |
| @@ -322,20 +322,9 @@ static inline struct mii_bus *mdiobus_alloc(void) · 321 unmodified lines | ||
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | int __mdiobus_register(struct mii_bus *bus, struct module *owner); |
| 325 | +int __devm_mdiobus_register(struct mii_bus *bus, struct module *owner); | |
| 325 | 326 | #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) | |
| 339 | 328 | |
| 340 | 329 | void mdiobus_unregister(struct mii_bus *bus); |
| 341 | 330 | void mdiobus_free(struct mii_bus *bus); |