diff mbox series

[RFC,1/3] phy: make phy_connect_fixed work with a null mdio bus

Message ID 20200503185227.28731-2-olteanv@gmail.com
State New
Headers show
Series DM_MDIO for fsl_tsec driver | expand

Commit Message

Vladimir Oltean May 3, 2020, 6:52 p.m. UTC
From: Vladimir Oltean <vladimir.oltean at nxp.com>

It is utterly pointless to require an MDIO bus pointer for a fixed PHY
device. The fixed.c implementation does not require it, only
phy_device_create. Fix that.

Signed-off-by: Vladimir Oltean <vladimir.oltean at nxp.com>
---
 drivers/net/phy/phy.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Zhiqiang Hou May 4, 2020, 6:08 a.m. UTC | #1
> -----Original Message-----
> From: Vladimir Oltean <olteanv at gmail.com>
> Sent: 2020?5?4? 2:52
> To: u-boot at lists.denx.de; joe.hershberger at ni.com; Priyanka Jain
> <priyanka.jain at nxp.com>
> Cc: Z.q. Hou <zhiqiang.hou at nxp.com>; bmeng.cn at gmail.com; Claudiu
> Manoil <claudiu.manoil at nxp.com>; Alexandru Marginean
> <alexandru.marginean at nxp.com>
> Subject: [RFC PATCH 1/3] phy: make phy_connect_fixed work with a null mdio
> bus
> 
> From: Vladimir Oltean <vladimir.oltean at nxp.com>
> 
> It is utterly pointless to require an MDIO bus pointer for a fixed PHY device.
> The fixed.c implementation does not require it, only phy_device_create. Fix
> that.
> 
> Signed-off-by: Vladimir Oltean <vladimir.oltean at nxp.com>
> ---
>  drivers/net/phy/phy.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index
> 9a66e62e8974..dcef1aaf2026 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -651,7 +651,7 @@ static struct phy_device *phy_device_create(struct
> mii_dev *bus, int addr,
>  	dev = malloc(sizeof(*dev));
>  	if (!dev) {
>  		printf("Failed to allocate PHY device for %s:%d\n",
> -		       bus->name, addr);
> +		       bus ? bus->name : "(null bus)", addr);
>  		return NULL;
>  	}
> 
> @@ -679,7 +679,7 @@ static struct phy_device *phy_device_create(struct
> mii_dev *bus, int addr,
>  		return NULL;
>  	}
> 
> -	if (addr >= 0 && addr < PHY_MAX_ADDR)
> +	if (addr >= 0 && addr < PHY_MAX_ADDR && phy_id != PHY_FIXED_ID)
>  		bus->phymap[addr] = dev;
> 
>  	return dev;
> --
> 2.17.1

Reviewed-by: Hou Zhiqiang <Zhiqiang.Hou at nxp.com>
diff mbox series

Patch

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 9a66e62e8974..dcef1aaf2026 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -651,7 +651,7 @@  static struct phy_device *phy_device_create(struct mii_dev *bus, int addr,
 	dev = malloc(sizeof(*dev));
 	if (!dev) {
 		printf("Failed to allocate PHY device for %s:%d\n",
-		       bus->name, addr);
+		       bus ? bus->name : "(null bus)", addr);
 		return NULL;
 	}
 
@@ -679,7 +679,7 @@  static struct phy_device *phy_device_create(struct mii_dev *bus, int addr,
 		return NULL;
 	}
 
-	if (addr >= 0 && addr < PHY_MAX_ADDR)
+	if (addr >= 0 && addr < PHY_MAX_ADDR && phy_id != PHY_FIXED_ID)
 		bus->phymap[addr] = dev;
 
 	return dev;