Hi Johan, On Mon, 19 Dec 2022 at 12:57, Johan Korsnes <johan.kors...@remarkable.no> wrote: > > Add function to determine whether a chip is present. This check is > typically implemented by writing the chip address to the bus and > checking that the chip replies with an ACK. > > The already existing dm_i2c_probe() will attempt to bind/probe the > relevant driver if the chip is present. This makes it unsuitable for > situations where one only wants to know the presence of a chip. > > Signed-off-by: Johan Korsnes <johan.kors...@remarkable.no> > Cc: Eirik Schultz <schultz...@gmail.com> > Cc: Heiko Schocher <h...@denx.de> > Cc: Simon Glass <s...@chromium.org> > > --- > Previously, I've used i2c_probe() to determine whether or not an i2c > chip is present on an i2c bus. With the introduction of the driver model > this function is deprecated. Fortunately, I found dm_i2c_probe(), which > I expected to perform the same check, it was even documented to be > suitable for this purpose: > > ``` > dm_i2c_probe() - probe a particular chip address > > This can be useful to check for the existence of a chip on the bus. > It is typically implemented by writing the chip address to the bus > and checking that the chip replies with an ACK. > ``` > > Unfortunately, it does not seem to be a replacement. It seems > dm_i2c_probe() will attempt to bind/probe a driver if the chip is > present, and will in turn return the return value from the driver > probe/bind attempt. > --- > drivers/i2c/i2c-uclass.c | 11 +++++++++++ > include/i2c.h | 16 +++++++++++++--- > 2 files changed, 24 insertions(+), 3 deletions(-)
This looks OK but please add a test to dm/test/i2c.c for your new function. https://u-boot.readthedocs.io/en/latest/develop/testing.html Regards, Simon