[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20171212204440.GC1523@lunn.ch>
Date: Tue, 12 Dec 2017 21:44:40 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Ard Biesheuvel <ard.biesheuvel@...aro.org>
Cc: Jassi Brar <jassisinghbrar@...il.com>,
"<netdev@...r.kernel.org>" <netdev@...r.kernel.org>,
"devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
"David S. Miller" <davem@...emloft.net>,
Arnd Bergmann <arnd.bergmann@...aro.org>,
Rob Herring <robh+dt@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Jassi Brar <jaswinder.singh@...aro.org>
Subject: Re: [PATCHv2 2/3] net: socionext: Add Synquacer NetSec driver
> > +static int netsec_register_mdio(struct netsec_priv *priv, u32 phy_addr)
> > +{
> > + struct mii_bus *bus;
> > + int ret;
> > +
> > + bus = devm_mdiobus_alloc(priv->dev);
> > + if (!bus)
> > + return -ENOMEM;
> > +
> > + snprintf(bus->id, MII_BUS_ID_SIZE, "%s", dev_name(priv->dev));
> > + bus->priv = priv;
> > + bus->name = "SNI NETSEC MDIO";
> > + bus->read = netsec_phy_read;
> > + bus->write = netsec_phy_write;
> > + bus->parent = priv->dev;
> > + priv->mii_bus = bus;
> > +
> > + if (dev_of_node(priv->dev)) {
> > + ret = of_mdiobus_register(bus, dev_of_node(priv->dev));
> > + if (ret) {
> > + dev_err(priv->dev, "mdiobus register err(%d)\n", ret);
> > + return ret;
> > + }
> > + } else {
> > + /* Mask out all PHYs from auto probing. */
> > + bus->phy_mask = ~0;
> > + ret = mdiobus_register(bus);
> > + if (ret) {
> > + dev_err(priv->dev, "mdiobus register err(%d)\n", ret);
> > + return ret;
> > + }
> > +
> > + priv->phydev = get_phy_device(priv->mii_bus, phy_addr, false);
> > + if (IS_ERR(priv->phydev)) {
> > + ret = PTR_ERR(priv->phydev);
> > + dev_err(priv->dev, "get_phy_device err(%d)\n", ret);
> > + priv->phydev = NULL;
> > + return -ENODEV;
> > + }
> > +
> > + ret = phy_device_register(priv->phydev);
> > + if (ret)
> > + dev_err(priv->dev,
> > + "phy_device_register err(%d)\n", ret);
You should unregister the mdio bus here.
> > + }
> > +
> > + return ret;
> > +}
Andrew
Powered by blists - more mailing lists