lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75Vf_wcW3K64uM8i6Cp9rz9jrD-Y3BO6S10Xt8d5Bx3N-Rg@mail.gmail.com>
Date:   Thu, 9 Jul 2020 23:43:44 +0300
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Calvin Johnson <calvin.johnson@....nxp.com>
Cc:     Jeremy Linton <jeremy.linton@....com>,
        Russell King - ARM Linux admin <linux@...linux.org.uk>,
        Jon <jon@...id-run.com>,
        Cristi Sovaiala <cristian.sovaiala@....com>,
        Ioana Ciornei <ioana.ciornei@....com>,
        Andrew Lunn <andrew@...n.ch>,
        Florian Fainelli <f.fainelli@...il.com>,
        Madalin Bucur <madalin.bucur@....nxp.com>,
        ACPI Devel Maling List <linux-acpi@...r.kernel.org>,
        linux.cj@...il.com, netdev <netdev@...r.kernel.org>
Subject: Re: [net-next PATCH v4 4/6] net: phy: introduce phy_find_by_fwnode()

On Thu, Jul 9, 2020 at 8:57 PM Calvin Johnson
<calvin.johnson@....nxp.com> wrote:
>
> The PHYs on an mdiobus are probed and registered using mdiobus_register().
> Later, for connecting these PHYs to MAC, the PHYs registered on the
> mdiobus have to be referenced.
>
> For each MAC node, a property "mdio-handle" is used to reference the
> MDIO bus on which the PHYs are registered. On getting hold of the MDIO
> bus, use phy_find_by_fwnode() to get the PHY connected to the MAC.
>
> Introduce fwnode_mdio_find_bus() to find the mii_bus that corresponds
> to given mii_bus fwnode.

...

> +struct phy_device *phy_find_by_fwnode(struct fwnode_handle *fwnode)
> +{
> +       struct fwnode_handle *fwnode_mdio;
> +       struct mii_bus *mdio;
> +       int addr;
> +       int err;
> +
> +       fwnode_mdio = fwnode_find_reference(fwnode, "mdio-handle", 0);
> +       mdio = fwnode_mdio_find_bus(fwnode_mdio);
> +       fwnode_handle_put(fwnode_mdio);
> +       if (!mdio)
> +               return ERR_PTR(-ENODEV);

> +       err = fwnode_property_read_u32(fwnode, "phy-channel", &addr);
> +       if (err < 0 || addr < 0 || addr >= PHY_MAX_ADDR)
> +               return ERR_PTR(-EINVAL);

I'm wondering why this is written like above and not like below

err = ...
if (err)
  return ERR_PTR(err);
if (...)
 return ERR_PTR(-E...);

?

> +       return mdiobus_get_phy(mdio, addr);
> +}

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ