* [PATCH 0/2] gpiolib: remove gpiochip_reserve()
@ 2013-02-02 14:44 Alexandre Courbot
2013-02-02 14:44 ` [PATCH 1/2] arm: pxa: tosa: do not use gpiochip_reserve() Alexandre Courbot
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Alexandre Courbot @ 2013-02-02 14:44 UTC (permalink / raw)
To: linux-arm-kernel
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(-)
--
1.8.1.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] arm: pxa: tosa: do not use gpiochip_reserve()
2013-02-02 14:44 [PATCH 0/2] gpiolib: remove gpiochip_reserve() Alexandre Courbot
@ 2013-02-02 14:44 ` Alexandre Courbot
2013-02-03 0:29 ` Haojian Zhuang
2013-02-02 14:44 ` [PATCH 2/2] gpiolib: remove gpiochip_reserve() Alexandre Courbot
2013-02-02 15:01 ` [PATCH 0/2] " Linus Walleij
2 siblings, 1 reply; 6+ messages in thread
From: Alexandre Courbot @ 2013-02-02 14:44 UTC (permalink / raw)
To: linux-arm-kernel
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 <acourbot@nvidia.com>
---
arch/arm/mach-pxa/tosa.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/arch/arm/mach-pxa/tosa.c b/arch/arm/mach-pxa/tosa.c
index 9e7998d..3d91d2e 100644
--- a/arch/arm/mach-pxa/tosa.c
+++ b/arch/arm/mach-pxa/tosa.c
@@ -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);
--
1.8.1.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] gpiolib: remove gpiochip_reserve()
2013-02-02 14:44 [PATCH 0/2] gpiolib: remove gpiochip_reserve() Alexandre Courbot
2013-02-02 14:44 ` [PATCH 1/2] arm: pxa: tosa: do not use gpiochip_reserve() Alexandre Courbot
@ 2013-02-02 14:44 ` Alexandre Courbot
2013-02-02 15:01 ` [PATCH 0/2] " Linus Walleij
2 siblings, 0 replies; 6+ messages in thread
From: Alexandre Courbot @ 2013-02-02 14:44 UTC (permalink / raw)
To: linux-arm-kernel
gpiochip_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.
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
drivers/gpio/gpiolib.c | 58 +++++++---------------------------------------
include/asm-generic/gpio.h | 1 -
2 files changed, 8 insertions(+), 51 deletions(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 199fca1..e27877a 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -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)
{
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index 45b8916..2034e69 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -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);
--
1.8.1.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 0/2] gpiolib: remove gpiochip_reserve()
2013-02-02 14:44 [PATCH 0/2] gpiolib: remove gpiochip_reserve() Alexandre Courbot
2013-02-02 14:44 ` [PATCH 1/2] arm: pxa: tosa: do not use gpiochip_reserve() Alexandre Courbot
2013-02-02 14:44 ` [PATCH 2/2] gpiolib: remove gpiochip_reserve() Alexandre Courbot
@ 2013-02-02 15:01 ` Linus Walleij
2 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2013-02-02 15:01 UTC (permalink / raw)
To: linux-arm-kernel
On Sat, Feb 2, 2013 at 3:44 PM, Alexandre Courbot <acourbot@nvidia.com> wrote:
> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] arm: pxa: tosa: do not use gpiochip_reserve()
2013-02-02 14:44 ` [PATCH 1/2] arm: pxa: tosa: do not use gpiochip_reserve() Alexandre Courbot
@ 2013-02-03 0:29 ` Haojian Zhuang
2013-02-04 20:42 ` Linus Walleij
0 siblings, 1 reply; 6+ messages in thread
From: Haojian Zhuang @ 2013-02-03 0:29 UTC (permalink / raw)
To: linux-arm-kernel
On Sat, Feb 2, 2013 at 10:44 PM, Alexandre Courbot <acourbot@nvidia.com> wrote:
> 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 <acourbot@nvidia.com>
> ---
> arch/arm/mach-pxa/tosa.c | 6 ------
> 1 file changed, 6 deletions(-)
>
> diff --git a/arch/arm/mach-pxa/tosa.c b/arch/arm/mach-pxa/tosa.c
> index 9e7998d..3d91d2e 100644
> --- a/arch/arm/mach-pxa/tosa.c
> +++ b/arch/arm/mach-pxa/tosa.c
> @@ -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);
> --
> 1.8.1.1
>
Acked-by: Haojian Zhuang <haojian.zhuang@gmail.com>
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] arm: pxa: tosa: do not use gpiochip_reserve()
2013-02-03 0:29 ` Haojian Zhuang
@ 2013-02-04 20:42 ` Linus Walleij
0 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2013-02-04 20:42 UTC (permalink / raw)
To: linux-arm-kernel
On Sun, Feb 3, 2013 at 1:29 AM, Haojian Zhuang <haojian.zhuang@gmail.com> wrote:
> Acked-by: Haojian Zhuang <haojian.zhuang@gmail.com>
Thanks!
> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-02-04 20:42 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-02 14:44 [PATCH 0/2] gpiolib: remove gpiochip_reserve() Alexandre Courbot
2013-02-02 14:44 ` [PATCH 1/2] arm: pxa: tosa: do not use gpiochip_reserve() Alexandre Courbot
2013-02-03 0:29 ` Haojian Zhuang
2013-02-04 20:42 ` Linus Walleij
2013-02-02 14:44 ` [PATCH 2/2] gpiolib: remove gpiochip_reserve() Alexandre Courbot
2013-02-02 15:01 ` [PATCH 0/2] " Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).