From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
spear-devel@list.st.com
Subject: Re: [PATCH 1/3] input: stmpe-keyboard: Use devm_*() routines
Date: Fri, 9 Nov 2012 08:45:03 -0800 [thread overview]
Message-ID: <20121109164503.GA17752@core.coreip.homeip.net> (raw)
In-Reply-To: <3d6f34ca5960203a5efb761f4d56b4e10ee24827.1352474824.git.viresh.kumar@linaro.org>
Hi Viresh,
On Fri, Nov 09, 2012 at 08:57:48PM +0530, Viresh Kumar wrote:
> This patch frees stmpe-keyboard driver from tension of freeing resources :)
> devm_* derivatives of multiple routines are used while allocating resources,
> which would be freed automatically by kernel.
>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> drivers/input/keyboard/stmpe-keypad.c | 31 ++++++++++---------------------
> 1 file changed, 10 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/input/keyboard/stmpe-keypad.c b/drivers/input/keyboard/stmpe-keypad.c
> index 470a877..6e25497 100644
> --- a/drivers/input/keyboard/stmpe-keypad.c
> +++ b/drivers/input/keyboard/stmpe-keypad.c
> @@ -275,15 +275,14 @@ static int __devinit stmpe_keypad_probe(struct platform_device *pdev)
> if (irq < 0)
> return irq;
>
> - keypad = kzalloc(sizeof(struct stmpe_keypad), GFP_KERNEL);
> + keypad = devm_kzalloc(&pdev->dev, sizeof(struct stmpe_keypad),
> + GFP_KERNEL);
> if (!keypad)
> return -ENOMEM;
>
> - input = input_allocate_device();
> - if (!input) {
> - ret = -ENOMEM;
> - goto out_freekeypad;
> - }
> + input = devm_input_allocate_device(&pdev->dev);
> + if (!input)
> + return -ENOMEM;
>
> input->name = "STMPE keypad";
> input->id.bustype = BUS_I2C;
> @@ -294,7 +293,7 @@ static int __devinit stmpe_keypad_probe(struct platform_device *pdev)
> STMPE_KEYPAD_MAX_COLS,
> keypad->keymap, input);
> if (ret)
> - goto out_freeinput;
> + return ret;
>
> input_set_capability(input, EV_MSC, MSC_SCAN);
> if (!plat->no_autorepeat)
> @@ -314,17 +313,17 @@ static int __devinit stmpe_keypad_probe(struct platform_device *pdev)
>
> ret = stmpe_keypad_chip_init(keypad);
> if (ret < 0)
> - goto out_freeinput;
> + return ret;
>
> ret = input_register_device(input);
> if (ret) {
> dev_err(&pdev->dev,
> "unable to register input device: %d\n", ret);
> - goto out_freeinput;
> + return ret;
> }
>
> - ret = request_threaded_irq(irq, NULL, stmpe_keypad_irq, IRQF_ONESHOT,
> - "stmpe-keypad", keypad);
> + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, stmpe_keypad_irq,
> + IRQF_ONESHOT, "stmpe-keypad", keypad);
> if (ret) {
> dev_err(&pdev->dev, "unable to get irq: %d\n", ret);
> goto out_unregisterinput;
> @@ -336,11 +335,6 @@ static int __devinit stmpe_keypad_probe(struct platform_device *pdev)
>
> out_unregisterinput:
> input_unregister_device(input);
If input device was alocated with devm_* interface it does not need be
explicitly unregistered/freed.
Thanks.
--
Dmitry
next prev parent reply other threads:[~2012-11-09 16:47 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-09 15:27 [PATCH 1/3] input: stmpe-keyboard: Use devm_*() routines Viresh Kumar
2012-11-09 15:27 ` [PATCH 2/3] input: stmpe-ts: " Viresh Kumar
2012-11-09 17:04 ` Viresh Kumar
2012-11-10 8:00 ` Dmitry Torokhov
2012-11-10 8:03 ` Viresh Kumar
2012-11-10 8:04 ` Viresh Kumar
2012-11-10 8:12 ` Dmitry Torokhov
2012-11-10 8:15 ` Hannes Frederic Sowa
2012-11-09 15:27 ` [PATCH 3/3] input:stmpe-ts:Initialize the phys field for input device Viresh Kumar
2012-11-20 6:58 ` Viresh Kumar
2012-11-20 7:47 ` Dmitry Torokhov
2012-11-20 7:57 ` Viresh Kumar
2012-11-09 16:45 ` Dmitry Torokhov [this message]
2012-11-09 17:03 ` [PATCH 1/3] input: stmpe-keyboard: Use devm_*() routines Viresh Kumar
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=20121109164503.GA17752@core.coreip.homeip.net \
--to=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=spear-devel@list.st.com \
--cc=viresh.kumar@linaro.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).