From: grinberg@compulab•co.il (Igor Grinberg)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH 03/10] gpio: pxa: avoid to use global irq base
Date: Mon, 28 Jan 2013 13:07:40 +0200 [thread overview]
Message-ID: <51065BFC.6000205@compulab.co.il> (raw)
In-Reply-To: <1358929554-32265-4-git-send-email-haojian.zhuang@linaro.org>
On 01/23/13 10:25, Haojian Zhuang wrote:
> Avoid to use global irq_base in gpio-pxa driver. Define irq_base in each
> pxa_gpio_chip instead. Then we can avoid to use macro PXA_GPIO_TO_IRQ() &
> MMP_GPIO_TO_IRQ().
>
> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro•org>
> ---
> arch/arm/mach-pxa/pxa25x.c | 2 +-
> arch/arm/mach-pxa/pxa27x.c | 2 +-
> drivers/gpio/gpio-pxa.c | 142 ++++++++++++++++++++++----------------------
> include/linux/gpio-pxa.h | 4 +-
> 4 files changed, 77 insertions(+), 73 deletions(-)
[...]
> diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
> index 8e66c6b..da6e7fd 100644
> --- a/drivers/gpio/gpio-pxa.c
> +++ b/drivers/gpio/gpio-pxa.c
[...]
> @@ -485,7 +452,7 @@ static int pxa_irq_domain_map(struct irq_domain *d, unsigned int irq,
> return 0;
> }
>
> -const struct irq_domain_ops pxa_irq_domain_ops = {
> +static const struct irq_domain_ops pxa_irq_domain_ops = {
> .map = pxa_irq_domain_map,
> .xlate = irq_domain_xlate_twocell,
> };
You should also move this out of CONFIG_OF as I don't think it is a dependency,
and also otherwise you get the below...
> @@ -529,14 +496,6 @@ static int pxa_gpio_probe_dt(struct platform_device *pdev)
> nr_gpios = nr_banks << 5;
> pxa_last_gpio = nr_gpios - 1;
>
> - irq_base = irq_alloc_descs(-1, 0, nr_gpios, 0);
> - if (irq_base < 0) {
> - dev_err(&pdev->dev, "Failed to allocate IRQ numbers\n");
> - goto err;
> - }
> - domain = irq_domain_add_legacy(np, nr_gpios, irq_base, 0,
> - &pxa_irq_domain_ops, NULL);
> - pxa_gpio_of_node = np;
> return 0;
> err:
> iounmap(gpio_reg_base);
> @@ -546,6 +505,56 @@ err:
> #define pxa_gpio_probe_dt(pdev) (-1)
> #endif
>
> +static int pxa_init_gpio_chip(struct platform_device *pdev, int gpio_end,
> + int (*set_wake)(unsigned int, unsigned int))
> +{
> + int i, gpio, nbanks = gpio_to_bank(gpio_end) + 1;
> + struct pxa_gpio_chip *chips;
> +
> + chips = devm_kzalloc(&pdev->dev, nbanks * sizeof(*chips), GFP_KERNEL);
> + if (chips == NULL) {
> + pr_err("%s: failed to allocate GPIO chips\n", __func__);
> + return -ENOMEM;
> + }
> +
> + for (i = 0, gpio = 0; i < nbanks; i++, gpio += 32) {
> + struct gpio_chip *c = &chips[i].chip;
> +
> + sprintf(chips[i].label, "gpio-%d", i);
> + chips[i].regbase = gpio_reg_base + BANK_OFF(i);
> + chips[i].set_wake = set_wake;
> +
> + c->base = gpio;
> + c->label = chips[i].label;
> +
> + c->direction_input = pxa_gpio_direction_input;
> + c->direction_output = pxa_gpio_direction_output;
> + c->get = pxa_gpio_get;
> + c->set = pxa_gpio_set;
> + c->to_irq = pxa_gpio_to_irq;
> +#ifdef CONFIG_OF_GPIO
> + c->of_node = pxa_gpio_of_node;
> + c->of_xlate = pxa_gpio_of_xlate;
> + c->of_gpio_n_cells = 2;
> +#endif
> +
> + /* number of GPIOs on last bank may be less than 32 */
> + c->ngpio = (gpio + 31 > gpio_end) ? (gpio_end - gpio + 1) : 32;
> +
> + chips[i].irq_base = irq_alloc_descs(-1, 0, c->ngpio, 0);
> + if (chips[i].irq_base < 0)
> + return -EINVAL;
> + if (!irq_domain_add_legacy(pdev->dev.of_node, c->ngpio,
> + chips[i].irq_base, 0,
> + &pxa_irq_domain_ops, &chips[i]))
if !CONFIG_OF, you get:
drivers/gpio/gpio-pxa.c:479: error: 'pxa_irq_domain_ops' undeclared (first use in this function)
Also, for !CONFIG_IRQ_DOMAIN, you get:
drivers/gpio/gpio-pxa.c: In function 'pxa_init_gpio_chip':
drivers/gpio/gpio-pxa.c:477: error: implicit declaration of function 'irq_domain_add_legacy'
Should we select IRQ_DOMAIN for PXA?
Will it work for other drivers?
> + return -ENODEV;
> +
> + gpiochip_add(c);
> + }
> + pxa_gpio_chips = chips;
> + return 0;
> +}
> +
> static int pxa_gpio_probe(struct platform_device *pdev)
> {
> struct pxa_gpio_chip *c;
[...]
--
Regards,
Igor.
next prev parent reply other threads:[~2013-01-28 11:07 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-23 8:25 [PATCH 00/10] rework gpio pxa driver for pinctrl Haojian Zhuang
2013-01-23 8:25 ` [PATCH 01/10] gpio: pxa: set initcall level to module init Haojian Zhuang
2013-01-25 9:51 ` Linus Walleij
2013-01-25 21:01 ` Robert Jarzmik
2013-01-28 4:26 ` Haojian Zhuang
2013-01-28 10:27 ` Linus Walleij
2013-01-23 8:25 ` [PATCH 02/10] gpio: pxa: identify ed mask reg with platform data Haojian Zhuang
2013-01-25 9:54 ` Linus Walleij
2013-01-25 9:57 ` Linus Walleij
2013-01-25 10:00 ` Haojian Zhuang
2013-01-29 17:33 ` Olof Johansson
2013-01-23 8:25 ` [PATCH 03/10] gpio: pxa: avoid to use global irq base Haojian Zhuang
2013-01-28 11:07 ` Igor Grinberg [this message]
2013-01-29 16:13 ` Haojian Zhuang
2013-01-23 8:25 ` [PATCH 04/10] gpio: pxa: use platform data for gpio inverted Haojian Zhuang
2013-01-25 9:59 ` Linus Walleij
2013-01-23 8:25 ` [PATCH 05/10] gpio: pxa: remove gpio_type Haojian Zhuang
2013-01-25 10:01 ` Linus Walleij
2013-01-28 11:29 ` Igor Grinberg
2013-01-31 20:54 ` Linus Walleij
2013-01-23 8:25 ` [PATCH 06/10] gpio: pxa: define nr gpios in platform data Haojian Zhuang
2013-01-28 8:02 ` Igor Grinberg
2013-01-23 8:25 ` [PATCH 07/10] gpio: pxa: clean code for compatible name Haojian Zhuang
2013-01-23 8:25 ` [PATCH 08/10] gpio: pxa: remove arch related macro Haojian Zhuang
2013-01-23 8:25 ` [PATCH 09/10] gpio: pxa: move gpio properties into child node Haojian Zhuang
2013-01-28 11:27 ` Igor Grinberg
2013-01-23 8:25 ` [PATCH 10/10] gpio: pxa: bind to pinctrl by request Haojian Zhuang
2013-01-23 12:27 ` [PATCH 00/10] rework gpio pxa driver for pinctrl Linus Walleij
[not found] ` <20130123131503.GJ2239@intel.com>
2013-01-25 9:49 ` Linus Walleij
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=51065BFC.6000205@compulab.co.il \
--to=grinberg@compulab$(echo .)co.il \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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