Skip to content

Commit b056ca1

Browse files
committed
gpiolib: Introduce ->add_pin_ranges() callback
When IRQ chip is being added by GPIO library, the ACPI based platform expects GPIO <-> pin mapping ranges to be initialized in order to correctly initialize ACPI event mechanism on affected platforms. Unfortunately this step is missed. Introduce ->add_pin_ranges() callback to fill the above mentioned gap. Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Reviewed-by: Mika Westerberg <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Tested-by: Hans de Goede <[email protected]>
1 parent 6b240ae commit b056ca1

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

drivers/gpio/gpiolib.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,14 @@ static void gpiochip_free_valid_mask(struct gpio_chip *gpiochip)
390390
gpiochip->valid_mask = NULL;
391391
}
392392

393+
static int gpiochip_add_pin_ranges(struct gpio_chip *gc)
394+
{
395+
if (gc->add_pin_ranges)
396+
return gc->add_pin_ranges(gc);
397+
398+
return 0;
399+
}
400+
393401
bool gpiochip_line_is_valid(const struct gpio_chip *gpiochip,
394402
unsigned int offset)
395403
{
@@ -1397,6 +1405,10 @@ int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data,
13971405
}
13981406
}
13991407

1408+
ret = gpiochip_add_pin_ranges(chip);
1409+
if (ret)
1410+
goto err_remove_of_chip;
1411+
14001412
acpi_gpiochip_add(chip);
14011413

14021414
machine_gpiochip_add(chip);

include/linux/gpio/driver.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,9 @@ struct gpio_irq_chip {
289289
* state (such as pullup/pulldown configuration).
290290
* @init_valid_mask: optional routine to initialize @valid_mask, to be used if
291291
* not all GPIOs are valid.
292+
* @add_pin_ranges: optional routine to initialize pin ranges, to be used when
293+
* requires special mapping of the pins that provides GPIO functionality.
294+
* It is called after adding GPIO chip and before adding IRQ chip.
292295
* @base: identifies the first GPIO number handled by this chip;
293296
* or, if negative during registration, requests dynamic ID allocation.
294297
* DEPRECATION: providing anything non-negative and nailing the base
@@ -379,6 +382,8 @@ struct gpio_chip {
379382
unsigned long *valid_mask,
380383
unsigned int ngpios);
381384

385+
int (*add_pin_ranges)(struct gpio_chip *chip);
386+
382387
int base;
383388
u16 ngpio;
384389
const char *const *names;

0 commit comments

Comments
 (0)