From: NeilBrown <neil@brown.name>
To: Sebastian Reichel <sre@kernel.org>
Cc: NeilBrown <neilb@suse.de>,
linux-api@vger.kernel.org, linux-kernel@vger.kernel.org,
GTA04 owners <gta04-owner@goldelico.com>,
inux-pm@vger.kernel.org, Pavel Machek <pavel@ucw.cz>,
linux-omap@vger.kernel.org, Lee Jones <lee.jones@linaro.org>
Subject: [PATCH 02/14] twl4030_charger: use devres for power_supply_register and kzalloc.
Date: Mon, 23 Mar 2015 10:20:28 +1100 [thread overview]
Message-ID: <20150322232028.23789.38570.stgit@notabene.brown> (raw)
In-Reply-To: <20150322231635.23789.70149.stgit@notabene.brown>
From: NeilBrown <neilb@suse.de>
Final allocations/registrations are now managed by devres.
Signed-off-by: NeilBrown <neilb@suse.de>
---
drivers/power/twl4030_charger.c | 32 +++++++++-----------------------
1 file changed, 9 insertions(+), 23 deletions(-)
diff --git a/drivers/power/twl4030_charger.c b/drivers/power/twl4030_charger.c
index 58996d252ecf..7b6c4000cd30 100644
--- a/drivers/power/twl4030_charger.c
+++ b/drivers/power/twl4030_charger.c
@@ -565,7 +565,7 @@ static int __init twl4030_bci_probe(struct platform_device *pdev)
int ret;
u32 reg;
- bci = kzalloc(sizeof(*bci), GFP_KERNEL);
+ bci = devm_kzalloc(&pdev->dev, sizeof(*bci), GFP_KERNEL);
if (bci == NULL)
return -ENOMEM;
@@ -580,7 +580,7 @@ static int __init twl4030_bci_probe(struct platform_device *pdev)
ret = twl4030_is_battery_present(bci);
if (ret) {
dev_crit(&pdev->dev, "Battery was not detected:%d\n", ret);
- goto fail_no_battery;
+ return ret;
}
platform_set_drvdata(pdev, bci);
@@ -590,10 +590,10 @@ static int __init twl4030_bci_probe(struct platform_device *pdev)
bci->ac.num_properties = ARRAY_SIZE(twl4030_charger_props);
bci->ac.get_property = twl4030_bci_get_property;
- ret = power_supply_register(&pdev->dev, &bci->ac);
+ ret = devm_power_supply_register(&pdev->dev, &bci->ac);
if (ret) {
dev_err(&pdev->dev, "failed to register ac: %d\n", ret);
- goto fail_register_ac;
+ return ret;
}
bci->usb.name = "twl4030_usb";
@@ -604,10 +604,10 @@ static int __init twl4030_bci_probe(struct platform_device *pdev)
bci->usb_reg = regulator_get(bci->dev, "bci3v1");
- ret = power_supply_register(&pdev->dev, &bci->usb);
+ ret = devm_power_supply_register(&pdev->dev, &bci->usb);
if (ret) {
dev_err(&pdev->dev, "failed to register usb: %d\n", ret);
- goto fail_register_usb;
+ return ret;
}
ret = devm_request_threaded_irq(&pdev->dev, bci->irq_chg, NULL,
@@ -616,7 +616,7 @@ static int __init twl4030_bci_probe(struct platform_device *pdev)
if (ret < 0) {
dev_err(&pdev->dev, "could not request irq %d, status %d\n",
bci->irq_chg, ret);
- goto fail;
+ return ret;
}
ret = devm_request_threaded_irq(&pdev->dev, bci->irq_bci, NULL,
@@ -624,7 +624,7 @@ static int __init twl4030_bci_probe(struct platform_device *pdev)
if (ret < 0) {
dev_err(&pdev->dev, "could not request irq %d, status %d\n",
bci->irq_bci, ret);
- goto fail;
+ return ret;
}
INIT_WORK(&bci->work, twl4030_bci_usb_work);
@@ -647,7 +647,7 @@ static int __init twl4030_bci_probe(struct platform_device *pdev)
TWL4030_INTERRUPTS_BCIIMR1A);
if (ret < 0) {
dev_err(&pdev->dev, "failed to unmask interrupts: %d\n", ret);
- goto fail;
+ return ret;
}
reg = ~(u32)(TWL4030_VBATOV | TWL4030_VBUSOV | TWL4030_ACCHGOV);
@@ -665,16 +665,6 @@ static int __init twl4030_bci_probe(struct platform_device *pdev)
twl4030_charger_enable_backup(0, 0);
return 0;
-
-fail:
- power_supply_unregister(&bci->usb);
-fail_register_usb:
- power_supply_unregister(&bci->ac);
-fail_register_ac:
-fail_no_battery:
- kfree(bci);
-
- return ret;
}
static int __exit twl4030_bci_remove(struct platform_device *pdev)
@@ -691,10 +681,6 @@ static int __exit twl4030_bci_remove(struct platform_device *pdev)
twl_i2c_write_u8(TWL4030_MODULE_INTERRUPTS, 0xff,
TWL4030_INTERRUPTS_BCIIMR2A);
- power_supply_unregister(&bci->usb);
- power_supply_unregister(&bci->ac);
- kfree(bci);
-
return 0;
}
next prev parent reply other threads:[~2015-03-22 23:20 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-22 23:20 [PATCH 00/14] Enhance twl4030_charger functionality. - V2 NeilBrown
2015-03-22 23:20 ` [PATCH 04/14] twl4030_charger: trust phy to determine when USB power is available NeilBrown
2015-03-22 23:20 ` [PATCH 05/14] twl4030_charger: split uA calculation into a function NeilBrown
2015-03-22 23:20 ` [PATCH 01/14] twl4030_charger: use devm_request_threaded_irq NeilBrown
2015-07-24 14:34 ` Sebastian Reichel
2015-03-22 23:20 ` NeilBrown [this message]
2015-03-23 21:25 ` [PATCH 02/14] twl4030_charger: use devres for power_supply_register and kzalloc Pavel Machek
[not found] ` <20150322232028.23789.38570.stgit-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2015-07-24 14:35 ` Sebastian Reichel
2015-03-22 23:20 ` [PATCH 03/14] twl4030_charger: use runtime_pm to keep usb phy active while charging NeilBrown
2015-03-22 23:20 ` [PATCH 06/14] twl4030_charger: allow fine control of charger current NeilBrown
2015-03-22 23:20 ` [PATCH 12/14] twl4030_charger: add ac/mode to match usb/mode NeilBrown
2015-03-22 23:20 ` [PATCH 13/14] twl4030_charger: Increase current carefully while watching voltage NeilBrown
2015-03-23 21:25 ` Pavel Machek
2015-03-29 21:26 ` NeilBrown
[not found] ` <20150330082637.4bf4832d-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2015-04-04 7:48 ` Pavel Machek
2015-03-22 23:20 ` [PATCH 08/14] twl4030_charger: allow max_current to be managed via sysfs NeilBrown
[not found] ` <20150322232029.23789.13768.stgit-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2015-03-23 12:14 ` [Gta04-owner] " jake42
2015-07-29 22:10 ` NeilBrown
2015-03-22 23:20 ` [PATCH 07/14] twl4030_charger: distinguish between USB current and 'AC' current NeilBrown
2015-03-22 23:20 ` [PATCH 10/14] twl4030_charger: enable manual enable/disable of usb charging NeilBrown
2015-03-22 23:20 ` [PATCH 14/14] twl4030_charger: assume a 'charger' can supply maximum current NeilBrown
2015-03-22 23:20 ` [PATCH 09/14] twl4030_charger: only draw USB current as negotiated with host NeilBrown
[not found] ` <20150322231635.23789.70149.stgit-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2015-03-22 23:20 ` [PATCH 11/14] twl4030_charger: add software controlled linear charging mode NeilBrown
2015-07-24 14:44 ` [PATCH 00/14] Enhance twl4030_charger functionality. - V2 Sebastian Reichel
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=20150322232028.23789.38570.stgit@notabene.brown \
--to=neil@brown.name \
--cc=gta04-owner@goldelico.com \
--cc=inux-pm@vger.kernel.org \
--cc=lee.jones@linaro.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=neilb@suse.de \
--cc=pavel@ucw.cz \
--cc=sre@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).