From c88da3b94d9bfbce75b6213db6c2982ebfd9de1c Mon Sep 17 00:00:00 2001 From: Ian Lepore Date: Mon, 12 Oct 2020 18:02:51 +0000 Subject: [PATCH] Bug fixes for the ads111x driver... make configurable gain and sample rate hints work on per-channel basis as documented, rather than chip-wide. Also, when configured via hints, return BUS_PROBE_NOWILDCARD on successful hints match, so that the hints don't bogusly match other types of i2c chips. --- sys/dev/iicbus/ads111x.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sys/dev/iicbus/ads111x.c b/sys/dev/iicbus/ads111x.c index 724b2a9a0fd7..5d7057d99b91 100644 --- a/sys/dev/iicbus/ads111x.c +++ b/sys/dev/iicbus/ads111x.c @@ -456,12 +456,15 @@ ads111x_add_channels(struct ads111x_softc *sc) name = device_get_name(sc->dev); unit = device_get_unit(sc->dev); for (chan = 0; chan < sc->chipinfo->numchan; ++chan) { + char resname[16]; found = false; gainidx = DEFAULT_GAINIDX; rateidx = DEFAULT_RATEIDX; - if (resource_int_value(name, unit, "gain_index", &gainidx) == 0) + snprintf(resname, sizeof(resname), "%d.gain_index", chan); + if (resource_int_value(name, unit, resname, &gainidx) == 0) found = true; - if (resource_int_value(name, unit, "rate_index", &gainidx) == 0) + snprintf(resname, sizeof(resname), "%d.rate_index", chan); + if (resource_int_value(name, unit, resname, &rateidx) == 0) found = true; if (found) { ads111x_setup_channel(sc, chan, gainidx, rateidx); @@ -522,7 +525,11 @@ ads111x_probe(device_t dev) info = ads111x_find_chipinfo(dev); if (info != NULL) { device_set_desc(dev, info->name); +#ifdef FDT return (BUS_PROBE_DEFAULT); +#else + return (BUS_PROBE_NOWILDCARD); +#endif } return (ENXIO);