mbox series

[U-Boot,v2,0/5] net: phy: prevent uclass_eth device "node" field overwriting

Message ID 20180705170252.5422-1-grygorii.strashko@ti.com
Headers show
Series net: phy: prevent uclass_eth device "node" field overwriting | expand

Message

Grygorii Strashko July 5, 2018, 5:02 p.m. UTC
This series prevents the UCLASS_ETH device "node" field overwriting 
by some network drivers when Ethernet PHYs are linked to UCLASS_ETH device using
"phy-handle" DT property and when Ethernet PHY driver needs to read some
additional information from DT (like dp83867).

It fixes following cases:

- network drivers
	priv->phydev = phy_connect(priv->bus, priv->phyaddr, dev,
				   priv->interface);
	<-- phydev is connected to dev which is UCLASS_ETH device

	if (priv->phy_of_handle > 0)
		dev_set_of_offset(priv->phydev->dev, priv->phy_of_handle);
	<-- phydev->dev->node is overwritten by phy-handle DT node

- PHY driver in .config() callback
	int node = dev_of_offset(dev);
	<-- PHY driver uses overwritten dev->node
        const void *fdt = gd->fdt_blob;

	 if (fdtdec_get_bool(fdt, node, "property"))
		...

As result, UCLASS_ETH device can't be used any more for DT accessing.

It adds new field ofnode node to struct phy_device and updates TI CPSW and
zynq_gem drivers to use it.

zynq_gem.c, xilinx_phy.c changes only build tested.

Changes in v2:
- struct phy_device->node field initialization added to phy_device_create()

Dependency:
 This series has dependency from
 https://patchwork.ozlabs.org/cover/936370/
 due to possible merge conflicts

PS: Not sure if any other Net drivers need to be updated,
    at least I've not found any.

Grygorii Strashko (5):
  net: phy: add ofnode node to struct phy_device
  net: phy: dp83867: switch to use phy_get_ofnode()
  net: phy: xilinx: switch to use phy_get_ofnode()
  drivers: net: cpsw: fix phy dt node setting
  drivers: net: zynq_gem: fix phy dt node setting

 drivers/net/cpsw.c           |  2 +-
 drivers/net/phy/phy.c        |  4 ++++
 drivers/net/phy/ti.c         |  7 +++++--
 drivers/net/phy/xilinx_phy.c | 10 ++++++----
 drivers/net/zynq_gem.c       |  2 +-
 include/phy.h                | 13 +++++++++++++
 6 files changed, 30 insertions(+), 8 deletions(-)