From patchwork Sun May 3 18:52:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 244946 List-Id: U-Boot discussion From: olteanv at gmail.com (Vladimir Oltean) Date: Sun, 3 May 2020 21:52:25 +0300 Subject: [RFC PATCH 1/3] phy: make phy_connect_fixed work with a null mdio bus In-Reply-To: <20200503185227.28731-1-olteanv@gmail.com> References: <20200503185227.28731-1-olteanv@gmail.com> Message-ID: <20200503185227.28731-2-olteanv@gmail.com> From: Vladimir Oltean 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 Reviewed-by: Hou Zhiqiang --- 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;