i2c-gpio: condition is always false
Simon Glass
sjg at chromium.org
Sun Oct 30 02:44:02 CET 2022
Hi Sergei,
On Thu, 20 Oct 2022 at 08:50, Sergei Antonov <saproj at gmail.com> wrote:
>
> Hello!
> Please look at this code from drivers/i2c/i2c-gpio.c:
>
> static int i2c_gpio_of_to_plat(struct udevice *dev)
> {
> struct i2c_gpio_bus *bus = dev_get_priv(dev);
> int ret;
>
> /* "gpios" is deprecated and replaced by "sda-gpios" + "scl-gpios". */
> ret = gpio_request_list_by_name(dev, "gpios", bus->gpios,
> ARRAY_SIZE(bus->gpios), 0);
> if (ret == -ENOENT) {
>
> The condition is always false because in
> gpio_request_list_by_name_nodev(), if entry is not found, this code
> will work:
> if (ret == -ENOENT)
> break;
> and then
> return count;
> return zero.
Well the gpio_request_list_by_name() function needs a better comment
re the return value and an update to test/dm/gpio.c to test this case.
Perhaps it should return -ENOENT when the property does not exist at all?
Also i2c_gpio_of_to_plat() could check for ret being less that
ARRAY_SIZE(bus->gpios)
Regards,
Simon
More information about the U-Boot
mailing list