bus->read() returns a negative errno on failure, but mt7530_regmap_read() assigns it to a u16, truncating e.g. -ETIMEDOUT into 0xff92, and returns success. The garbage word is then consumed as register data, and read-modify-write cycles write it back to the switch. Check both reads and propagate their errors. The same defect existed in mt7530_mii_read() since the driver was introduced and moved into the regmap backend unchanged.
Unified · Split
| @@ -55,8 +55,15 @@ mt7530_regmap_read(void *context, unsigned int reg, unsigned int *val) · 54 unmodified lines | ||
| 55 | 55 | if (ret < 0) |
| 56 | 56 | return ret; |
| 57 | 57 | |
| 58 | − lo = bus->read(bus, priv->mdiodev->addr, r); | |
| 59 | − hi = bus->read(bus, priv->mdiodev->addr, 0x10); | |
| 58 | + ret = bus->read(bus, priv->mdiodev->addr, r); | |
| 59 | + if (ret < 0) | |
| 60 | + return ret; | |
| 61 | + lo = ret; | |
| 62 | + | |
| 63 | + ret = bus->read(bus, priv->mdiodev->addr, 0x10); | |
| 64 | + if (ret < 0) | |
| 65 | + return ret; | |
| 66 | + hi = ret; | |
| 60 | 67 | |
| 61 | 68 | *val = (hi << 16) | (lo & 0xffff); |
| 62 | 69 | |