so that requested will always be used, only *requested_str will be used
for DEBUG_FS tracking assistance
Subject: [PATCH 2/5] define gpio_chip.requested_str as a debugfs tracking string
---
include/asm-generic/gpio.h | 11 ++---------
lib/gpiolib.c | 34 ++++++++++++++--------------------
2 files changed, 16 insertions(+), 29 deletions(-)
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index d00a287..ba3e336 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -73,13 +73,10 @@ struct gpio_chip {
/* 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
- /* fat bits */
- const char *requested[ARCH_GPIOS_PER_CHIP];
-#else
- /* thin bits */
- DECLARE_BITMAP(requested, ARCH_GPIOS_PER_CHIP);
+ const char *requested_str[ARCH_GPIOS_PER_CHIP];
#endif
};
@@ -89,11 +86,7 @@ struct gpio_chip {
static inline int
gpiochip_is_requested(struct gpio_chip *chip, unsigned offset)
{
-#ifdef CONFIG_DEBUG_FS
- return chip->requested[offset] != NULL;
-#else
return test_bit(offset, chip->requested);
-#endif
}
/* add/remove chips */
diff --git a/lib/gpiolib.c b/lib/gpiolib.c
index c627efb..d52c7f1 100644
--- a/lib/gpiolib.c
+++ b/lib/gpiolib.c
@@ -48,12 +48,11 @@ static void gpio_ensure_requested(struct gpio_chip
*chip, unsigned offset)
{
int requested;
+ requested = test_and_set_bit(offset, chip->requested);
+
#ifdef CONFIG_DEBUG_FS
- requested = (int) chip->requested[offset];
if (!requested)
- chip->requested[offset] = "(auto)";
-#else
- requested = test_and_set_bit(offset, chip->requested);
+ chip->requested_str[offset] = "(auto)";
#endif
if (!requested)
@@ -158,16 +157,13 @@ int gpio_request(unsigned gpio, const char *label)
*/
status = 0;
-#ifdef CONFIG_DEBUG_FS
- if (!label)
- label = "?";
- if (chip->requested[gpio])
- status = -EBUSY;
- else
- chip->requested[gpio] = label;
-#else
+
if (test_and_set_bit(gpio, chip->requested))
status = -EBUSY;
+
+#ifdef CONFIG_DEBUG_FS
+ if (status == 0)
+ chip->requested_str[gpio] = (label == NULL) ? "?" : label;
#endif
done:
@@ -190,14 +186,12 @@ void gpio_free(unsigned gpio)
gpio -= chip->base;
-#ifdef CONFIG_DEBUG_FS
- if (chip->requested[gpio])
- chip->requested[gpio] = NULL;
- else
- chip = NULL;
-#else
if (!test_and_clear_bit(gpio, chip->requested))
chip = NULL;
+
+#ifdef CONFIG_DEBUG_FS
+ if (chip != NULL)
+ chip->requested_str[gpio] = NULL;
#endif
WARN_ON(extra_checks && chip == NULL);
done:
@@ -400,14 +394,14 @@ static void gpiolib_dbg_show(struct seq_file *s,
struct gpio_chip *chip)
unsigned gpio;
int is_out;
- if (!chip->requested[i])
+ if (!chip->requested_str[i])
continue;
gpio = chip->base + i;
is_out = test_bit(i, chip->is_out);
seq_printf(s, " gpio-%-3d (%-12s) %s %s",
- gpio, chip->requested[i],
+ gpio, chip->requested_str[i],
is_out ? "out" : "in ",
chip->get
? (chip->get(chip, i) ? "hi" : "lo")
--
1.5.2.5.GIT
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]