All of lore.kernel.org
 help / color / mirror / Atom feed
From: grinberg@compulab.co.il (Igor Grinberg)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] GPIO: gpio-pxa: simplify pxa_gpio_to_irq() and pxa_irq_to_chip()
Date: Mon, 06 Aug 2012 13:08:25 +0300	[thread overview]
Message-ID: <501F9799.5020400@compulab.co.il> (raw)
In-Reply-To: <501E5F5D.5070901@gmail.com>

On 08/05/12 14:56, Daniel Mack wrote:
> On 05.08.2012 10:31, Igor Grinberg wrote:
>> Hi Daniel,
>>
>> On 07/25/12 18:35, Daniel Mack wrote:
>>> Simplify the code in gpio-pxa.c and make them based on irq_base.
>>> When not probed from devicetree, initialize irq_base from
>>> PXA_GPIO_TO_IRQ() or MMP_GPIO_TO_IRQ(), respectively, so the non-DT case
>>> still works.
>>>
>>> Only tested on PXA3xx.
>>>
>>> Signed-off-by: Daniel Mack <zonque@gmail.com>
>>> ---
>>>  drivers/gpio/gpio-pxa.c |   70 +++++++++++------------------------------------
>>>  1 file changed, 16 insertions(+), 54 deletions(-)
>>>
>>> diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
>>> index 58a6a63..6d0cb9d 100644
>>> --- a/drivers/gpio/gpio-pxa.c
>>> +++ b/drivers/gpio/gpio-pxa.c
>>
>> [...]
>>
>>> @@ -564,10 +516,20 @@ static int __devinit pxa_gpio_probe(struct platform_device *pdev)
>>>  	int irq0 = 0, irq1 = 0, irq_mux, gpio_offset = 0;
>>>  
>>>  	ret = pxa_gpio_probe_dt(pdev);
>>> -	if (ret < 0)
>>> +	if (ret < 0) {
>>>  		pxa_last_gpio = pxa_gpio_nums();
>>> -	else
>>> +#ifdef CONFIG_ARCH_PXA
>>> +		if (gpio_is_pxa_type(gpio_type))
>>> +			irq_base = PXA_GPIO_TO_IRQ(0);
>>> +#endif
>>> +#ifdef CONFIG_ARCH_MMP
>>> +		if (gpio_is_mmp_type(gpio_type))
>>> +			irq_base = MMP_GPIO_TO_IRQ(0);
>>> +#endif
>>
>> The ifdes above do not look essential.
> 
> But they are. In case of !CONFIG_ARCH_MMP, MMP_GPIO_TO_IRQ is undefined.
> Same problem for !CONFIG_ARC_PXA.

I see. Ok then. I'm not a huge fan of having the #ifdes inside
the code (functions) and thinking of moving those outside of the function,
I get pretty much the same solution it was before your patch.

I really think that PXA|MMP_GPIO_TO_IRQ should be moved to some common
location (say arch/arm/plat-pxa/) so both are available regardless
of CONFIG_ARCH_MMP|PXA. That will simplify the code even more.
But probably it is too much to ask for that simple patch...
So, I'm fine with the patch.

Thanks

> 
>> Can't we drop them and just have else if ... else if?
> 
> We can't do that either, as we might have a hybrid kernel that works on
> both PXA and MMP platforms, and then the condition is a runtime thing.

Well, that is exactly what I mean...
I mean, the if ... else ... if ... else without the #ifdefs...
But again, it requires some more changes.

-- 
Regards,
Igor.

  reply	other threads:[~2012-08-06 10:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-25 15:35 [PATCH 1/2] GPIO: gpio-pxa: simplify pxa_gpio_to_irq() and pxa_irq_to_chip() Daniel Mack
2012-07-25 15:35 ` [PATCH 2/2] GPIO: gpio-pxa: fix devicetree functions Daniel Mack
2012-08-04 23:16   ` Linus Walleij
2012-08-05  3:52     ` Haojian Zhuang
2012-08-05  9:40       ` Linus Walleij
2012-08-05 12:58         ` Haojian Zhuang
2012-07-25 16:17 ` [PATCH 1/2] GPIO: gpio-pxa: simplify pxa_gpio_to_irq() and pxa_irq_to_chip() Arnd Bergmann
2012-07-25 18:11   ` Daniel Mack
2012-07-25 19:10     ` Arnd Bergmann
2012-08-04 23:20       ` Linus Walleij
2012-08-05  8:31 ` Igor Grinberg
2012-08-05 11:56   ` Daniel Mack
2012-08-06 10:08     ` Igor Grinberg [this message]
2012-08-06 10:26       ` Arnd Bergmann

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=501F9799.5020400@compulab.co.il \
    --to=grinberg@compulab.co.il \
    --cc=linux-arm-kernel@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.