From: David Brownell <david-b@pacbell.net>
To: Sam Ravnborg <sam@ravnborg.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Linux Kernel list <linux-kernel@vger.kernel.org>,
eric miao <eric.y.miao@gmail.com>
Subject: Re: [patch 2.6.24-rc6-mm 2/9] gpiolib: add gpio provider infrastructure
Date: Sat, 29 Dec 2007 10:35:46 -0800 [thread overview]
Message-ID: <200712291035.47345.david-b@pacbell.net> (raw)
In-Reply-To: <20071229071023.GC16569@uranus.ravnborg.org>
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@users.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);
next prev parent reply other threads:[~2007-12-29 18:36 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200712281927.32575.david-b@pacbell.net>
2007-12-29 3:53 ` [patch 2.6.24-rc6-mm 1/9] gpiolib: add drivers/gpio directory David Brownell
2007-12-29 6:58 ` Sam Ravnborg
2007-12-29 18:19 ` David Brownell
2007-12-29 19:03 ` Sam Ravnborg
2008-01-05 20:07 ` David Brownell
2007-12-29 3:54 ` [patch 2.6.24-rc6-mm 2/9] gpiolib: add gpio provider infrastructure David Brownell
2007-12-29 7:10 ` Sam Ravnborg
2007-12-29 18:35 ` David Brownell [this message]
2008-01-05 20:08 ` David Brownell
2007-12-29 3:55 ` [patch 2.6.24-rc6-mm 3/9] gpiolib: update Documentation/gpio.txt David Brownell
2008-01-05 20:09 ` David Brownell
2007-12-29 3:56 ` [patch 2.6.24-rc6-mm 4/9] gpiolib: avr32 at32ap platform support David Brownell
2008-01-05 20:10 ` David Brownell
2008-01-05 20:49 ` Haavard Skinnemoen
2008-01-05 22:09 ` David Brownell
2007-12-29 3:57 ` [patch 2.6.24-rc6-mm 5/9] gpiolib: pxa " David Brownell
2008-01-05 20:11 ` David Brownell
2007-12-29 3:58 ` [patch 2.6.24-rc6-mm 6/9] gpiolib: pcf857x i2c gpio expander support David Brownell
2008-01-05 20:13 ` David Brownell
2007-12-29 3:58 ` [patch 2.6.24-rc6-mm 7/9] gpiolib: mcp23s08 spi " David Brownell
2007-12-29 3:58 ` [patch 2.6.24-rc6-mm 8/9] gpiolib: pca9539 i2c " David Brownell
2008-01-02 13:46 ` Jean Delvare
2008-01-04 1:41 ` David Brownell
2008-01-05 19:40 ` David Brownell
2008-01-06 12:59 ` Jean Delvare
2007-12-29 3:59 ` [patch 2.6.24-rc6-mm 9/9] gpiolib: deprecate obsolete pca9539 driver David Brownell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200712291035.47345.david-b@pacbell.net \
--to=david-b@pacbell.net \
--cc=akpm@linux-foundation.org \
--cc=eric.y.miao@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sam@ravnborg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox