Thread (22 messages) flat view 22 messages, 3 authors, 2021-06-17

Re: [net-next: PATCH v2 2/7] net: mdiobus: Introduce fwnode_mdbiobus_register()

From: Marcin Wojtas <hidden>
Date: 2021-06-16 23:51:14
Also in: lkml

śr., 16 cze 2021 o 21:33 Andrew Lunn [off-list ref] napisał(a):
On Wed, Jun 16, 2021 at 09:07:54PM +0200, Marcin Wojtas wrote:
quoted
This patch introduces a new helper function that
wraps acpi_/of_ mdiobus_register() and allows its
usage via common fwnode_ interface.

Fall back to raw mdiobus_register() in case CONFIG_FWNODE_MDIO
is not enabled, in order to satisfy compatibility
in all future user drivers.
quoted
Signed-off-by: Marcin Wojtas <redacted>
---
 include/linux/fwnode_mdio.h    | 12 +++++++++++
 drivers/net/mdio/fwnode_mdio.c | 22 ++++++++++++++++++++
 2 files changed, 34 insertions(+)
diff --git a/include/linux/fwnode_mdio.h b/include/linux/fwnode_mdio.h
index faf603c48c86..13d4ae8fee0a 100644
--- a/include/linux/fwnode_mdio.h
+++ b/include/linux/fwnode_mdio.h
@@ -16,6 +16,7 @@ int fwnode_mdiobus_phy_device_register(struct mii_bus *mdio,
 int fwnode_mdiobus_register_phy(struct mii_bus *bus,
                              struct fwnode_handle *child, u32 addr);

+int fwnode_mdiobus_register(struct mii_bus *bus, struct fwnode_handle *fwnode);
 #else /* CONFIG_FWNODE_MDIO */
 int fwnode_mdiobus_phy_device_register(struct mii_bus *mdio,
                                     struct phy_device *phy,
@@ -30,6 +31,17 @@ static inline int fwnode_mdiobus_register_phy(struct mii_bus *bus,
 {
      return -EINVAL;
 }
+
+static inline int fwnode_mdiobus_register(struct mii_bus *bus,
+                                       struct fwnode_handle *fwnode)
+{
+     /*
+      * Fall back to mdiobus_register() function to register a bus.
+      * This way, we don't have to keep compat bits around in drivers.
+      */
+
+     return mdiobus_register(mdio);
+}
I'm not sure this fallback is correct.

Any driver which decides to use fwmode is going to select it. If it is
not selected, you want a link time error, or a compiler time error to
tell you, you are missing FWNODE_MDIO. Calling mdiobus_register() is
unlikely to work, or the driver would of done that directly.
This kind of fallback is done in of_mdiobus_register and acpi_mdiobus_register.

Actually mvmdio driver is using this fallback for non-dt platforms
(e.g. Orion). Therefore I would prefer to keep the current behavior.

Best regards,
Marcin
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help