mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Brownell <david-b@pacbell.net>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Florian Fainelli <florian.fainelli@telecomint.eu>,
	linux-kernel@vger.kernel.org, hpa@zytor.com, tglx@linutronix.de,
	Ingo Molnar <mingo@elte.hu>,
	Mauro Carvalho Chehab <mchehab@infradead.org>
Subject: Re: [PATCH 1/4 resend] [x86] Add generic GPIO support to x86
Date: Wed, 13 Feb 2008 17:55:30 -0800	[thread overview]
Message-ID: <200802131755.30921.david-b@pacbell.net> (raw)
In-Reply-To: <20080213140258.78380f5d.akpm@linux-foundation.org>

On Wednesday 13 February 2008, Andrew Morton wrote:
> It would be more modern to have a <linux/gpio.h> which takes care of
> cruddy details, but it's getting too late for that.

Sort of like this?  For drivers that don't want to list themselves
in Kconfig as depending on GENERIC_GPIO (e.g. one NAND driver I heard
about), this lets them use <linux/gpio.h> ... existing code can't
break, and it won't hurt if new code uses this.

- Dave


============== CUT HERE
Add a <linux/gpio.h> defining fail/warn stubs for GPIO calls on
platforms that don't support the GPIO programming interface.  It
includes the arch-specific interface glue otherwise.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
---
 include/linux/gpio.h |   93 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 93 insertions(+)

--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ g26/include/linux/gpio.h	2008-02-13 17:40:06.000000000 -0800
@@ -0,0 +1,93 @@
+#ifndef __LINUX_GPIO_H
+#define __LINUX_GPIO_H
+
+#ifdef CONFIG_GENERIC_GPIO
+#include <asm/gpio.h>
+
+#else
+
+/*
+ * Some platforms don't support the GPIO programming interface.
+ *
+ * In case some driver uses it anyway (it should normally have
+ * depended on GENERIC_GPIO), these routines help the compiler
+ * optimize out much GPIO-related code ... or trigger a runtime
+ * warning when something is wrongly called.
+ */
+
+static inline int gpio_is_valid(int number)
+{
+	return 0;
+}
+
+static inline int gpio_request(unsigned gpio, const char *label)
+{
+	return -EINVAL;
+}
+
+static inline void gpio_free(unsigned gpio)
+{
+	/* GPIO can never have been requested */
+	WARN_ON(1);
+}
+
+static inline int gpio_direction_input(unsigned gpio)
+{
+	return -EINVAL;
+}
+
+static inline int gpio_direction_output(unsigned gpio, int value)
+{
+	return -EINVAL;
+}
+
+static inline int gpio_get_value(unsigned gpio)
+{
+	/* GPIO can never have been requested or set as {in,out}put */
+	WARN_ON(1);
+	return 0;
+}
+
+static inline void gpio_set_value(unsigned gpio, int value)
+{
+	/* GPIO can never have been requested or set as output */
+	WARN_ON(1);
+}
+
+static int gpio_cansleep(unsigned gpio)
+{
+	/* GPIO can never have been requested or set as {in,out}put */
+	WARN_ON(1);
+	return 0;
+}
+
+static inline int gpio_get_value_cansleep(unsigned gpio)
+{
+	/* GPIO can never have been requested or set as {in,out}put */
+	WARN_ON(1);
+	return 0;
+}
+
+static inline void gpio_set_value_cansleep(unsigned gpio, int value)
+{
+	/* GPIO can never have been requested or set as output */
+	WARN_ON(1);
+}
+
+static inline int gpio_to_irq(unsigned gpio)
+{
+	/* GPIO can never have been requested or set as input */
+	WARN_ON(1);
+	return -EINVAL;
+}
+
+static inline int irq_to_gpio(unsigned irq)
+{
+	/* irq can never have been returned from gpio_to_irq() */
+	WARN_ON(1);
+	return -EINVAL;
+}
+
+#endif
+
+#endif /* __LINUX_GPIO_H */


  parent reply	other threads:[~2008-02-14  2:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-18 13:51 Florian Fainelli
2007-10-18 21:38 ` Andres Salomon
2007-10-19 12:01   ` Florian Fainelli
2007-10-19 21:32     ` Jordan Crouse
2007-10-21 16:06       ` Haavard Skinnemoen
2007-10-22 19:18     ` Andres Salomon
2007-10-22 19:59       ` Florian Fainelli
2007-10-25  8:18       ` Thomas Gleixner
2007-10-25 12:30         ` Florian Fainelli
2007-10-25 15:24           ` Thomas Gleixner
2008-02-13 22:02 ` Andrew Morton
2008-02-13 23:25   ` David Brownell
2008-02-14  1:55   ` David Brownell [this message]
2008-02-22 23:56     ` Anton Vorontsov
2008-02-23  0:51       ` 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=200802131755.30921.david-b@pacbell.net \
    --to=david-b@pacbell.net \
    --cc=akpm@linux-foundation.org \
    --cc=florian.fainelli@telecomint.eu \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@infradead.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    /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

Powered by JetHome