linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: haojian.zhuang@gmail.com (Haojian Zhuang)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 03/05] input: enable onkey driver of max8925
Date: Thu, 20 May 2010 09:46:51 +0800	[thread overview]
Message-ID: <AANLkTik3hGTMATHu80Tn6OeaHkEObFbhR-S7xHaIIQQV@mail.gmail.com> (raw)
In-Reply-To: <20100519163041.GA18753@core.coreip.homeip.net>

On Thu, May 20, 2010 at 12:30 AM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> Hi Haojian,
>
> On Wed, May 19, 2010 at 02:58:07PM +0800, Haojian Zhuang wrote:
>> +
>> +/* MAX8925 gives us an interrupt when ONKEY is held for 3 seconds. */
>> +static irqreturn_t max8925_onkey_handler(int irq, void *data)
>> +{
>> + ? ? struct max8925_onkey_info *info = data;
>> +
>> + ? ? input_report_key(info->idev, KEY_POWER, 1);
>> + ? ? input_sync(info->idev);
>> +
>> + ? ? /* Enable hardreset to halt if system isn't shutdown on time */
>
> A comment mentioning that max8925_set_bits() may sleep would instantly
> remove all concerns why threaded IRQ is being used here.
>
>> + ? ? ret = request_threaded_irq(irq, NULL, max8925_onkey_handler,
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?IRQF_ONESHOT, "onkey", info);
>> + ? ? if (ret < 0) {
>> + ? ? ? ? ? ? dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n",
>> + ? ? ? ? ? ? ? ? ? ? irq, ret);
>> + ? ? ? ? ? ? goto out;
>> + ? ? }
>> +
>> + ? ? info->idev = input_allocate_device();
>> + ? ? if (!info->idev) {
>> + ? ? ? ? ? ? dev_err(chip->dev, "Failed to allocate input dev\n");
>> + ? ? ? ? ? ? ret = -ENOMEM;
>> + ? ? ? ? ? ? goto out_input;
>> + ? ? }
>> +
>
> You need to allocate device before requesting IRQ otherwise it may crash
> and burn.
>
>> +static int __devexit max8925_onkey_remove(struct platform_device *pdev)
>> +{
>> + ? ? struct max8925_onkey_info *info = platform_get_drvdata(pdev);
>> +
>> + ? ? if (info) {
>
> How can info be NULL?
>
>> + ? ? ? ? ? ? free_irq(info->irq, info);
>> + ? ? ? ? ? ? input_unregister_device(info->idev);
>> + ? ? ? ? ? ? kfree(info);
>
> platform_set_drvdata(pdev, NULL); - please clean up after yourself.
>
> Thanks.
>
> --
> Dmitry
>

Thanks a lot. Now the updated patch is attached and pasted in below.

Best Regards
Haojian

      reply	other threads:[~2010-05-20  1:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-19  6:58 [PATCH 03/05] input: enable onkey driver of max8925 Haojian Zhuang
2010-05-19 16:30 ` Dmitry Torokhov
2010-05-20  1:46   ` Haojian Zhuang [this message]

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=AANLkTik3hGTMATHu80Tn6OeaHkEObFbhR-S7xHaIIQQV@mail.gmail.com \
    --to=haojian.zhuang@gmail.com \
    --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 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).