From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Kiran Padwal <kiran.padwal@smartplayin.com>
Cc: support.opensource@diasemi.com,
anthony.olech.opensource@diasemi.com, david.chen@diasemi.com,
kiran.padwal21@gmail.com, linux-input@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Input: da9052_onkey: convert to use devm_*
Date: Fri, 8 Aug 2014 09:26:10 -0700 [thread overview]
Message-ID: <20140808162610.GE26820@core.coreip.homeip.net> (raw)
In-Reply-To: <1407482324-17713-1-git-send-email-kiran.padwal@smartplayin.com>
Hi Kiran,
On Fri, Aug 08, 2014 at 12:48:44PM +0530, Kiran Padwal wrote:
> Converting to devm functions can make the code smaller and cleaner.
I'd rather not mix use of managed and non-managed resources in one
driver.
Thanks.
>
> Signed-off-by: Kiran Padwal <kiran.padwal@smartplayin.com>
> ---
> drivers/input/misc/da9052_onkey.c | 20 +++++++++-----------
> 1 file changed, 9 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/input/misc/da9052_onkey.c b/drivers/input/misc/da9052_onkey.c
> index 184c8f2..909441e 100644
> --- a/drivers/input/misc/da9052_onkey.c
> +++ b/drivers/input/misc/da9052_onkey.c
> @@ -84,12 +84,14 @@ static int da9052_onkey_probe(struct platform_device *pdev)
> return -EINVAL;
> }
>
> - onkey = kzalloc(sizeof(*onkey), GFP_KERNEL);
> - input_dev = input_allocate_device();
> - if (!onkey || !input_dev) {
> - dev_err(&pdev->dev, "Failed to allocate memory\n");
> - error = -ENOMEM;
> - goto err_free_mem;
> + onkey = devm_kzalloc(&pdev->dev, sizeof(*onkey), GFP_KERNEL);
> + if (!onkey)
> + return -ENOMEM;
> +
> + input_dev = devm_input_allocate_device(&pdev->dev);
> + if (!input_dev) {
> + dev_err(&pdev->dev, "Failed to allocate input device\n");
> + return -ENOMEM;
> }
>
> onkey->input = input_dev;
> @@ -108,7 +110,7 @@ static int da9052_onkey_probe(struct platform_device *pdev)
> if (error < 0) {
> dev_err(onkey->da9052->dev,
> "Failed to register ONKEY IRQ: %d\n", error);
> - goto err_free_mem;
> + return error;
> }
>
> error = input_register_device(onkey->input);
> @@ -124,9 +126,6 @@ static int da9052_onkey_probe(struct platform_device *pdev)
> err_free_irq:
> da9052_free_irq(onkey->da9052, DA9052_IRQ_NONKEY, onkey);
> cancel_delayed_work_sync(&onkey->work);
> -err_free_mem:
> - input_free_device(input_dev);
> - kfree(onkey);
>
> return error;
> }
> @@ -139,7 +138,6 @@ static int da9052_onkey_remove(struct platform_device *pdev)
> cancel_delayed_work_sync(&onkey->work);
>
> input_unregister_device(onkey->input);
> - kfree(onkey);
>
> return 0;
> }
> --
> 1.7.9.5
>
--
Dmitry
prev parent reply other threads:[~2014-08-08 16:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-08 7:18 [PATCH] Input: da9052_onkey: convert to use devm_* Kiran Padwal
2014-08-08 16:26 ` Dmitry Torokhov [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=20140808162610.GE26820@core.coreip.homeip.net \
--to=dmitry.torokhov@gmail.com \
--cc=anthony.olech.opensource@diasemi.com \
--cc=david.chen@diasemi.com \
--cc=kiran.padwal21@gmail.com \
--cc=kiran.padwal@smartplayin.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=support.opensource@diasemi.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).