[U-Boot] [PATCH 04/24] dm: i2c: Implement 'i2c bus' command for driver model
Simon Glass
sjg at chromium.org
Wed May 6 16:34:36 CEST 2015
Hi Heiko,
On 5 May 2015 at 23:44, Heiko Schocher <hs at denx.de> wrote:
> Hello Simon,
>
>
> Am 04.05.2015 19:30, schrieb Simon Glass:
>>
>> This command was missed in the conversion. Add it back for driver model.
>>
>> Signed-off-by: Simon Glass <sjg at chromium.org>
>> ---
>>
>> common/cmd_i2c.c | 63
>> +++++++++++++++++++++++++++++++++++++++++++++++++-------
>> 1 file changed, 55 insertions(+), 8 deletions(-)
>>
>> diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
>> index ad38cbf..1bc0db8 100644
>> --- a/common/cmd_i2c.c
>> +++ b/common/cmd_i2c.c
>> @@ -1623,6 +1623,27 @@ int do_edid(cmd_tbl_t *cmdtp, int flag, int argc,
>> char *const argv[])
>> }
>> #endif /* CONFIG_I2C_EDID */
>>
>> +#ifdef CONFIG_DM_I2C
>> +static void show_bus(struct udevice *bus)
>> +{
>> + struct udevice *dev;
>> +
>> + printf("Bus %d:\t%s", bus->req_seq, bus->name);
>> + if (device_active(bus))
>> + printf(" (active %d)", bus->seq);
>> + printf("\n");
>> + for (device_find_first_child(bus, &dev);
>> + dev;
>> + device_find_next_child(&dev)) {
>> + struct dm_i2c_chip *chip = dev_get_parent_platdata(dev);
>> +
>> + printf(" %02x: %s, offset len %x, flags %x\n",
>> + chip->chip_addr, dev->name, chip->offset_len,
>> + chip->flags);
>> + }
>> +}
>> +#endif
>> +
>> /**
>> * do_i2c_show_bus() - Handle the "i2c bus" command-line command
>> * @cmdtp: Command data struct pointer
>> @@ -1632,20 +1653,30 @@ int do_edid(cmd_tbl_t *cmdtp, int flag, int argc,
>> char *const argv[])
>> *
>> * Returns zero always.
>> */
>> -#if defined(CONFIG_SYS_I2C)
>> +#if defined(CONFIG_SYS_I2C) || defined(CONFIG_DM_I2C)
>> static int do_i2c_show_bus(cmd_tbl_t *cmdtp, int flag, int argc,
>> char * const argv[])
>> {
>> - int i;
>> -#ifndef CONFIG_SYS_I2C_DIRECT_BUS
>> - int j;
>> -#endif
>> -
>> if (argc == 1) {
>> /* show all busses */
>> +#ifdef CONFIG_DM_I2C
>> + struct udevice *bus;
>> + struct uclass *uc;
>> + int ret;
>> +
>> + ret = uclass_get(UCLASS_I2C, &uc);
>> + if (ret)
>> + return CMD_RET_FAILURE;
>> + uclass_foreach_dev(bus, uc)
>> + show_bus(bus);
>> +#else
>> + int i;
>> +
>> for (i = 0; i < CONFIG_SYS_NUM_I2C_BUSES; i++) {
>> printf("Bus %d:\t%s", i, I2C_ADAP_NR(i)->name);
>> #ifndef CONFIG_SYS_I2C_DIRECT_BUS
>> + int j;
>> +
>
>
> I thought this drops an error, because var j is declared in the middle of
> code, but just tried it with gcc 4.7.2 and gcc 4.8.1 vor the mgcoge board,
> drops no warning, so:
>
> Acked-by: Heiko Schocher <hs at denx.de>
Yes, I probably shouldn't do that.
[snip]
Regards,
Simon
More information about the U-Boot
mailing list