[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 5 May 2020 17:22:00 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Calvin Johnson <calvin.johnson@....nxp.com>
Cc: "Rafael J . Wysocki" <rafael@...nel.org>,
Russell King - ARM Linux admin <linux@...linux.org.uk>,
linux.cj@...il.com, Jeremy Linton <jeremy.linton@....com>,
Andrew Lunn <andrew@...n.ch>,
Florian Fainelli <f.fainelli@...il.com>,
Cristi Sovaiala <cristian.sovaiala@....com>,
Florin Laurentiu Chiculita <florinlaurentiu.chiculita@....com>,
Ioana Ciornei <ioana.ciornei@....com>,
Madalin Bucur <madalin.bucur@....nxp.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
Varun Sethi <V.Sethi@....com>,
"Rajesh V . Bikkina" <rajesh.bikkina@....com>,
ACPI Devel Maling List <linux-acpi@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Diana Madalina Craciun <diana.craciun@....com>,
netdev <netdev@...r.kernel.org>, Marcin Wojtas <mw@...ihalf.com>,
Laurentiu Tudor <laurentiu.tudor@....com>,
Makarand Pawagi <makarand.pawagi@....com>,
linux-arm Mailing List <linux-arm-kernel@...ts.infradead.org>,
Pankaj Bansal <pankaj.bansal@....com>,
"David S. Miller" <davem@...emloft.net>,
Heiner Kallweit <hkallweit1@...il.com>
Subject: Re: [net-next PATCH v3 5/5] net: mdiobus: Introduce fwnode_mdiobus_register_phy()
On Tue, May 5, 2020 at 4:30 PM Calvin Johnson
<calvin.johnson@....nxp.com> wrote:
>
> Introduce fwnode_mdiobus_register_phy() to register PHYs on the
> mdiobus. From the compatible string, identify whether the PHY is
> c45 and based on this create a PHY device instance which is
> registered on the mdiobus.
...
> +int fwnode_mdiobus_register_phy(struct mii_bus *bus,
> + struct fwnode_handle *child, u32 addr)
> +{
> + struct phy_device *phy;
> + bool is_c45 = false;
Redundant assignment, see below.
> + const char *cp;
> + u32 phy_id;
> + int rc;
> +
> + fwnode_property_read_string(child, "compatible", &cp);
Consider rc = ...; otherwise you will have UB below.
> + if (!strcmp(cp, "ethernet-phy-ieee802.3-c45"))
UB!
> + is_c45 = true;
is_c45 = !(rc || strcmp(...));
> + if (!is_c45 && !fwnode_get_phy_id(child, &phy_id))
Perhaps positive conditional
if (is_c45 || fwnode_...(...))
get_phy_device();
else
...
> + phy = phy_device_create(bus, addr, phy_id, 0, NULL);
> + else
> + phy = get_phy_device(bus, addr, is_c45);
> + if (IS_ERR(phy))
> + return PTR_ERR(phy);
> +
> + phy->irq = bus->irq[addr];
> +
> + /* Associate the fwnode with the device structure so it
> + * can be looked up later.
> + */
> + phy->mdio.dev.fwnode = child;
> +
> + /* All data is now stored in the phy struct, so register it */
> + rc = phy_device_register(phy);
> + if (rc) {
> + phy_device_free(phy);
> + fwnode_handle_put(child);
Shouldn't mdio.dev.fwnode be put rather than child (yes, I see the assignment)
> + return rc;
> + }
> +
> + dev_dbg(&bus->dev, "registered phy at address %i\n", addr);
> +
> + return 0;
> +}
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists