All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/3] net: mdio: setup both fwnode and of_node
@ 2021-06-17 12:29 Ioana Ciornei
  2021-06-17 12:29 ` [PATCH net-next v2 1/3] net: mdio: setup of_node for the MDIO device Ioana Ciornei
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Ioana Ciornei @ 2021-06-17 12:29 UTC (permalink / raw)
  To: davem, kuba, netdev
  Cc: andrew, hkallweit1, linux, gregkh, rafael, grant.likely,
	calvin.johnson, Ioana Ciornei

From: Ioana Ciornei <ioana.ciornei@nxp.com>

The first patch in this series fixes a bug introduced by mistake in the
previous ACPI MDIO patch set.

The next two patches are adding a new helper which takes a device and a
fwnode_handle and populates both the of_node and fwnode so that we make
sure that a bug like this does not happen anymore.
Also, the new helper is used in the MDIO area.

Ioana Ciornei (3):
  net: mdio: setup of_node for the MDIO device
  driver core: add a helper to setup both the of_node and fwnode of a
    device
  net: mdio: use device_set_node() to setup both fwnode and of

 drivers/base/core.c            | 7 +++++++
 drivers/net/mdio/fwnode_mdio.c | 2 +-
 drivers/net/mdio/of_mdio.c     | 9 ++++-----
 drivers/net/phy/mdio_bus.c     | 3 +--
 include/linux/device.h         | 1 +
 5 files changed, 14 insertions(+), 8 deletions(-)

-- 
2.31.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH net-next v2 1/3] net: mdio: setup of_node for the MDIO device
  2021-06-17 12:29 [PATCH net-next v2 0/3] net: mdio: setup both fwnode and of_node Ioana Ciornei
@ 2021-06-17 12:29 ` Ioana Ciornei
  2021-06-17 12:29 ` [PATCH net-next v2 2/3] driver core: add a helper to setup both the of_node and fwnode of a device Ioana Ciornei
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Ioana Ciornei @ 2021-06-17 12:29 UTC (permalink / raw)
  To: davem, kuba, netdev
  Cc: andrew, hkallweit1, linux, gregkh, rafael, grant.likely,
	calvin.johnson, Ioana Ciornei

From: Ioana Ciornei <ioana.ciornei@nxp.com>

By mistake, the of_node of the MDIO device was not setup in the patch
linked below. As a consequence, any PHY driver that depends on the
of_node in its probe callback was not be able to successfully finish its
probe on a PHY, thus the Generic PHY driver was used instead.

Fix this by actually setting up the of_node.

Fixes: bc1bee3b87ee ("net: mdiobus: Introduce fwnode_mdiobus_register_phy()")
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v2:
 - none


 drivers/net/mdio/fwnode_mdio.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c
index e96766da8de4..283ddb1185bd 100644
--- a/drivers/net/mdio/fwnode_mdio.c
+++ b/drivers/net/mdio/fwnode_mdio.c
@@ -65,6 +65,7 @@ int fwnode_mdiobus_phy_device_register(struct mii_bus *mdio,
 	 * can be looked up later
 	 */
 	fwnode_handle_get(child);
+	phy->mdio.dev.of_node = to_of_node(child);
 	phy->mdio.dev.fwnode = child;
 
 	/* All data is now stored in the phy struct;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next v2 2/3] driver core: add a helper to setup both the of_node and fwnode of a device
  2021-06-17 12:29 [PATCH net-next v2 0/3] net: mdio: setup both fwnode and of_node Ioana Ciornei
  2021-06-17 12:29 ` [PATCH net-next v2 1/3] net: mdio: setup of_node for the MDIO device Ioana Ciornei
@ 2021-06-17 12:29 ` Ioana Ciornei
  2021-06-17 12:50   ` Greg KH
  2021-06-17 12:29 ` [PATCH net-next v2 3/3] net: mdio: use device_set_node() to setup both fwnode and of Ioana Ciornei
  2021-06-17 19:20 ` [PATCH net-next v2 0/3] net: mdio: setup both fwnode and of_node patchwork-bot+netdevbpf
  3 siblings, 1 reply; 6+ messages in thread
From: Ioana Ciornei @ 2021-06-17 12:29 UTC (permalink / raw)
  To: davem, kuba, netdev
  Cc: andrew, hkallweit1, linux, gregkh, rafael, grant.likely,
	calvin.johnson, Ioana Ciornei

From: Ioana Ciornei <ioana.ciornei@nxp.com>

There are many places where both the fwnode_handle and the of_node of a
device need to be populated. Add a function which does both so that we
have consistency.

Suggested-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v2:
 - new patch

 drivers/base/core.c    | 7 +++++++
 include/linux/device.h | 1 +
 2 files changed, 8 insertions(+)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 628e33939aca..b6836bfa985c 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -4723,6 +4723,13 @@ void device_set_of_node_from_dev(struct device *dev, const struct device *dev2)
 }
 EXPORT_SYMBOL_GPL(device_set_of_node_from_dev);
 
+void device_set_node(struct device *dev, struct fwnode_handle *fwnode)
+{
+	dev->fwnode = fwnode;
+	dev->of_node = to_of_node(fwnode);
+}
+EXPORT_SYMBOL_GPL(device_set_node);
+
 int device_match_name(struct device *dev, const void *name)
 {
 	return sysfs_streq(dev_name(dev), name);
diff --git a/include/linux/device.h b/include/linux/device.h
index 38a2071cf776..a1e7cab2c7bf 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -819,6 +819,7 @@ int device_online(struct device *dev);
 void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode);
 void set_secondary_fwnode(struct device *dev, struct fwnode_handle *fwnode);
 void device_set_of_node_from_dev(struct device *dev, const struct device *dev2);
+void device_set_node(struct device *dev, struct fwnode_handle *fwnode);
 
 static inline int dev_num_vf(struct device *dev)
 {
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next v2 3/3] net: mdio: use device_set_node() to setup both fwnode and of
  2021-06-17 12:29 [PATCH net-next v2 0/3] net: mdio: setup both fwnode and of_node Ioana Ciornei
  2021-06-17 12:29 ` [PATCH net-next v2 1/3] net: mdio: setup of_node for the MDIO device Ioana Ciornei
  2021-06-17 12:29 ` [PATCH net-next v2 2/3] driver core: add a helper to setup both the of_node and fwnode of a device Ioana Ciornei
@ 2021-06-17 12:29 ` Ioana Ciornei
  2021-06-17 19:20 ` [PATCH net-next v2 0/3] net: mdio: setup both fwnode and of_node patchwork-bot+netdevbpf
  3 siblings, 0 replies; 6+ messages in thread
From: Ioana Ciornei @ 2021-06-17 12:29 UTC (permalink / raw)
  To: davem, kuba, netdev
  Cc: andrew, hkallweit1, linux, gregkh, rafael, grant.likely,
	calvin.johnson, Ioana Ciornei

From: Ioana Ciornei <ioana.ciornei@nxp.com>

Use the newly introduced helper to setup both the of_node and the
fwnode for a given device.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v2:
 - new patch

 drivers/net/mdio/fwnode_mdio.c | 3 +--
 drivers/net/mdio/of_mdio.c     | 9 ++++-----
 drivers/net/phy/mdio_bus.c     | 3 +--
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c
index 283ddb1185bd..1becb1a731f6 100644
--- a/drivers/net/mdio/fwnode_mdio.c
+++ b/drivers/net/mdio/fwnode_mdio.c
@@ -65,8 +65,7 @@ int fwnode_mdiobus_phy_device_register(struct mii_bus *mdio,
 	 * can be looked up later
 	 */
 	fwnode_handle_get(child);
-	phy->mdio.dev.of_node = to_of_node(child);
-	phy->mdio.dev.fwnode = child;
+	device_set_node(&phy->mdio.dev, child);
 
 	/* All data is now stored in the phy struct;
 	 * register it
diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c
index 8744b1e1c2b1..9e3c815a070f 100644
--- a/drivers/net/mdio/of_mdio.c
+++ b/drivers/net/mdio/of_mdio.c
@@ -51,6 +51,7 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio,
 static int of_mdiobus_register_device(struct mii_bus *mdio,
 				      struct device_node *child, u32 addr)
 {
+	struct fwnode_handle *fwnode = of_fwnode_handle(child);
 	struct mdio_device *mdiodev;
 	int rc;
 
@@ -61,9 +62,8 @@ static int of_mdiobus_register_device(struct mii_bus *mdio,
 	/* Associate the OF node with the device structure so it
 	 * can be looked up later.
 	 */
-	of_node_get(child);
-	mdiodev->dev.of_node = child;
-	mdiodev->dev.fwnode = of_fwnode_handle(child);
+	fwnode_handle_get(fwnode);
+	device_set_node(&mdiodev->dev, fwnode);
 
 	/* All data is now stored in the mdiodev struct; register it. */
 	rc = mdio_device_register(mdiodev);
@@ -162,8 +162,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
 	 * the device tree are populated after the bus has been registered */
 	mdio->phy_mask = ~0;
 
-	mdio->dev.of_node = np;
-	mdio->dev.fwnode = of_fwnode_handle(np);
+	device_set_node(&mdio->dev, of_fwnode_handle(np));
 
 	/* Get bus level PHY reset GPIO details */
 	mdio->reset_delay_us = DEFAULT_GPIO_RESET_DELAY;
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 24665670a89a..53f034fc2ef7 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -459,8 +459,7 @@ static void of_mdiobus_link_mdiodev(struct mii_bus *bus,
 			continue;
 
 		if (addr == mdiodev->addr) {
-			dev->of_node = child;
-			dev->fwnode = of_fwnode_handle(child);
+			device_set_node(dev, of_fwnode_handle(child));
 			return;
 		}
 	}
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next v2 2/3] driver core: add a helper to setup both the of_node and fwnode of a device
  2021-06-17 12:29 ` [PATCH net-next v2 2/3] driver core: add a helper to setup both the of_node and fwnode of a device Ioana Ciornei
@ 2021-06-17 12:50   ` Greg KH
  0 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2021-06-17 12:50 UTC (permalink / raw)
  To: Ioana Ciornei
  Cc: davem, kuba, netdev, andrew, hkallweit1, linux, rafael,
	grant.likely, calvin.johnson, Ioana Ciornei

On Thu, Jun 17, 2021 at 03:29:04PM +0300, Ioana Ciornei wrote:
> From: Ioana Ciornei <ioana.ciornei@nxp.com>
> 
> There are many places where both the fwnode_handle and the of_node of a
> device need to be populated. Add a function which does both so that we
> have consistency.
> 
> Suggested-by: Andrew Lunn <andrew@lunn.ch>
> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next v2 0/3] net: mdio: setup both fwnode and of_node
  2021-06-17 12:29 [PATCH net-next v2 0/3] net: mdio: setup both fwnode and of_node Ioana Ciornei
                   ` (2 preceding siblings ...)
  2021-06-17 12:29 ` [PATCH net-next v2 3/3] net: mdio: use device_set_node() to setup both fwnode and of Ioana Ciornei
@ 2021-06-17 19:20 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-06-17 19:20 UTC (permalink / raw)
  To: Ioana Ciornei
  Cc: davem, kuba, netdev, andrew, hkallweit1, linux, gregkh, rafael,
	grant.likely, calvin.johnson, ioana.ciornei

Hello:

This series was applied to netdev/net-next.git (refs/heads/master):

On Thu, 17 Jun 2021 15:29:02 +0300 you wrote:
> From: Ioana Ciornei <ioana.ciornei@nxp.com>
> 
> The first patch in this series fixes a bug introduced by mistake in the
> previous ACPI MDIO patch set.
> 
> The next two patches are adding a new helper which takes a device and a
> fwnode_handle and populates both the of_node and fwnode so that we make
> sure that a bug like this does not happen anymore.
> Also, the new helper is used in the MDIO area.
> 
> [...]

Here is the summary with links:
  - [net-next,v2,1/3] net: mdio: setup of_node for the MDIO device
    https://git.kernel.org/netdev/net-next/c/70ef608c224a
  - [net-next,v2,2/3] driver core: add a helper to setup both the of_node and fwnode of a device
    https://git.kernel.org/netdev/net-next/c/43e76d463c09
  - [net-next,v2,3/3] net: mdio: use device_set_node() to setup both fwnode and of
    https://git.kernel.org/netdev/net-next/c/7e33d84db1a8

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-06-17 19:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-17 12:29 [PATCH net-next v2 0/3] net: mdio: setup both fwnode and of_node Ioana Ciornei
2021-06-17 12:29 ` [PATCH net-next v2 1/3] net: mdio: setup of_node for the MDIO device Ioana Ciornei
2021-06-17 12:29 ` [PATCH net-next v2 2/3] driver core: add a helper to setup both the of_node and fwnode of a device Ioana Ciornei
2021-06-17 12:50   ` Greg KH
2021-06-17 12:29 ` [PATCH net-next v2 3/3] net: mdio: use device_set_node() to setup both fwnode and of Ioana Ciornei
2021-06-17 19:20 ` [PATCH net-next v2 0/3] net: mdio: setup both fwnode and of_node patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.