linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Magnus Damm <magnus.damm@gmail.com>
To: Paul Mundt <lethal@linux-sh.org>
Cc: linux-kernel@vger.kernel.org, rjw@sisk.pl,
	linus.walleij@stericsson.com, arnd@arndb.de,
	linux-sh@vger.kernel.org, horms@verge.net.au,
	grant.likely@secretlab.ca, olof@lixom.net
Subject: Re: [PATCH] gpio: Emma Mobile GPIO driver V2
Date: Wed, 16 May 2012 10:09:54 +0000	[thread overview]
Message-ID: <CANqRtoSSEb9jwEmvbhBuyHp-9BfUSRabQzqjrrVGTFDP-AHutQ@mail.gmail.com> (raw)
In-Reply-To: <20120516072927.GN7988@linux-sh.org>

On Wed, May 16, 2012 at 4:29 PM, Paul Mundt <lethal@linux-sh.org> wrote:
> On Wed, May 16, 2012 at 12:43:33AM +0900, Magnus Damm wrote:
>> +static int __devinit em_gio_irq_domain_init(struct em_gio_priv *p)
>> +{
>> +     struct platform_device *pdev = p->pdev;
>> +     struct gpio_em_config *pdata = pdev->dev.platform_data;
>> +
>> +     p->irq_base = irq_alloc_descs(pdata->irq_base, 0,
>> +                                   pdata->number_of_pins, numa_node_id());
>> +     if (IS_ERR_VALUE(p->irq_base)) {
>> +             dev_err(&pdev->dev, "cannot get irq_desc\n");
>> +             return -ENXIO;
>> +     }
>> +     pr_debug("gio: hw base = %d, nr = %d, sw base = %d\n",
>> +              pdata->gpio_base, pdata->number_of_pins, p->irq_base);
>> +
>> +     p->irq_domain = irq_domain_add_legacy(pdev->dev.of_node,
>> +                                           pdata->number_of_pins,
>> +                                           p->irq_base, 0,
>> +                                           &em_gio_irq_domain_ops, p);
>> +     if (!p->irq_domain) {
>> +             irq_free_descs(p->irq_base, pdata->number_of_pins);
>> +             return -ENXIO;
>> +     }
>> +
>> +     return 0;
>> +}
>> +
> There's no reason to use a legacy domain here, this is a pretty
> straightforward candidate for a linear map. You can use ->to_irq() for
> the irq_create_mapping() invocation and then later look up the IRQ with
> irq_linear_revmap().

I believe I have my reasons for using the legacy domain, but I agree
that it is possible to use irq_create_mapping() and
irq_linear_revmap() in the case of linear mappings. Actually, it's
exactly what my DT prototype patch does. Please see this patch that
adds linear irq domain support in the DT case, and the patch
description also includes information about when the legacy irq domain
is used and when the linear one is:

http://groups.google.com/group/linux.kernel/browse_thread/thread/25a8d7e4d311ab59?pli=1

> irq_domain_add_legacy() exists for existing static ranges, which there is
> really no reason to be adding in new board/platform support. You don't
> have to worry about virq overlap since irq_create_mapping() already wraps
> on top of irq_alloc_desc_xxx() for lookup.

So I intentionally made use of the legacy domain in the non-DT case.
This because I want to let the SoC code set the static IRQ ranges via
platform data.
>
>> +static void __devexit em_gio_irq_domain_cleanup(struct em_gio_priv *p)
>> +{
>> +     struct gpio_em_config *pdata = p->pdev->dev.platform_data;
>> +
>> +     irq_free_descs(p->irq_base, pdata->number_of_pins);
>> +     /* FIXME: irq domain wants to be freed! */
>> +}
>> +
> After which point you can iterate and dispose of the virq mappings with
> irq_dispose_mapping(). The lack of irq domain teardown functionality does
> need to be addressed though.

I can't see any GPIO driver doing that yet, but yes, that is possible.

Thanks,

/ magnus

  reply	other threads:[~2012-05-16 10:09 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-15 15:43 [PATCH] gpio: Emma Mobile GPIO driver V2 Magnus Damm
2012-05-15 16:32 ` Joe Perches
2012-05-17  6:20   ` Magnus Damm
2012-05-16  7:11 ` Linus Walleij
2012-05-16 10:15   ` Magnus Damm
2012-05-16 11:25     ` Linus Walleij
2012-05-16 20:05       ` Rafael J. Wysocki
2012-05-16 22:22         ` Olof Johansson
2012-05-16 22:37           ` Rafael J. Wysocki
2012-05-16 22:54             ` Olof Johansson
2012-05-18 22:56               ` Grant Likely
2012-05-19  1:18                 ` Olof Johansson
2012-05-19  1:44                   ` Grant Likely
2012-05-19  2:27                     ` Olof Johansson
2012-05-19 12:06               ` Rafael J. Wysocki
2012-05-16  7:29 ` Paul Mundt
2012-05-16 10:09   ` Magnus Damm [this message]
2012-05-16 12:09     ` Arnd Bergmann
2012-05-16 15:47       ` Magnus Damm
2012-05-17  0:41       ` Paul Mundt
2012-05-18 23:25         ` Grant Likely
2012-05-19  6:46           ` Paul Mundt
2012-05-19 20:05             ` Grant Likely
2012-05-18 22:57   ` Grant Likely
2012-05-19  2:13     ` Paul Mundt

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=CANqRtoSSEb9jwEmvbhBuyHp-9BfUSRabQzqjrrVGTFDP-AHutQ@mail.gmail.com \
    --to=magnus.damm@gmail.com \
    --cc=arnd@arndb.de \
    --cc=grant.likely@secretlab.ca \
    --cc=horms@verge.net.au \
    --cc=lethal@linux-sh.org \
    --cc=linus.walleij@stericsson.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=olof@lixom.net \
    --cc=rjw@sisk.pl \
    /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).