From: Jean-Jacques Hiblot Date: Thu, 11 Oct 2018 14:01:20 +0200 Subject: [U-Boot] [PATCH v2 02/19] dm: i2c: Add dm_i2c_probe_device() to test the presence of a chip In-Reply-To: References: <1538757935-6481-1-git-send-email-jjhiblot@ti.com> <1538757935-6481-3-git-send-email-jjhiblot@ti.com> Message-ID: <271799f4-18cd-29ed-66df-81778a1f697c@ti.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Simon, thanks for the reviews. On 11/10/2018 05:13, Simon Glass wrote: > Hi Jean-Jacques, > > On 5 October 2018 at 10:45, Jean-Jacques Hiblot wrote: >> In a non-DM environment, it is possible to test the presence of a chip >> using i2c_probe(chip_addr). >> dm_i2c_probe_device() brings the same functionality with a DM interface. >> The intent is to be able to test the presence of a chip for the device has >> been created with i2c_get_chip_for_busnum(bus_num, chip_addr, ...) >> >> Signed-off-by: Jean-Jacques Hiblot >> --- >> >> Changes in v2: None >> >> drivers/i2c/i2c-uclass.c | 8 ++++++++ >> include/i2c.h | 13 +++++++++++++ >> 2 files changed, 21 insertions(+) >> >> diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c >> index c5a3c4e..ec88168 100644 >> --- a/drivers/i2c/i2c-uclass.c >> +++ b/drivers/i2c/i2c-uclass.c >> @@ -378,6 +378,14 @@ int dm_i2c_probe(struct udevice *bus, uint chip_addr, uint chip_flags, >> return ret; >> } >> >> +int dm_i2c_probe_device(struct udevice *dev) >> +{ >> + struct udevice *bus = dev_get_parent(dev); >> + struct dm_i2c_chip *chip = dev_get_parent_platdata(dev); >> + >> + return i2c_probe_chip(bus, chip->chip_addr, chip->flags); >> +} > Why not just probe the device? That should have the same effect. The device itself is not probed when using i2c_get_chip_for_busnum(). I could have changed it there but was sure about possible side-effects on all boards. The code that uses the non-DM API usually calls I2C_probe() at some point, this function is the equivalent in the DM world. JJ > > Regards, > Simon >