Re: [PATCH net-next v1 2/7] net: usb: asix: ax88772: add phylib support

From: Andrew Lunn
Date: Fri Jun 04 2021 - 19:19:06 EST


On Fri, Jun 04, 2021 at 03:42:39PM +0200, Oleksij Rempel wrote:
> To be able to use ax88772 with external PHYs and use advantage of

s/use/take/

> +/* MDIO read and write wrappers for phylib */
> +int asix_mdio_bus_read(struct mii_bus *bus, int phy_id, int regnum)
> +{
> + return asix_mdio_read(((struct usbnet *)bus->priv)->net, phy_id,
> + regnum);
> +}

Please avoid this cast. priv should be a void *, so you can do

struct usbnet *priv = bus->priv;

return asix_mdio_read(priv->net, phy_id, regnum);

> +static int ax88772_init_phy(struct usbnet *dev)
> +{
> + struct asix_common_private *priv = dev->driver_priv;
> + int ret;
> +
> + priv->phy_addr = asix_get_phy_addr(dev);
> + /* asix_read_phy_addr() is using ret < 2 as error value */
> + if (priv->phy_addr < 2)
> + return -ENODEV;

Really?

ax88172a.c does not check. ax88172_bind() does not
check. ax88772_bind() does not check. As far as i can see, nothing
really cares.

So please add another cleanup patch and make asix_read_phy_addr()
return -ENODEV.

Otherwise, this looks O.K.