[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YHdEJGhQlAVkSwWW@lunn.ch>
Date: Wed, 14 Apr 2021 21:36:04 +0200
From: Andrew Lunn <andrew@...n.ch>
To: Thomas Bogendoerfer <tsbogend@...ha.franken.de>
Cc: "David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next 1/7] net: korina: Fix MDIO functions
> +static int korina_mdio_wait(struct korina_private *lp)
> +{
> + int timeout = 1000;
> +
> + while ((readl(&lp->eth_regs->miimind) & 1) && timeout-- > 0)
> + udelay(1);
> +
> + if (timeout <= 0)
> + return -1;
> +
> + return 0;
Using readl_poll_timeout_atomic() would be better.
> +}
> +
> +static int korina_mdio_read(struct net_device *dev, int phy, int reg)
> {
> struct korina_private *lp = netdev_priv(dev);
> int ret;
>
> - mii_id = ((lp->rx_irq == 0x2c ? 1 : 0) << 8);
> + if (korina_mdio_wait(lp))
> + return -1;
This should really be -ETIMEDOUT
> dev->watchdog_timeo = TX_TIMEOUT;
> netif_napi_add(dev, &lp->napi, korina_poll, NAPI_POLL_WEIGHT);
>
> - lp->phy_addr = (((lp->rx_irq == 0x2c? 1:0) << 8) | 0x05);
> lp->mii_if.dev = dev;
> - lp->mii_if.mdio_read = mdio_read;
> - lp->mii_if.mdio_write = mdio_write;
> - lp->mii_if.phy_id = lp->phy_addr;
> + lp->mii_if.mdio_read = korina_mdio_read;
> + lp->mii_if.mdio_write = korina_mdio_write;
> + lp->mii_if.phy_id = 1;
> lp->mii_if.phy_id_mask = 0x1f;
> lp->mii_if.reg_num_mask = 0x1f;
You could also replace all the mii code with phylib.
Andrew
Powered by blists - more mailing lists