@@ -322,7 +322,8 @@ pinctrl_match_gpio_range(struct pinctrl_dev *pctldev, struct gpio_chip *gc,
322
322
/**
323
323
* pinctrl_ready_for_gpio_range() - check if other GPIO pins of
324
324
* 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
326
327
*
327
328
* This function is complement of pinctrl_match_gpio_range(). If the return
328
329
* 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,
333
334
* is false, it means that pinctrl device may not be ready.
334
335
*/
335
336
#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 )
337
339
{
338
340
struct pinctrl_dev * pctldev ;
339
341
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;
349
342
350
343
mutex_lock (& pinctrldev_list_mutex );
351
344
@@ -355,8 +348,8 @@ static bool pinctrl_ready_for_gpio_range(unsigned gpio)
355
348
mutex_lock (& pctldev -> mutex );
356
349
list_for_each_entry (range , & pctldev -> gpio_ranges , node ) {
357
350
/* 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 )
360
353
continue ;
361
354
mutex_unlock (& pctldev -> mutex );
362
355
mutex_unlock (& pinctrldev_list_mutex );
@@ -370,7 +363,11 @@ static bool pinctrl_ready_for_gpio_range(unsigned gpio)
370
363
return false;
371
364
}
372
365
#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
+ }
374
371
#endif
375
372
376
373
/**
@@ -805,7 +802,7 @@ int pinctrl_gpio_request(struct gpio_chip *gc, unsigned int offset)
805
802
806
803
ret = pinctrl_get_device_gpio_range (gc , offset , & pctldev , & range );
807
804
if (ret ) {
808
- if (pinctrl_ready_for_gpio_range (gc -> base + offset ))
805
+ if (pinctrl_ready_for_gpio_range (gc , offset ))
809
806
ret = 0 ;
810
807
return ret ;
811
808
}
0 commit comments