Skip to content

Commit 6042aae

Browse files
author
Bartosz Golaszewski
committed
pinctrl: change the signature of pinctrl_ready_for_gpio_range()
Modify pinctrl_ready_for_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 <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Acked-by: Linus Walleij <[email protected]>
1 parent 31d4e8d commit 6042aae

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

drivers/pinctrl/core.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ pinctrl_match_gpio_range(struct pinctrl_dev *pctldev, struct gpio_chip *gc,
322322
/**
323323
* pinctrl_ready_for_gpio_range() - check if other GPIO pins of
324324
* the same GPIO chip are in range
325-
* @gpio: gpio pin to check taken from the global GPIO pin space
325+
* @gc: GPIO chip structure from the GPIO subsystem
326+
* @offset: hardware offset of the GPIO relative to the controller
326327
*
327328
* This function is complement of pinctrl_match_gpio_range(). If the return
328329
* value of pinctrl_match_gpio_range() is NULL, this function could be used
@@ -333,19 +334,11 @@ pinctrl_match_gpio_range(struct pinctrl_dev *pctldev, struct gpio_chip *gc,
333334
* is false, it means that pinctrl device may not be ready.
334335
*/
335336
#ifdef CONFIG_GPIOLIB
336-
static bool pinctrl_ready_for_gpio_range(unsigned gpio)
337+
static bool pinctrl_ready_for_gpio_range(struct gpio_chip *gc,
338+
unsigned int offset)
337339
{
338340
struct pinctrl_dev *pctldev;
339341
struct pinctrl_gpio_range *range = NULL;
340-
/*
341-
* FIXME: "gpio" here is a number in the global GPIO numberspace.
342-
* get rid of this from the ranges eventually and get the GPIO
343-
* descriptor from the gpio_chip.
344-
*/
345-
struct gpio_chip *chip = gpiod_to_chip(gpio_to_desc(gpio));
346-
347-
if (WARN(!chip, "no gpio_chip for gpio%i?", gpio))
348-
return false;
349342

350343
mutex_lock(&pinctrldev_list_mutex);
351344

@@ -355,8 +348,8 @@ static bool pinctrl_ready_for_gpio_range(unsigned gpio)
355348
mutex_lock(&pctldev->mutex);
356349
list_for_each_entry(range, &pctldev->gpio_ranges, node) {
357350
/* Check if any gpio range overlapped with gpio chip */
358-
if (range->base + range->npins - 1 < chip->base ||
359-
range->base > chip->base + chip->ngpio - 1)
351+
if (range->base + range->npins - 1 < gc->base ||
352+
range->base > gc->base + gc->ngpio - 1)
360353
continue;
361354
mutex_unlock(&pctldev->mutex);
362355
mutex_unlock(&pinctrldev_list_mutex);
@@ -370,7 +363,11 @@ static bool pinctrl_ready_for_gpio_range(unsigned gpio)
370363
return false;
371364
}
372365
#else
373-
static bool pinctrl_ready_for_gpio_range(unsigned gpio) { return true; }
366+
static inline bool
367+
pinctrl_ready_for_gpio_range(struct gpio_chip *gc, unsigned int offset)
368+
{
369+
return true;
370+
}
374371
#endif
375372

376373
/**
@@ -805,7 +802,7 @@ int pinctrl_gpio_request(struct gpio_chip *gc, unsigned int offset)
805802

806803
ret = pinctrl_get_device_gpio_range(gc, offset, &pctldev, &range);
807804
if (ret) {
808-
if (pinctrl_ready_for_gpio_range(gc->base + offset))
805+
if (pinctrl_ready_for_gpio_range(gc, offset))
809806
ret = 0;
810807
return ret;
811808
}

0 commit comments

Comments
 (0)