pinctrl: change the signature of pinctrl_match_gpio_range()
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Tue, 10 Oct 2023 14:13:14 +0000 (16:13 +0200)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Sat, 4 Nov 2023 09:23:22 +0000 (10:23 +0100)
Modify pinctrl_match_gpio_range() to be in line with public GPIO
helpers and take a pair of GPIO chip & offset as arguments.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/core.c

index a560df8bf27534961b3346b94c83e6fda78b84b3..9e454d0b18b49d02a5a2482dbeb48543d4d6807c 100644 (file)
@@ -292,13 +292,15 @@ static inline int gpio_to_pin(struct pinctrl_gpio_range *range,
 /**
  * pinctrl_match_gpio_range() - check if a certain GPIO pin is in range
  * @pctldev: pin controller device to check
- * @gpio: gpio pin to check taken from the global GPIO pin space
+ * @gc: GPIO chip structure from the GPIO subsystem
+ * @offset: hardware offset of the GPIO relative to the controller
  *
  * Tries to match a GPIO pin number to the ranges handled by a certain pin
  * controller, return the range or NULL
  */
 static struct pinctrl_gpio_range *
-pinctrl_match_gpio_range(struct pinctrl_dev *pctldev, unsigned gpio)
+pinctrl_match_gpio_range(struct pinctrl_dev *pctldev, struct gpio_chip *gc,
+                        unsigned int offset)
 {
        struct pinctrl_gpio_range *range;
 
@@ -306,8 +308,8 @@ pinctrl_match_gpio_range(struct pinctrl_dev *pctldev, unsigned gpio)
        /* Loop over the ranges */
        list_for_each_entry(range, &pctldev->gpio_ranges, node) {
                /* Check if we're in the valid range */
-               if (gpio >= range->base &&
-                   gpio < range->base + range->npins) {
+               if ((gc->base + offset) >= range->base &&
+                   (gc->base + offset) < range->base + range->npins) {
                        mutex_unlock(&pctldev->mutex);
                        return range;
                }
@@ -395,7 +397,7 @@ static int pinctrl_get_device_gpio_range(struct gpio_chip *gc,
        list_for_each_entry(pctldev, &pinctrldev_list, node) {
                struct pinctrl_gpio_range *range;
 
-               range = pinctrl_match_gpio_range(pctldev, gc->base + offset);
+               range = pinctrl_match_gpio_range(pctldev, gc, offset);
                if (range) {
                        *outdev = pctldev;
                        *outrange = range;