linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Chang Rebecca Swee Fun <rebecca.swee.fun.chang@intel.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	GPIO Subsystem Mailing List <linux-gpio@vger.kernel.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Mika Westerberg <mika.westerberg@intel.com>,
	Denis Turischev <denis.turischev@compulab.co.il>,
	Alexandre Courbot <gnurou@gmail.com>
Subject: Re: [PATCHv4 3/3] gpio: sch: Enable IRQ support for Quark X1000
Date: Thu, 27 Nov 2014 12:53:31 +0200	[thread overview]
Message-ID: <CAHp75Vfx=MXU_AV3MZS18xJicWUT8tpiZL+OsSDjLyiQVueOBA@mail.gmail.com> (raw)
In-Reply-To: <1416977280-27319-4-git-send-email-rebecca.swee.fun.chang@intel.com>

On Wed, Nov 26, 2014 at 6:48 AM, Chang Rebecca Swee Fun
<rebecca.swee.fun.chang@intel.com> wrote:
> ntel Quark X1000 GPIO controller supports interrupt handling for
> both core power well and resume power well. This patch is to enable
> the IRQ support and provide IRQ handling for Intel Quark X1000
> GPIO-SCH device driver.
>
> This piece of work is derived from Dan O'Donovan's initial work for
> Quark X1000 enabling.

Minor comments.

[]

>  static int sch_gpio_probe(struct platform_device *pdev)
>  {
>         struct sch_gpio *sch;
>         struct resource *res;
> +       int err;
>
>         sch = devm_kzalloc(&pdev->dev, sizeof(*sch), GFP_KERNEL);
>         if (!sch)
> @@ -167,6 +333,15 @@ static int sch_gpio_probe(struct platform_device *pdev)
>                                  pdev->name))
>                 return -EBUSY;
>
> +       sch->irq = platform_get_irq(pdev, 0);
> +       if (sch->irq >= 0) {
> +               sch->irq_support = true;

Do we need irq_support at all? Can we substitute it by sch->irq >= 0 or … < 0?

> +       } else {
> +               dev_warn(&pdev->dev,
> +                        "failed to obtain irq number for device\n");
> +               sch->irq_support = false;
> +       }
> +
>         spin_lock_init(&sch->lock);
>         sch->iobase = res->start;
>         sch->chip = sch_gpio_chip;
> @@ -215,15 +390,57 @@ static int sch_gpio_probe(struct platform_device *pdev)
>                 return -ENODEV;
>         }
>
> +       gpiochip_add(&sch->chip);
> +
> +       if (sch->irq_support) {
> +               sch->irq_base = irq_alloc_descs(-1, 0, sch->chip.ngpio,
> +                                               NUMA_NO_NODE);
> +               if (sch->irq_base < 0) {
> +                       dev_err(&pdev->dev,
> +                               "failed to allocate GPIO IRQ descs\n");
> +                       goto err_sch_intr_chip;
> +               }
> +
> +               /* disable interrupts */
> +               sch_gpio_irq_disable_all(sch, sch->chip.ngpio);
> +
> +               err = request_irq(sch->irq, sch_gpio_irq_handler, IRQF_SHARED,
> +                                 KBUILD_MODNAME, sch);
> +               if (err) {
> +                       dev_err(&pdev->dev,
> +                               "%s failed to request IRQ\n", __func__);
> +                       goto err_sch_request_irq;
> +               }
> +
> +               sch_gpio_irqs_init(sch, sch->chip.ngpio);
> +       }
> +
>         platform_set_drvdata(pdev, sch);
>
> -       return gpiochip_add(&sch->chip);
> +       return 0;
> +
> +err_sch_request_irq:
> +       irq_free_descs(sch->irq_base, sch->chip.ngpio);
> +
> +err_sch_intr_chip:
> +       gpiochip_remove(&sch->chip);
> +
> +       return err;
>  }
>
>  static int sch_gpio_remove(struct platform_device *pdev)
>  {
>         struct sch_gpio *sch = platform_get_drvdata(pdev);
>
> +       if (sch->irq_support) {
> +               sch_gpio_irqs_deinit(sch, sch->chip.ngpio);
> +
> +               if (sch->irq >= 0)

Is it possible to have irq_support = true and sch->irq < 0?

> +                       free_irq(sch->irq, sch);
> +
> +               irq_free_descs(sch->irq_base, sch->chip.ngpio);
> +       }
> +
>         gpiochip_remove(&sch->chip);
>         return 0;
>  }

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2014-11-27 10:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-26  4:47 [PATCHv4 0/3] Enable Quark X1000 support in gpio-sch Chang Rebecca Swee Fun
2014-11-26  4:47 ` [PATCHv4 1/3] gpio: sch: Consolidate similar algorithms Chang Rebecca Swee Fun
2014-11-28 10:54   ` Mika Westerberg
2014-11-28 13:54   ` Linus Walleij
2014-11-28 13:57     ` Linus Walleij
2014-12-04  8:43   ` Alexandre Courbot
2014-11-26  4:47 ` [PATCHv4 2/3] gpio: sch: Add support for Intel Quark X1000 SoC Chang Rebecca Swee Fun
2014-12-04  8:45   ` Alexandre Courbot
2014-11-26  4:48 ` [PATCHv4 3/3] gpio: sch: Enable IRQ support for Quark X1000 Chang Rebecca Swee Fun
2014-11-27 10:53   ` Andy Shevchenko [this message]
2014-11-28 11:05   ` Mika Westerberg
2014-11-28 14:02   ` Linus Walleij
2014-12-03  2:26     ` Chang, Rebecca Swee Fun
2014-12-04  8:47       ` Alexandre Courbot

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='CAHp75Vfx=MXU_AV3MZS18xJicWUT8tpiZL+OsSDjLyiQVueOBA@mail.gmail.com' \
    --to=andy.shevchenko@gmail.com \
    --cc=denis.turischev@compulab.co.il \
    --cc=gnurou@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mika.westerberg@intel.com \
    --cc=rebecca.swee.fun.chang@intel.com \
    /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).