On Friday 28 December 2007, Sam Ravnborg wrote:
> For this an the other setters of desc->label a small helper function
> would be better. The helper function could then contain the necessary
> ifdef in only one place.
Good point; see the appended.
> > +/* add/remove chips */
> > +extern int gpiochip_add(struct gpio_chip *chip);
> > +extern int __must_check gpiochip_remove(struct gpio_chip *chip);
>
> The use of "extern" is not needed in .h files for function prototypes.
But it's widely used nonetheless, and many people prefer to
see those annotations. Heck, /usr/include is full of them...
- Dave
============ CUT HERE
Minor gpiolib.c cleanup: remove most #ifdefs for CONFIG_FS.
Signed-off-by: David Brownell <[email protected]>
---
drivers/gpio/gpiolib.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
--- at91.orig/drivers/gpio/gpiolib.c
+++ at91/drivers/gpio/gpiolib.c
@@ -50,6 +50,12 @@ struct gpio_desc {
};
static struct gpio_desc gpio_desc[ARCH_NR_GPIOS];
+static inline void desc_set_label(struct gpio_desc *d, const char *label)
+{
+#ifdef CONFIG_DEBUG_FS
+ d->label = label;
+#endif
+}
/* Warn when drivers omit gpio_request() calls -- legal but ill-advised
* when setting direction, and otherwise illegal. Until board setup code
@@ -61,9 +67,7 @@ static void gpio_ensure_requested(struct
{
if (test_and_set_bit(FLAG_REQUESTED, &desc->flags) == 0) {
pr_warning("GPIO-%d autorequested\n", (int)(desc - gpio_desc));
-#ifdef CONFIG_DEBUG_FS
- desc->label = "[auto]";
-#endif
+ desc_set_label(desc, "[auto]");
}
}
@@ -178,9 +182,7 @@ int gpio_request(unsigned gpio, const ch
*/
if (test_and_set_bit(FLAG_REQUESTED, &desc->flags) == 0) {
-#ifdef CONFIG_DEBUG_FS
- desc->label = (label == NULL) ? "?" : label;
-#endif
+ desc_set_label(desc, label ? : "?");
status = 0;
} else
status = -EBUSY;
@@ -207,11 +209,9 @@ void gpio_free(unsigned gpio)
spin_lock_irqsave(&gpio_lock, flags);
desc = &gpio_desc[gpio];
- if (desc->chip && test_and_clear_bit(FLAG_REQUESTED, &desc->flags)) {
-#ifdef CONFIG_DEBUG_FS
- desc->label = NULL;
-#endif
- } else
+ if (desc->chip && test_and_clear_bit(FLAG_REQUESTED, &desc->flags))
+ desc_set_label(desc, NULL);
+ else
WARN_ON(extra_checks);
spin_unlock_irqrestore(&gpio_lock, flags);
--
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]