Skip to content

Commit

Permalink
gpio: Get rid of gpio_to_chip()
Browse files Browse the repository at this point in the history
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 <linus.walleij@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
  • Loading branch information
Linus Walleij authored and Bartosz Golaszewski committed Jan 30, 2023
1 parent 5143530 commit e3863fa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
14 changes: 12 additions & 2 deletions drivers/pinctrl/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,12 @@ static bool pinctrl_ready_for_gpio_range(unsigned gpio)
{
struct pinctrl_dev *pctldev;
struct pinctrl_gpio_range *range = NULL;
struct gpio_chip *chip = gpio_to_chip(gpio);
/*
* FIXME: "gpio" here is a number in the global GPIO numberspace.
* get rid of this from the ranges eventually and get the GPIO
* descriptor from the gpio_chip.
*/
struct gpio_chip *chip = gpiod_to_chip(gpio_to_desc(gpio));

if (WARN(!chip, "no gpio_chip for gpio%i?", gpio))
return false;
Expand Down Expand Up @@ -1657,7 +1662,12 @@ static int pinctrl_pins_show(struct seq_file *s, void *what)
}
}
if (gpio_num >= 0)
chip = gpio_to_chip(gpio_num);
/*
* FIXME: gpio_num comes from the global GPIO numberspace.
* we need to get rid of the range->base eventually and
* get the descriptor directly from the gpio_chip.
*/
chip = gpiod_to_chip(gpio_to_desc(gpio_num));
else
chip = NULL;
if (chip)
Expand Down
6 changes: 0 additions & 6 deletions include/asm-generic/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ struct module;
struct device_node;
struct gpio_desc;

/* caller holds gpio_lock *OR* gpio is marked as requested */
static inline struct gpio_chip *gpio_to_chip(unsigned gpio)
{
return gpiod_to_chip(gpio_to_desc(gpio));
}

/* Always use the library code for GPIO management calls,
* or when sleeping may be involved.
*/
Expand Down

0 comments on commit e3863fa

Please sign in to comment.