[U-Boot] [PATCH v2 02/19] dm: i2c: Add dm_i2c_probe_device() to test the presence of a chip

Simon Glass sjg at chromium.org
Thu Oct 11 03:13:03 UTC 2018


Hi Jean-Jacques,

On 5 October 2018 at 10:45, Jean-Jacques Hiblot <jjhiblot at ti.com> 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 <jjhiblot at ti.com>
> ---
>
> 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.

Regards,
Simon


More information about the U-Boot mailing list