Skip to contentSkip to conversation

Make MMCI driver compile without gpiolib

PATCH New Linus Walleij 4 participants 6 messages Aug 26, 2009 – Sep 28, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Make MMCI driver compile without gpiolib

The recent addition of optional gpiolib support to check if a card was inserted or write protected was really not optional. It needs this ifdef to become optional so that U300 compiles, for example.

---
 drivers/mmc/host/mmci.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/mmc/host/mmci.c +2 -0
index 5eb86a8..a923ee2 100644
@@ -619,6 +619,7 @@ static int __devinit mmci_probe(struct amba_device *dev, struct amba_id *id)
 	writel(0, host->base + MMCIMASK1);
 	writel(0xfff, host->base + MMCICLEAR);
 
+#ifdef CONFIG_GPIOLIB
 	if (gpio_is_valid(plat->gpio_cd)) {
 		ret = gpio_request(plat->gpio_cd, DRIVER_NAME " (cd)");
 		if (ret == 0)
@@ -637,6 +638,7 @@ static int __devinit mmci_probe(struct amba_device *dev, struct amba_id *id)
 		else if (ret != -ENOSYS)
 			goto err_gpio_wp;
 	}
+#endif
 
 	ret = request_irq(dev->irq[0], mmci_irq, IRQF_SHARED, DRIVER_NAME " (cmd)", host);
 	if (ret)
Signature · 1 line
1.6.2.1
#1 lore raw

PATCH 1/1 Make MMCI driver compile without gpiolib

Quoted 4 lines · Linus Walleij

The recent addition of optional gpiolib support to check if a card was inserted or write protected was really not optional. It needs this ifdef to become optional so that U300 compiles, for example.

Looking back at this, I don't think this ifdef is required.

Why?

We're using linux/gpio.h, which provides dummy definitions for the GPIO functions of GENERIC_GPIO is not set. If GENERIC_GPIO is set, then GPIOs are available, and can be used.

GPIOLIB is entirely a different matter, and doesn't really indicate whether GPIO support is available or not.

The real problem is that U300 doesn't implement gpio_is_valid() - which is part of the GPIO API and not specific to GPIOLIB.

Please implement this function, and let's revert this (wrong) patch.

Quoted 20 lines
drivers/mmc/host/mmci.c +2 -0
index 5eb86a8..a923ee2 100644
@@ -619,6 +619,7 @@ static int __devinit mmci_probe(struct amba_device *dev, struct amba_id *id)
 	writel(0, host->base + MMCIMASK1);
 	writel(0xfff, host->base + MMCICLEAR);
 
+#ifdef CONFIG_GPIOLIB
 	if (gpio_is_valid(plat->gpio_cd)) {
 		ret = gpio_request(plat->gpio_cd, DRIVER_NAME " (cd)");
 		if (ret == 0)
@@ -637,6 +638,7 @@ static int __devinit mmci_probe(struct amba_device *dev, struct amba_id *id)
 		else if (ret != -ENOSYS)
 			goto err_gpio_wp;
 	}
+#endif
 
 	ret = request_irq(dev->irq[0], mmci_irq, IRQF_SHARED, DRIVER_NAME " (cmd)", host);
 	if (ret)
#2 lore raw

PATCH 1/1 Make MMCI driver compile without gpiolib

2009/9/27 Russell King - ARM Linux <[email protected]>:

Quoted 1 line

Looking back at this, I don't think this ifdef is required.

You're righ of course, sorry for that. Fix-up patch just posted, also in the patch tracker. Reverts these #ifdef:s and fix the root problem instead.

Linus Walleij

#3 lore raw

PATCH 1/1 Make MMCI driver compile without gpiolib

In reply to Russell King - ARM Linux

Hm thinking back at this:

2009/9/27 Russell King - ARM Linux <[email protected]>:

Quoted 2 lines

The real problem is that U300 doesn't implement gpio_is_valid() - which is part of the GPIO API and not specific to GPIOLIB.

None of the GPIO drivers in drivers/gpio implement gpio_is_valid() though they all select GPIOLIB which in turn selects GENERIC_GPIO.

With one of them being the PL061 this means that the not so unlikely combination of PL061+PL180 will fail to compile (even though I'm not aware of such a platform for the time being).

Is it worth taking a run over drivers/gpio and try to fix this or atleast the PL061 driver? I can have a look at it.

Yours,
Linus Walleij

#4 lore raw

PATCH 1/1 Make MMCI driver compile without gpiolib

Hi Linus,

Quoted 7 lines · Linus Walleij

Hm thinking back at this:

2009/9/27 Russell King - ARM Linux <[email protected]>:

Quoted 2 lines

The real problem is that U300 doesn't implement gpio_is_valid() - which is part of the GPIO API and not specific to GPIOLIB.

Quoted 6 lines

None of the GPIO drivers in drivers/gpio implement gpio_is_valid() though they all select GPIOLIB which in turn selects GENERIC_GPIO.

With one of them being the PL061 this means that the not so unlikely combination of PL061+PL180 will fail to compile (even though I'm not aware of such a platform for the time being).

Shouldn't gpio_is_valid() be implemented at the platform code? How should the generic GPIO driver know the number of valid GPIO lines, or the number of PL061 blocks for that matter?

Quoted 2 lines

Is it worth taking a run over drivers/gpio and try to fix this or atleast the PL061 driver? I can have a look at it.

baruch

Signature · 3 lines
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
#5 lore raw

PATCH 1/1 Make MMCI driver compile without gpiolib

In reply to Linus Walleij
Quoted 9 lines · Linus Walleij

Hm thinking back at this:

2009/9/27 Russell King - ARM Linux <[email protected]>:

Quoted 2 lines

The real problem is that U300 doesn't implement gpio_is_valid() - which is part of the GPIO API and not specific to GPIOLIB.

None of the GPIO drivers in drivers/gpio implement gpio_is_valid() though they all select GPIOLIB which in turn selects GENERIC_GPIO.

include/asm-generic/gpio.h:

#ifdef CONFIG_GPIOLIB
...
/* Platforms may implement their GPIO interface with library code,
* at a small performance cost for non-inlined operations and some
* extra memory (for code and for per-GPIO table entries). *
* While the GPIO programming interface defines valid GPIO numbers
* to be in the range 0..MAX_INT, this library restricts them to the
* smaller range 0..ARCH_NR_GPIOS-1.
*/

#ifndef ARCH_NR_GPIOS
#define ARCH_NR_GPIOS 256
#endif

static inline int gpio_is_valid(int number)

{
        /* only some non-negative numbers are valid */
        return ((unsigned)number) < ARCH_NR_GPIOS;
}

So, with gpiolib enabled, gpio_is_valid() is predefined assuming that GPIOs between 0..ARCH_NR_GPIOS are valid.