From: Fabio Estevam <fabio.estevam@freescale.com>
To: dmitry.torokhov@gmail.com
Cc: linux-input@vger.kernel.org, lars@metafoo.de,
Fabio Estevam <fabio.estevam@freescale.com>
Subject: [PATCH] Input: pwm-beeper - Use devm functions
Date: Thu, 19 Feb 2015 09:26:02 -0200 [thread overview]
Message-ID: <1424345162-17260-1-git-send-email-fabio.estevam@freescale.com> (raw)
By using devm functions the code can be simplified a bit.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
drivers/input/misc/pwm-beeper.c | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/drivers/input/misc/pwm-beeper.c b/drivers/input/misc/pwm-beeper.c
index a28ee70..c5ccaee 100644
--- a/drivers/input/misc/pwm-beeper.c
+++ b/drivers/input/misc/pwm-beeper.c
@@ -72,11 +72,11 @@ static int pwm_beeper_probe(struct platform_device *pdev)
struct pwm_beeper *beeper;
int error;
- beeper = kzalloc(sizeof(*beeper), GFP_KERNEL);
+ beeper = devm_kzalloc(&pdev->dev, sizeof(*beeper), GFP_KERNEL);
if (!beeper)
return -ENOMEM;
- beeper->pwm = pwm_get(&pdev->dev, NULL);
+ beeper->pwm = devm_pwm_get(&pdev->dev, NULL);
if (IS_ERR(beeper->pwm)) {
dev_dbg(&pdev->dev, "unable to request PWM, trying legacy API\n");
beeper->pwm = pwm_request(pwm_id, "pwm beeper");
@@ -85,14 +85,13 @@ static int pwm_beeper_probe(struct platform_device *pdev)
if (IS_ERR(beeper->pwm)) {
error = PTR_ERR(beeper->pwm);
dev_err(&pdev->dev, "Failed to request pwm device: %d\n", error);
- goto err_free;
+ return error;
}
- beeper->input = input_allocate_device();
+ beeper->input = devm_input_allocate_device(&pdev->dev);
if (!beeper->input) {
dev_err(&pdev->dev, "Failed to allocate input device\n");
- error = -ENOMEM;
- goto err_pwm_free;
+ return -ENOMEM;
}
beeper->input->dev.parent = &pdev->dev;
@@ -122,10 +121,6 @@ static int pwm_beeper_probe(struct platform_device *pdev)
err_input_free:
input_free_device(beeper->input);
-err_pwm_free:
- pwm_free(beeper->pwm);
-err_free:
- kfree(beeper);
return error;
}
@@ -137,9 +132,6 @@ static int pwm_beeper_remove(struct platform_device *pdev)
input_unregister_device(beeper->input);
pwm_disable(beeper->pwm);
- pwm_free(beeper->pwm);
-
- kfree(beeper);
return 0;
}
--
1.9.1
next reply other threads:[~2015-02-19 12:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-19 11:26 Fabio Estevam [this message]
2015-02-19 17:12 ` [PATCH] Input: pwm-beeper - Use devm functions Dmitry Torokhov
2015-02-19 18:40 ` Fabio.Estevam
2015-02-19 18:46 ` Dmitry Torokhov
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=1424345162-17260-1-git-send-email-fabio.estevam@freescale.com \
--to=fabio.estevam@freescale.com \
--cc=dmitry.torokhov@gmail.com \
--cc=lars@metafoo.de \
--cc=linux-input@vger.kernel.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).