]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
i2c: i2c-gpio: Correctly handle new {sda, scl}-gpios bindings
authorChris Packham <judge.packham@gmail.com>
Tue, 25 Jul 2023 23:13:08 +0000 (11:13 +1200)
committerStefan Roese <sr@denx.de>
Mon, 31 Jul 2023 11:50:57 +0000 (13:50 +0200)
gpio_request_list_by_name() returns the number of gpios requested.
Notably it swallows the underlying -ENOENT when the "gpios" property
does not exist.

Update the i2c-gpio driver to check for ret == 0 before trying the new
sda-gpios/scl-gpios properties.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
drivers/i2c/i2c-gpio.c

index 4ed9e9e7cdddd835f4892f7d05adc0cc6faa4836..c1fc290bd253e8d87ba1e01a4c0b74e7a7eebeae 100644 (file)
@@ -339,7 +339,7 @@ static int i2c_gpio_of_to_plat(struct udevice *dev)
        /* "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) {
+       if (ret == 0) {
                ret = gpio_request_by_name(dev, "sda-gpios", 0,
                                           &bus->gpios[PIN_SDA], 0);
                if (ret < 0)