From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Mike Frysinger <vapier@gentoo.org>
Cc: linux-mips@linux-mips.org, linux-ia64@vger.kernel.org,
linux-sh@vger.kernel.org, linux@lists.openrisc.net,
Paul Mackerras <paulus@samba.org>,
"H. Peter Anvin" <hpa@zytor.com>,
sparclinux@vger.kernel.org, Guan Xuetao <gxt@mprc.pku.edu.cn>,
Hans-Christian Egtvedt <egtvedt@samfundet.no>,
Jonas Bonn <jonas@southpole.se>,
x86@kernel.org, Ingo Molnar <mingo@redhat.com>,
linux-arch@vger.kernel.org, Matt Turner <mattst88@gmail.com>,
Haavard Skinnemoen <hskinnemoen@gmail.com>,
Fenghua Yu <fenghua.yu@intel.com>,
microblaze-uclinux@itee.uq.edu.au,
linux-m68k@lists.linux-m68k.org,
Ivan Kokshaysky <ink@jurassic.park.msu.ru>,
Thomas Gleixner <tglx@linutronix.de>,
linux-arm-kernel@lists.infradead.org,
Richard Henderson <rth@twiddle.net>,
Chris Zankel <chris@zankel.net>, Michal Simek <monstr@monstr.eu>,
Tony Luck <tony.luck@intel.com>,
Mark Brown <broonie@opensource.wolfsonmicro.com>,
linux-kernel@vger.kernel.org, Ralf Baechle <ralf@linux-mips.org>,
Paul Mundt <lethal@linux-sh.org>,
linux-alpha@vger.kernel.org,
uclinux-dist-devel@blackfin.uclinux.org,
linuxppc-dev@lists.ozlabs.org,
"David S. Miller" <davem@davemloft.net>
Subject: Re: [PATCH] asm-generic/gpio.h: merge basic gpiolib wrappers
Date: Thu, 27 Oct 2011 14:43:51 +0100 [thread overview]
Message-ID: <20111027134351.GL19187@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <CAJaTeTp_jv-b1GUEswfFzn=joj=jkMHE91zK1wnDksH60GT6Dg@mail.gmail.com>
On Thu, Oct 27, 2011 at 03:29:40PM +0200, Mike Frysinger wrote:
> On Thu, Oct 27, 2011 at 15:11, Russell King - ARM Linux wrote:
> > On Thu, Oct 27, 2011 at 09:01:43AM -0400, Mike Frysinger wrote:
> >> diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
> >> index d494001..622851c 100644
> >> --- a/include/asm-generic/gpio.h
> >> +++ b/include/asm-generic/gpio.h
> >> @@ -170,6 +170,29 @@ extern int __gpio_cansleep(unsigned gpio);
> >>
> >> extern int __gpio_to_irq(unsigned gpio);
> >>
> >> +#ifndef gpio_get_value
> >> +#define gpio_get_value(gpio) __gpio_get_value(gpio)
> >> +#endif
> >> +
> >> +#ifndef gpio_set_value
> >> +#define gpio_set_value(gpio, value) __gpio_set_value(gpio, value)
> >> +#endif
> >> +
> >> +#ifndef gpio_cansleep
> >> +#define gpio_cansleep(gpio) __gpio_cansleep(gpio)
> >> +#endif
> >> +
> >> +#ifndef gpio_to_irq
> >> +#define gpio_to_irq(gpio) __gpio_to_irq(gpio)
> >> +#endif
> >> +
> >> +#ifndef irq_to_gpio
> >> +static inline int irq_to_gpio(unsigned int irq)
> >> +{
> >> + return -EINVAL;
> >> +}
> >> +#endif
> >> +
> >
> > This is extremely dangerous. Consider for example this code
> > (see ARM mach-davinci's gpio.h):
> > ...
> > This is why I didn't solve this using the preprocessor method in ARM, but
> > instead used __ARM_GPIOLIB_COMPLEX to control whether these definitions
> > are required.
>
> i thought the arm mach were defining things already, but i guess i
> missed some in my review
>
> easy enough to glue the arm-specific world to the asm-generic world
> ... a bit ugly, but should work i think:
> #ifndef __ARM_GPIOLIB_COMPLEX
> /* assume the mach has defined this */
> #ifndef gpio_get_value
> #define gpio_get_value gpio_get_value
> #endif
> #ifndef gpio_set_value
> #define gpio_set_value gpio_set_value
> #endif
> #ifndef gpio_cansleep
> #define gpio_cansleep gpio_cansleep
> #endif
> #ifndef gpio_to_irq
> #define gpio_to_irq gpio_to_irq
> #endif
> #ifndef irq_to_gpio
> #define irq_to_gpio irq_to_gpio
> #endif
> ...
>
> the next step might be to drill down into the arm mach's and sprinkle
> the defines into the parts that need it ...
You don't illustrate how it would work with what's there in current
kernels, so I'm having to guess.
With the above coming before the asm-generic/gpio.h include, and this
following the include:
/* The trivial gpiolib dispatchers */
#define gpio_get_value __gpio_get_value
#define gpio_set_value __gpio_set_value
#define gpio_cansleep __gpio_cansleep
this is asking for multiple definition warnings from the preprocessor -
and wrapping these with yet more ifdefs doesn't solve the problem.
Also bear in mind that we're trying to reduce the amount of code in the
mach/gpio.h header files at the moment, so I'd want to avoid adding stuff
to them.
next prev parent reply other threads:[~2011-10-27 13:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1319528012-19006-1-git-send-email-broonie@opensource.wolfsonmicro.com>
2011-10-27 13:01 ` [PATCH] asm-generic/gpio.h: merge basic gpiolib wrappers Mike Frysinger
2011-10-27 13:11 ` Russell King - ARM Linux
2011-10-27 13:29 ` Mike Frysinger
2011-10-27 13:43 ` Russell King - ARM Linux [this message]
2011-10-27 13:53 ` Russell King - ARM Linux
2011-10-27 22:52 ` [PATCH v2] " Mike Frysinger
2011-11-03 3:45 ` [PATCH v3] " Mike Frysinger
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=20111027134351.GL19187@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=chris@zankel.net \
--cc=davem@davemloft.net \
--cc=egtvedt@samfundet.no \
--cc=fenghua.yu@intel.com \
--cc=gxt@mprc.pku.edu.cn \
--cc=hpa@zytor.com \
--cc=hskinnemoen@gmail.com \
--cc=ink@jurassic.park.msu.ru \
--cc=jonas@southpole.se \
--cc=lethal@linux-sh.org \
--cc=linux-alpha@vger.kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-ia64@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-m68k@lists.linux-m68k.org \
--cc=linux-mips@linux-mips.org \
--cc=linux-sh@vger.kernel.org \
--cc=linux@lists.openrisc.net \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mattst88@gmail.com \
--cc=microblaze-uclinux@itee.uq.edu.au \
--cc=mingo@redhat.com \
--cc=monstr@monstr.eu \
--cc=paulus@samba.org \
--cc=ralf@linux-mips.org \
--cc=rth@twiddle.net \
--cc=sparclinux@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=uclinux-dist-devel@blackfin.uclinux.org \
--cc=vapier@gentoo.org \
--cc=x86@kernel.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;
as well as URLs for NNTP newsgroup(s).