diff options
| author | Warner Losh <imp@FreeBSD.org> | 2025-09-14 17:12:38 +0000 |
|---|---|---|
| committer | Warner Losh <imp@FreeBSD.org> | 2025-09-14 17:12:38 +0000 |
| commit | 4b301f7e7ab43bb61561786c2ab33f3a3c4a725d (patch) | |
| tree | 7d1d43878d797921ae990138c1e74b63c9dbebd4 | |
| parent | 455426da078cbbea8160bf4232b3fd1ae56e2ff5 (diff) | |
iicbb: Fix gcc12 complaint
So gcc12 doesn't understand that t->udelay is >= 1, so thinks that noack
might be unset sometimes. While we specifically constrain this on direct
assignment, there's a sysctl that might not. This is likely also a bug.
Instead of uglifying everything by using MAX(1, sc->udelay), I rewrote
the for loop as a do-while loop (which arguably dictates intent better
because this code clearly assumes it will be executed once).
Sponsored by: Netflix
| -rw-r--r-- | sys/dev/iicbus/iicbb.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/dev/iicbus/iicbb.c b/sys/dev/iicbus/iicbb.c index c344bda930b0..5f6423135f46 100644 --- a/sys/dev/iicbus/iicbb.c +++ b/sys/dev/iicbus/iicbb.c @@ -331,7 +331,7 @@ iicbb_getack(device_t dev) { struct iicbb_softc *sc = device_get_softc(dev); int noack, err; - int t; + int t = 0; /* Release SDA so that the slave can drive it. */ err = iicbb_clockin(dev, 1); @@ -341,12 +341,13 @@ iicbb_getack(device_t dev) } /* Sample SDA until ACK (low) or udelay runs out. */ - for (t = 0; t < sc->udelay; t++) { + do { noack = I2C_GETSDA(dev); if (!noack) break; DELAY(1); - } + t++; + } while(t < sc->udelay); DELAY(sc->udelay - t); iicbb_clockout(dev); |
