Skip to content

Commit e3863fa

Browse files
linuswBartosz Golaszewski
authored andcommitted
gpio: Get rid of gpio_to_chip()
The gpio_to_chip() function refers to the global GPIO numberspace which is a problem we want to get rid of. Get this function out of the header and open code it into gpiolib with appropriate FIXME notices so no new users appear in the kernel. Signed-off-by: Linus Walleij <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 5143530 commit e3863fa

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

drivers/pinctrl/core.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,12 @@ static bool pinctrl_ready_for_gpio_range(unsigned gpio)
325325
{
326326
struct pinctrl_dev *pctldev;
327327
struct pinctrl_gpio_range *range = NULL;
328-
struct gpio_chip *chip = gpio_to_chip(gpio);
328+
/*
329+
* FIXME: "gpio" here is a number in the global GPIO numberspace.
330+
* get rid of this from the ranges eventually and get the GPIO
331+
* descriptor from the gpio_chip.
332+
*/
333+
struct gpio_chip *chip = gpiod_to_chip(gpio_to_desc(gpio));
329334

330335
if (WARN(!chip, "no gpio_chip for gpio%i?", gpio))
331336
return false;
@@ -1657,7 +1662,12 @@ static int pinctrl_pins_show(struct seq_file *s, void *what)
16571662
}
16581663
}
16591664
if (gpio_num >= 0)
1660-
chip = gpio_to_chip(gpio_num);
1665+
/*
1666+
* FIXME: gpio_num comes from the global GPIO numberspace.
1667+
* we need to get rid of the range->base eventually and
1668+
* get the descriptor directly from the gpio_chip.
1669+
*/
1670+
chip = gpiod_to_chip(gpio_to_desc(gpio_num));
16611671
else
16621672
chip = NULL;
16631673
if (chip)

include/asm-generic/gpio.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@ struct module;
3131
struct device_node;
3232
struct gpio_desc;
3333

34-
/* caller holds gpio_lock *OR* gpio is marked as requested */
35-
static inline struct gpio_chip *gpio_to_chip(unsigned gpio)
36-
{
37-
return gpiod_to_chip(gpio_to_desc(gpio));
38-
}
39-
4034
/* Always use the library code for GPIO management calls,
4135
* or when sleeping may be involved.
4236
*/

0 commit comments

Comments
 (0)