]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: i2c: fix i2c-shared-gpio range check
authorMarkus Stockhausen <markus.stockhausen@gmx.de>
Sat, 21 Mar 2026 13:01:23 +0000 (14:01 +0100)
committerRobert Marko <robimarko@gmail.com>
Wed, 25 Mar 2026 09:28:10 +0000 (10:28 +0100)
The i2c-shared-gpio driver is designed to emulate up to four
i2c busses with distinct sda lines and a a shared scl line.
For some reason the check for the number of allowed busses
is one off and the driver can only allocate three busses.
Fix that.

Fixes: acd7ecc9ed8 ("realtek: add new i2c-gpio-shared driver")
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/22543
Signed-off-by: Robert Marko <robimarko@gmail.com>
target/linux/realtek/files-6.12/drivers/i2c/busses/i2c-gpio-shared.c

index e7f817abd7756566e1feeaa8fb4c99c293957635..37930af7264b5e2267dbadb9ab364cb4778c4e21 100644 (file)
@@ -10,6 +10,8 @@
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
 
+#define GPIO_SHARED_MAX_BUS    4
+
 struct gpio_shared_ctx;
 
 struct gpio_shared_bus {
@@ -20,8 +22,6 @@ struct gpio_shared_bus {
        struct gpio_shared_ctx *ctx;
 };
 
-#define GPIO_SHARED_MAX_BUS    4
-
 struct gpio_shared_ctx {
        struct device *dev;
        struct gpio_desc *scl;
@@ -97,7 +97,7 @@ static int gpio_shared_probe(struct platform_device *pdev)
        if (IS_ERR(ctx->scl))
                return dev_err_probe(dev, PTR_ERR(ctx->scl), "shared SCL node not found\n");
 
-       if (device_get_child_node_count(dev) >= GPIO_SHARED_MAX_BUS)
+       if (device_get_child_node_count(dev) > GPIO_SHARED_MAX_BUS)
                return dev_err_probe(dev, -EINVAL, "Too many channels\n");
 
        device_for_each_child_node(dev, child) {