Re: [PATCH v9, 2/2] net: Add dm9051 driver

From: Andrew Lunn
Date: Tue Dec 28 2021 - 10:34:33 EST


> +static int dm9051_mdio_read(struct mii_bus *mdiobus, int phy_id, int reg)
> +{
> +       struct board_info *db = mdiobus->priv;
> +       int val, ret;
> +
> +       if (phy_id == DM9051_PHY_ID) {
> +               mutex_lock(&db->addr_lock);
> +               ret = dm9051_phy_read(db, reg, &val);
> +               mutex_unlock(&db->addr_lock);
> +               if (ret)
> +                       return ret;
> +               return val;
> +       }
> +
> +       return 0xffff;
>
>
>
> Hmm.. can we rather use regmap APIs for SPI and MDIO?

Hi Andy

regmap via MDIO is very new, but yes it exists. This driver just needs
SPI which has had regmap support for a long time.

However, i suspect the submitter is trying hard to keep the driver in
a shape they can reuse the core with other OSes. At least that is my
feeling give the way requests for changes are handled. Maybe forcing
the use of regmap is actually a good idea, to break them away from
that bad idea.

Andrew