gpiolib: remove gpiochip_reserve()
Subsystems (5)
cover gpiolib: remove gpiochip_reserve()
The Tosa (Sharp SL-C6000x) target is the last remaining user of gpiochip_reserve(). I would like to get rid of this function as part of my project to totally remove the big static gpio_desc[] array of gpiolib. Patches that achieve this are written and working, but the presence of gpiochip_reserve() makes it necessary to maintain a list of "reserved" ranges in the GPIO space, which complexifies code that would be much simpler otherwise.
Even for Tosa the use of gpiochip_reserve() does not seem necessary - all GPIO controllers have their own base GPIO set AFAICT, so there should be no need to use it. And without any user in the kernel, there should be no reason to keep this function.
If Dmitri could give his Acked-by or Tested-by and one of the GPIO maintainers merge this series, I could go ahead with the deeper changes to gpiolib.
Thanks,
Alexandre Courbot (2):
arm: pxa: tosa: do not use gpiochip_reserve()
gpiolib: remove gpiochip_reserve()
arch/arm/mach-pxa/tosa.c | 6 ----- drivers/gpio/gpiolib.c | 58 +++++++--------------------------------------- include/asm-generic/gpio.h | 1 - 3 files changed, 8 insertions(+), 57 deletions(-)
Signature · 1 line
1.8.1.1
PATCH 1/2 arm: pxa: tosa: do not use gpiochip_reserve()
GPIO address space reservation during early platform initialization is not needed anymore for Tosa. Remove the calls to gpiochip_reserve() which is due to be removed.
--- arch/arm/mach-pxa/tosa.c | 6 ------ 1 file changed, 6 deletions(-)
arch/arm/mach-pxa/tosa.c +0 -6
@@ -927,8 +927,6 @@ static void tosa_restart(char mode, const char *cmd)static void __init tosa_init (void ) { -int dummy; -pxa2xx_mfp_config (ARRAY_AND_SIZE (tosa_pin_config));pxa_set_ffuart_info (NULL );
@@ -947,10 +945,6 @@ static void __init tosa_init(void)/* enable batt_fault */ PMCR =0x01 ; - dummy =gpiochip_reserve (TOSA_SCOOP_GPIO_BASE ,12 ); - dummy =gpiochip_reserve (TOSA_SCOOP_JC_GPIO_BASE ,12 ); - dummy =gpiochip_reserve (TOSA_TC6393XB_GPIO_BASE ,16 ); -pxa_set_mci_info (&tosa_mci_platform_data);pxa_set_ficp_info (&tosa_ficp_platform_data);pxa_set_i2c_info (NULL );
Signature · 1 line
1.8.1.1
Re: [PATCH 1/2] arm: pxa: tosa: do not use gpiochip_reserve()
Quoted 34 lines · Alexandre Courbot
GPIO address space reservation during early platform initialization is not needed anymore for Tosa. Remove the calls to
gpiochip_reserve()which is due to be removed.Signed-off-by Alexandre Courbot <[email protected]>--- arch/arm/mach-pxa/tosa.c | 6 ------ 1 file changed, 6 deletions(-)arch/arm/mach-pxa/tosa.c +0
-7@@ -927,8 +927,6 @@ static void tosa_restart(char mode, const char *cmd)static void __init tosa_init (void ) { -int dummy; -pxa2xx_mfp_config (ARRAY_AND_SIZE (tosa_pin_config));pxa_set_ffuart_info (NULL );@@ -947,10 +945,6 @@ static void __init tosa_init(void)/* enable batt_fault */ PMCR =0x01 ; - dummy =gpiochip_reserve (TOSA_SCOOP_GPIO_BASE ,12 ); - dummy =gpiochip_reserve (TOSA_SCOOP_JC_GPIO_BASE ,12 ); - dummy =gpiochip_reserve (TOSA_TC6393XB_GPIO_BASE ,16 ); -pxa_set_mci_info (&tosa_mci_platform_data);pxa_set_ficp_info (&tosa_ficp_platform_data);pxa_set_i2c_info (NULL ); --
Quoted 2 lines
1.8.1.1
Linus,
Could you help to merge this patch into your gpio git tree? I think that both of them should go through one git tree.
Regards
Haojian
Re: [PATCH 1/2] arm: pxa: tosa: do not use gpiochip_reserve()
Quoted 1 line · Haojian Zhuang
Acked-by Haojian Zhuang <[email protected]>
Thanks!
Quoted 4 lines
Linus,
Could you help to merge this patch into your gpio git tree? I think that both of them should go through one git tree.
Yep, already merged it.
Yours,
Linus Walleij
PATCH 2/2 gpiolib: remove gpiochip_reserve()
In reply to Alexandre Courbotgpiochip_reserve() has no user and stands in the way of the removal of the static gpio_desc[] array. Remove this function as well as the now unneeded RESERVED flag of struct gpio_desc.
--- drivers/gpio/gpiolib.c | 58 +++++++--------------------------------------- include/asm-generic/gpio.h | 1 - 2 files changed, 8 insertions(+), 51 deletions(-)
drivers/gpio/gpiolib.c +8 -50
@@ -52,14 +52,13 @@ struct gpio_desc {/* flag symbols are bit numbers */ #define FLAG_REQUESTED 0#define FLAG_IS_OUT 1 -#define FLAG_RESERVED 2 -#define FLAG_EXPORT 3/* protected by sysfs_lock */ -#define FLAG_SYSFS 4/* exported via /sys/class/gpio/control */ -#define FLAG_TRIG_FALL 5/* trigger on falling edge */ -#define FLAG_TRIG_RISE 6/* trigger on rising edge */ -#define FLAG_ACTIVE_LOW 7/* sysfs value has active low */ -#define FLAG_OPEN_DRAIN 8/* Gpio is open drain type */ -#define FLAG_OPEN_SOURCE 9/* Gpio is open source type */ +#define FLAG_EXPORT 2/* protected by sysfs_lock */ +#define FLAG_SYSFS 3/* exported via /sys/class/gpio/control */ +#define FLAG_TRIG_FALL 4/* trigger on falling edge */ +#define FLAG_TRIG_RISE 5/* trigger on rising edge */ +#define FLAG_ACTIVE_LOW 6/* sysfs value has active low */ +#define FLAG_OPEN_DRAIN 7/* Gpio is open drain type */ +#define FLAG_OPEN_SOURCE 8/* Gpio is open source type */ #define ID_SHIFT 16/* add new flags before this one */
@@ -132,7 +131,7 @@ static int gpiochip_find_base(int ngpio)struct gpio_desc *desc = &gpio_desc[i];struct gpio_chip *chip = desc->chip; -if (!chip && !test_bit (FLAG_RESERVED , &desc->flags)) { +if (!chip) { spare++;if (spare == ngpio) { base = i;
@@ -150,47 +149,6 @@ static int gpiochip_find_base(int ngpio)return base; } -/** -* gpiochip_reserve() - reserve range of gpios to use with platform code only -* @start: starting gpio number -* @ngpio: number of gpios to reserve -* Context: platform init, potentially before irqs or kmalloc will work -* -* Returns a negative errno if any gpio within the range is already reserved -* or registered, else returns zero as a success code. Use this function -* to mark a range of gpios as unavailable for dynamic gpio number allocation, -* for example because its driver support is not yet loaded. -*/ -int __init gpiochip_reserve (int start,int ngpio) -{ -int ret =0 ; -unsigned long flags; -int i; - -if (!gpio_is_valid (start) || !gpio_is_valid (start + ngpio -1 )) -return -EINVAL ; - -spin_lock_irqsave (&gpio_lock, flags); - -for (i = start; i < start + ngpio; i++) { -struct gpio_desc *desc = &gpio_desc[i]; - -if (desc->chip ||test_bit (FLAG_RESERVED , &desc->flags)) { - ret = -EBUSY ; - goto err; - } - -set_bit (FLAG_RESERVED , &desc->flags); - } - -pr_debug ("%s: reserved gpios from %d to %d\n" , - __func__, start, start + ngpio -1 ); -err: -spin_unlock_irqrestore (&gpio_lock, flags); - -return ret; -} -/* caller ensures gpio is valid and requested, chip->get_direction may sleep */ static int gpio_get_direction (unsigned gpio) {
include/asm-generic/gpio.h +0 -1
@@ -152,7 +152,6 @@ struct gpio_chip {extern const char *gpiochip_is_requested (struct gpio_chip *chip,unsigned offset);extern struct gpio_chip *gpio_to_chip (unsigned gpio); -extern int __must_check gpiochip_reserve (int start,int ngpio);/* add/remove chips */ extern int gpiochip_add (struct gpio_chip *chip);
Signature · 1 line
1.8.1.1
Quoted 2 lines · Alexandre Courbot
If Dmitri could give his Acked-by or Tested-by and one of the GPIO maintainers merge this series, I could go ahead with the deeper changes to gpiolib.
Good riddance.
Both patches applied to get some rotation in linux-next.
This is too good stuff to wait and I like to push this work ahead a bit. I can still back them out if there is some problem on the TOSA.
Yours,
Linus Walleij