From: Stephen Boyd <sboyd@codeaurora.org>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-input@vger.kernel.org
Subject: [PATCH 3/7] Input: pm8xxx-vibrator - Migrate to devm_* APIs
Date: Tue, 10 Dec 2013 15:43:12 -0800 [thread overview]
Message-ID: <1386718996-3733-4-git-send-email-sboyd@codeaurora.org> (raw)
In-Reply-To: <1386718996-3733-1-git-send-email-sboyd@codeaurora.org>
Simplify the error paths and reduce the lines of code in this
driver by using the devm_* APIs.
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
---
drivers/input/misc/pm8xxx-vibrator.c | 44 +++++++++++-------------------------
1 file changed, 13 insertions(+), 31 deletions(-)
diff --git a/drivers/input/misc/pm8xxx-vibrator.c b/drivers/input/misc/pm8xxx-vibrator.c
index ec086f6..2a92ab0 100644
--- a/drivers/input/misc/pm8xxx-vibrator.c
+++ b/drivers/input/misc/pm8xxx-vibrator.c
@@ -186,13 +186,13 @@ static int pm8xxx_vib_probe(struct platform_device *pdev)
int error;
u8 val;
- vib = kzalloc(sizeof(*vib), GFP_KERNEL);
- input_dev = input_allocate_device();
- if (!vib || !input_dev) {
- dev_err(&pdev->dev, "couldn't allocate memory\n");
- error = -ENOMEM;
- goto err_free_mem;
- }
+ vib = devm_kzalloc(&pdev->dev, sizeof(*vib), GFP_KERNEL);
+ if (!vib)
+ return -ENOMEM;
+
+ input_dev = devm_input_allocate_device(&pdev->dev);
+ if (!input_dev)
+ return -ENOMEM;
INIT_WORK(&vib->work, pm8xxx_work_handler);
vib->dev = &pdev->dev;
@@ -201,17 +201,17 @@ static int pm8xxx_vib_probe(struct platform_device *pdev)
/* operate in manual mode */
error = pm8xxx_vib_read_u8(vib, &val, VIB_DRV);
if (error < 0)
- goto err_free_mem;
+ return error;
+
val &= ~VIB_DRV_EN_MANUAL_MASK;
error = pm8xxx_vib_write_u8(vib, val, VIB_DRV);
if (error < 0)
- goto err_free_mem;
+ return error;
vib->reg_vib_drv = val;
input_dev->name = "pm8xxx_vib_ffmemless";
input_dev->id.version = 1;
- input_dev->dev.parent = &pdev->dev;
input_dev->close = pm8xxx_vib_close;
input_set_drvdata(input_dev, vib);
input_set_capability(vib->vib_input_dev, EV_FF, FF_RUMBLE);
@@ -221,35 +221,18 @@ static int pm8xxx_vib_probe(struct platform_device *pdev)
if (error) {
dev_err(&pdev->dev,
"couldn't register vibrator as FF device\n");
- goto err_free_mem;
+ return error;
}
error = input_register_device(input_dev);
if (error) {
dev_err(&pdev->dev, "couldn't register input device\n");
- goto err_destroy_memless;
+ input_ff_destroy(input_dev);
+ return error;
}
platform_set_drvdata(pdev, vib);
return 0;
-
-err_destroy_memless:
- input_ff_destroy(input_dev);
-err_free_mem:
- input_free_device(input_dev);
- kfree(vib);
-
- return error;
-}
-
-static int pm8xxx_vib_remove(struct platform_device *pdev)
-{
- struct pm8xxx_vib *vib = platform_get_drvdata(pdev);
-
- input_unregister_device(vib->vib_input_dev);
- kfree(vib);
-
- return 0;
}
#ifdef CONFIG_PM_SLEEP
@@ -268,7 +251,6 @@ static SIMPLE_DEV_PM_OPS(pm8xxx_vib_pm_ops, pm8xxx_vib_suspend, NULL);
static struct platform_driver pm8xxx_vib_driver = {
.probe = pm8xxx_vib_probe,
- .remove = pm8xxx_vib_remove,
.driver = {
.name = "pm8xxx-vib",
.owner = THIS_MODULE,
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
next prev parent reply other threads:[~2013-12-10 23:43 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-10 23:43 [PATCH 0/7] Use regmap+devm in pm8xxx input drivers Stephen Boyd
2013-12-10 23:43 ` [PATCH 1/7] Input: pmic8xxx-pwrkey - Pass input device directly to interrupt Stephen Boyd
2013-12-15 11:21 ` Dmitry Torokhov
2013-12-16 19:59 ` Stephen Boyd
2013-12-10 23:43 ` [PATCH 2/7] Input: pmic8xxx-pwrkey - Migrate to regmap APIs Stephen Boyd
2013-12-15 11:33 ` Dmitry Torokhov
2014-01-02 18:49 ` Mark Brown
2014-01-02 19:17 ` Dmitry Torokhov
2014-01-03 0:50 ` Mark Brown
2014-01-21 9:34 ` bug fix for mmc queue.c Wang, Yalin
2013-12-10 23:43 ` Stephen Boyd [this message]
2013-12-10 23:43 ` [PATCH 4/7] Input: pm8xxx-vibrator - Migrate to regmap APIs Stephen Boyd
2013-12-10 23:43 ` [PATCH 5/7] genirq: Add devm_request_any_context_irq() Stephen Boyd
2013-12-15 10:42 ` Dmitry Torokhov
2013-12-10 23:43 ` [PATCH 6/7] Input: pmic8xxx-keypad - Migrate to devm_* APIs Stephen Boyd
2013-12-16 15:37 ` Dmitry Torokhov
2013-12-17 2:01 ` spamassassin system account
2013-12-10 23:43 ` [PATCH 7/7] Input: pmic8xxx-keypad - Migrate to regmap APIs Stephen Boyd
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=1386718996-3733-4-git-send-email-sboyd@codeaurora.org \
--to=sboyd@codeaurora.org \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@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).