Re: [patch 2.6.20-rc1 5/6] SA1100 GPIO wrappers

Russell King
2006-12-23T11:38:08Z

On Wed, Dec 20, 2006 at 01:13:21PM -0800, David Brownell wrote:
> Arch-neutral GPIO calls for SA-1100.
>
> From: Philipp Zabel <philipp.zabel@gmail.com>
>
> +static inline unsigned gpio_to_irq(unsigned gpio)
> +{
> + if (gpio < 11)
> + return IRQ_GPIO0 + gpio;
> + else
> + return IRQ_GPIO11 - 11 + gpio;
> +}
> +
> +static inline unsigned irq_to_gpio(unsigned irq)
> +{
> + if (irq < IRQ_GPIO11_27)
> + return irq - IRQ_GPIO0;
> + else
> + return irq - IRQ_GPIO11 + 11;
> +}

Why do we need to convert between IRQ and PGIO numbers? This is NOT
something that drivers should even care about - it's something that the
interrupt subsystem should know when being asked to claim an GPIO-based
IRQ.

That's something I worked hard to eliminate from the SA1100 drivers,
please don't reintroduce this silly idea again.

When the interrupt system is asked to claim a IRQ corresponding to a
GPIO, it should deal with all the stuff necessary to ensure that the
GPIO is in the required state. Drivers should not be considering
converting IRQ numbers to GPIOs or vice versa.

Doing otherwise is just plain silly - are we expecting to add GPIO
support to all Linux drivers which could possibly be used on ARM, just
because their interrupt pin might possibly be connected to a GPIO?

Get real - if you're dealing with IRQs use _only_ IRQ numbers. Don't
even think that drivers should be able to convert between IRQ and GPIO
numbers.

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/