All of lore.kernel.org
 help / color / mirror / Atom feed
From: haojian.zhuang@gmail.com (Haojian Zhuang)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 5/5] input: support onkey in 88pm860x
Date: Thu, 4 Feb 2010 06:08:42 -0500	[thread overview]
Message-ID: <771cded01002040308t3fe112e5leb60bc969fbfcfb@mail.gmail.com> (raw)
In-Reply-To: <20100203173628.GB30600@core.coreip.homeip.net>

On Wed, Feb 3, 2010 at 12:36 PM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> Hi Haojian,
>
> On Wed, Feb 03, 2010 at 08:04:30AM -0500, Haojian Zhuang wrote:
>
> Looks most;y good with the exceptin of the following:
>
>> +
>> + ? ? info = kzalloc(sizeof(struct pm860x_onkey_info), GFP_KERNEL);
>> + ? ? if (!info)
>> + ? ? ? ? ? ? return -ENOMEM;
>> + ? ? info->chip = chip;
>> + ? ? info->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion;
>> + ? ? info->dev = &pdev->dev;
>> + ? ? info->irq = irq + chip->irq_base;
>> +
>> + ? ? ret = request_threaded_irq(info->irq, NULL, pm860x_onkey_handler,
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?IRQF_ONESHOT, "onkey", info);
>> + ? ? if (ret < 0) {
>> + ? ? ? ? ? ? dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n",
>> + ? ? ? ? ? ? ? ? ? ? info->irq, ret);
>> + ? ? ? ? ? ? goto out;
>> + ? ? }
>> +
>> + ? ? info->idev = input_allocate_device();
>
> You can't enable IRQ first and allocate the device later. If IRQ comes
> here it will go "BOOM".
>
>> + ? ? if (!info->idev) {
>> + ? ? ? ? ? ? dev_err(chip->dev, "Failed to allocate input dev\n");
>> + ? ? ? ? ? ? ret = -ENOMEM;
>> + ? ? ? ? ? ? goto out_input;
>> + ? ? }
>> +
>> + ? ? info->idev->name = "88pm860x_on";
>> + ? ? info->idev->phys = "88pm860x_on/input0";
>> + ? ? info->idev->id.bustype = BUS_I2C;
>> + ? ? info->idev->dev.parent = &pdev->dev;
>> + ? ? info->irq = irq;
>> + ? ? info->idev->evbit[0] = BIT_MASK(EV_KEY);
>> + ? ? info->idev->keybit[BIT_WORD(KEY_POWER)] = BIT_MASK(KEY_POWER);
>> +
>> + ? ? ret = input_register_device(info->idev);
>> + ? ? if (ret) {
>> + ? ? ? ? ? ? dev_err(chip->dev, "Can't register input device: %d\n", ret);
>> + ? ? ? ? ? ? goto out_reg;
>> + ? ? }
>> + ? ? platform_set_drvdata(pdev, info);
>> +
>> + ? ? return 0;
>> +
>> +out_reg:
>> + ? ? input_free_device(info->idev);
>> +out_input:
>> + ? ? free_irq(info->irq, info);
>
> So this needs to be in reverse order as well.
>
>> +out:
>> + ? ? kfree(info);
>> + ? ? return ret;
>> +}
>> +
>> +static int __devexit pm860x_onkey_remove(struct platform_device *pdev)
>> +{
>> + ? ? struct pm860x_onkey_info *info = platform_get_drvdata(pdev);
>> +
>> + ? ? if (info) {
>
> "info" will never be NULL, your probe routine makes sure of it. Also it
> is considered a good manners to set drvdata back to NULL after
> unbinding.
>
>> + ? ? ? ? ? ? free_irq(info->irq, info);
>> + ? ? ? ? ? ? input_unregister_device(info->idev);
>> + ? ? ? ? ? ? kfree(info);
>> + ? ? }
>> + ? ? return 0;
>> +}
>> +
>

Fix and format the new patch.

Thanks
Haojian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-input-support-onkey-in-88pm860x.patch
Type: text/x-patch
Size: 6025 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20100204/9345e64e/attachment-0001.bin>

  reply	other threads:[~2010-02-04 11:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-03 13:04 [PATCH 5/5] input: support onkey in 88pm860x Haojian Zhuang
2010-02-03 17:36 ` Dmitry Torokhov
2010-02-04 11:08   ` Haojian Zhuang [this message]
2010-02-05 15:42     ` Samuel Ortiz
2010-02-05 17:11       ` Dmitry Torokhov
2010-02-11 12:42         ` Samuel Ortiz

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=771cded01002040308t3fe112e5leb60bc969fbfcfb@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 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.