Subject: [PATCH 3/5] gpio/omap: Add DT support to GPIO driver

From: [email-masked] (Jon Hunter)
Date: Wed, 17 Apr 2013 08:25:05 -0500

On 04/17/2013 02:55 AM, Javier Martinez Canillas wrote:

...

> There are so many patches flying around in this thread that I missed it :-)
> 
> Sorry about that...

No problem.

>> I was trying to see if we could find a common solution that everyone
>> could use as it seems that ideally we should all be requesting the gpio.
>>
>> Cheers
>> Jon
>>
>> [1] http://marc.info/?l=linux-arm-kernel&m=136606204823845&w=1
> 
> btw, I shared the latest patch with only build testing it, but today I
> gave a try and I found a problem with this approach. The .xlate
> function is being called twice for each GPIO-IRQ so the first time
> gpio_request_one() succeeds but the second time it fails returning
> -EBUSY.

I tried it and I did not see that. I don't see the below warning either.

> This raises a warning on drivers/of/platform.c
> (WARN_ON(of_irq_to_resource_table(np, res, num_irq) != num_irq)):
> 
>     0.285308] ------------[ cut here ]------------
> [    0.285369] WARNING: at drivers/of/platform.c:171
> of_device_alloc+0x154/0x168()
> [    0.285430] Modules linked in:
> [    0.285491] [<c001a944>] (unwind_backtrace+0x0/0xf0) from
> [<c0041edc>] (warn_slowpath_common+0x4c/0x68)
> [    0.285552] [<c0041edc>] (warn_slowpath_common+0x4c/0x68) from
> [<c0041f14>] (warn_slowpath_null+0x1c/0x24)
> [    0.285614] [<c0041f14>] (warn_slowpath_null+0x1c/0x24) from
> [<c041ac3c>] (of_device_alloc+0x154/0x168)
> [    0.285675] [<c041ac3c>] (of_device_alloc+0x154/0x168) from
> [<c041ac84>] (of_platform_device_create_pdata+0x34/0x80)
> [    0.285736] [<c041ac84>]
> (of_platform_device_create_pdata+0x34/0x80) from [<c0027364>]
> (gpmc_probe_generic_child+0x180/0x240)
> [    0.285827] [<c0027364>] (gpmc_probe_generic_child+0x180/0x240)
> from [<c00278d8>] (gpmc_probe+0x4b4/0x614)
> [    0.285888] [<c00278d8>] (gpmc_probe+0x4b4/0x614) from [<c0325514>]
> (platform_drv_probe+0x18/0x1c)
> [    0.285949] [<c0325514>] (platform_drv_probe+0x18/0x1c) from
> [<c0324354>] (driver_probe_device+0x108/0x21c)

Any chance you have still have some additional code in your dts to
request the gpio? I recall you made some hacks to make this work before.

> I probably won't have time to dig further on this until later this
> week but I wanted to share with you in case you know why is being
> calling twice and if you thought about a solution.

Care to post your dts file?

> It works if I don't check the return gpio_request_one() (or better if
> we don't return on omap_gpio_irq_domain_xlate) but of course is not
> the right solution.

Yes we need to check the return value.

Cheers
Jon