Subject: [PATCH] move per GPIO "is_out" to "struct gpio_desc"
---
include/asm-generic/gpio.h | 4 +---
lib/gpiolib.c | 18 +++++++++++-------
2 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index 783adcf..da67038 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -27,6 +27,7 @@ struct gpio_chip;
struct gpio_desc {
struct gpio_chip *chip;
+ unsigned is_out:1;
};
/**
@@ -47,8 +48,6 @@ struct gpio_desc {
* (base + ngpio - 1).
* @can_sleep: flag must be set iff get()/set() methods sleep, as they
* must while accessing GPIO expander chips over I2C or SPI
- * @is_out: bit array where bit N is true iff GPIO with offset N has been
- * called successfully to configure this as an output
*
* A gpio_chip can help platforms abstract various sources of GPIOs so
* they can all be accessed through a common programing interface.
@@ -78,7 +77,6 @@ struct gpio_chip {
unsigned can_sleep:1;
/* other fields are modified by the gpio library only */
- DECLARE_BITMAP(is_out, ARCH_GPIOS_PER_CHIP);
DECLARE_BITMAP(requested, ARCH_GPIOS_PER_CHIP);
#ifdef CONFIG_DEBUG_FS
diff --git a/lib/gpiolib.c b/lib/gpiolib.c
index 57e0d10..a089597 100644
--- a/lib/gpiolib.c
+++ b/lib/gpiolib.c
@@ -217,11 +217,14 @@ int gpio_direction_input(unsigned gpio)
{
unsigned long flags;
struct gpio_chip *chip;
+ struct gpio_desc *desc;
int status = -EINVAL;
spin_lock_irqsave(&gpio_lock, flags);
- chip = gpio_to_chip(gpio);
+ desc = &gpio_desc[gpio];
+ chip = desc->chip;
+
if (!chip || !chip->get || !chip->direction_input)
goto fail;
@@ -238,8 +241,7 @@ int gpio_direction_input(unsigned gpio)
might_sleep_if(extra_checks && chip->can_sleep);
status = chip->direction_input(chip, gpio);
- if (status == 0)
- clear_bit(gpio, chip->is_out);
+ desc->is_out = 0;
return status;
fail:
spin_unlock_irqrestore(&gpio_lock, flags);
@@ -251,11 +253,14 @@ int gpio_direction_output(unsigned gpio, int value)
{
unsigned long flags;
struct gpio_chip *chip;
+ struct gpio_desc *desc;
int status = -EINVAL;
spin_lock_irqsave(&gpio_lock, flags);
- chip = gpio_to_chip(gpio);
+ desc = &gpio_desc[gpio];
+ chip = desc->chip;
+
if (!chip || !chip->get || !chip->direction_output)
goto fail;
@@ -272,8 +277,7 @@ int gpio_direction_output(unsigned gpio, int value)
might_sleep_if(extra_checks && chip->can_sleep);
status = chip->direction_output(chip, gpio, value);
- if (status == 0)
- set_bit(gpio, chip->is_out);
+ desc->is_out = 1;
return status;
fail:
spin_unlock_irqrestore(&gpio_lock, flags);
@@ -402,7 +406,7 @@ static void gpiolib_dbg_show(struct seq_file *s,
struct gpio_chip *chip)
continue;
gpio = chip->base + i;
- is_out = test_bit(i, chip->is_out);
+ is_out = gpio_desc[gpio].is_out;
seq_printf(s, " gpio-%-3d (%-12s) %s %s",
gpio, chip->requested_str[i],
--
1.5.2.5.GIT
-
| Andrea Arcangeli | [PATCH 00 of 12] mmu notifier #v13 |
| David Newall | Re: What still uses the block layer? |
| Greg Kroah-Hartman | [PATCH 001/196] Chinese: Add the known_regression URI to the HOWTO |
| Konrad Rzeszutek | [PATCH] Add iSCSI iBFT support (v0.4.5) |
git: | |
| Gerrit Renker | [PATCH 27/37] dccp: Integration of dynamic feature activation - part 2 (server side) |
| David Miller | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| Stefan Richter | Re: [GIT]: Networking |
| Antonio Almeida | HTB accuracy for high speed |
