[PATCH net-next v2 5/8] net: dsa: mt7530: replace mt7530_read with regmap_read
Jakub Kicinski
kuba at kernel.org
Mon Jun 15 17:15:21 PDT 2026
On Mon, 15 Jun 2026 16:56:49 -0700 Jakub Kicinski wrote:
> > static u32
> > -mt7530_read(struct mt7530_priv *priv, u32 reg)
> > +mt7530_mii_poll(struct mt7530_dummy_poll *p)
> > {
> > - int ret;
> > u32 val;
> >
> > - ret = regmap_read(priv->regmap, reg, &val);
> > - if (ret) {
> > - WARN_ON_ONCE(1);
> > - dev_err(priv->dev,
> > - "failed to read mt7530 register\n");
> > - return 0;
> > - }
> > + regmap_read(p->priv->regmap, p->reg, &val);
> >
> > return val;
> > }
>
> [Medium]
> The old wrapper guaranteed val == 0 on failure. The new mt7530_mii_poll()
> declares val without an initializer and ignores the regmap_read() return
> code, so on a failed underlying transfer val is whatever was on the stack.
>
> Looking at drivers/net/dsa/mt7530-mdio.c::mt7530_regmap_read():
>
> ret = bus->write(bus, priv->mdiodev->addr, 0x1f, page);
> if (ret < 0)
> return ret;
>
> lo = bus->read(bus, priv->mdiodev->addr, r);
> hi = bus->read(bus, priv->mdiodev->addr, 0x10);
>
> *val = (hi << 16) | (lo & 0xffff);
This looks legit, AFAICT, sadly.
Maybe just write *val = 0; in mt7530_regmap_read() unconditionally ?
More information about the linux-arm-kernel
mailing list