[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <200712291035.47345.david-b@pacbell.net>
Date: Sat, 29 Dec 2007 10:35:46 -0800
From: David Brownell <david-b@...bell.net>
To: Sam Ravnborg <sam@...nborg.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Linux Kernel list <linux-kernel@...r.kernel.org>,
eric miao <eric.y.miao@...il.com>
Subject: Re: [patch 2.6.24-rc6-mm 2/9] gpiolib: add gpio provider infrastructure
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 <dbrownell@...rs.sourceforge.net>
---
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 majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists