From: Andrew Davis <afd@ti.com>
To: "Sebastian Reichel" <sre@kernel.org>,
"Support Opensource" <support.opensource@diasemi.com>,
"Krzysztof Kozlowski" <krzysztof.kozlowski@linaro.org>,
"Pali Rohár" <pali@kernel.org>
Cc: <linux-pm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Andrew Davis <afd@ti.com>
Subject: [PATCH 18/21] power: supply: rx51: Use devm_iio_channel_get() helper
Date: Tue, 23 Jan 2024 10:36:50 -0600 [thread overview]
Message-ID: <20240123163653.384385-19-afd@ti.com> (raw)
In-Reply-To: <20240123163653.384385-1-afd@ti.com>
Use the device lifecycle managed get function. This helps prevent
mistakes like releasing out of order in cleanup functions and
forgetting to release on error paths.
Signed-off-by: Andrew Davis <afd@ti.com>
---
drivers/power/supply/rx51_battery.c | 45 +++++++----------------------
1 file changed, 11 insertions(+), 34 deletions(-)
diff --git a/drivers/power/supply/rx51_battery.c b/drivers/power/supply/rx51_battery.c
index e2bfc81f0fd97..d532c670661b6 100644
--- a/drivers/power/supply/rx51_battery.c
+++ b/drivers/power/supply/rx51_battery.c
@@ -192,7 +192,6 @@ static int rx51_battery_probe(struct platform_device *pdev)
{
struct power_supply_config psy_cfg = {};
struct rx51_device_info *di;
- int ret;
di = devm_kzalloc(&pdev->dev, sizeof(*di), GFP_KERNEL);
if (!di)
@@ -209,41 +208,23 @@ static int rx51_battery_probe(struct platform_device *pdev)
psy_cfg.drv_data = di;
- di->channel_temp = iio_channel_get(di->dev, "temp");
- if (IS_ERR(di->channel_temp)) {
- ret = PTR_ERR(di->channel_temp);
- goto error;
- }
+ di->channel_temp = devm_iio_channel_get(di->dev, "temp");
+ if (IS_ERR(di->channel_temp))
+ return PTR_ERR(di->channel_temp);
- di->channel_bsi = iio_channel_get(di->dev, "bsi");
- if (IS_ERR(di->channel_bsi)) {
- ret = PTR_ERR(di->channel_bsi);
- goto error_channel_temp;
- }
+ di->channel_bsi = devm_iio_channel_get(di->dev, "bsi");
+ if (IS_ERR(di->channel_bsi))
+ return PTR_ERR(di->channel_bsi);
- di->channel_vbat = iio_channel_get(di->dev, "vbat");
- if (IS_ERR(di->channel_vbat)) {
- ret = PTR_ERR(di->channel_vbat);
- goto error_channel_bsi;
- }
+ di->channel_vbat = devm_iio_channel_get(di->dev, "vbat");
+ if (IS_ERR(di->channel_vbat))
+ return PTR_ERR(di->channel_vbat);
di->bat = power_supply_register(di->dev, &di->bat_desc, &psy_cfg);
- if (IS_ERR(di->bat)) {
- ret = PTR_ERR(di->bat);
- goto error_channel_vbat;
- }
+ if (IS_ERR(di->bat))
+ return PTR_ERR(di->bat);
return 0;
-
-error_channel_vbat:
- iio_channel_release(di->channel_vbat);
-error_channel_bsi:
- iio_channel_release(di->channel_bsi);
-error_channel_temp:
- iio_channel_release(di->channel_temp);
-error:
-
- return ret;
}
static void rx51_battery_remove(struct platform_device *pdev)
@@ -251,10 +232,6 @@ static void rx51_battery_remove(struct platform_device *pdev)
struct rx51_device_info *di = platform_get_drvdata(pdev);
power_supply_unregister(di->bat);
-
- iio_channel_release(di->channel_vbat);
- iio_channel_release(di->channel_bsi);
- iio_channel_release(di->channel_temp);
}
#ifdef CONFIG_OF
--
2.39.2
next prev parent reply other threads:[~2024-01-23 16:37 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-23 16:36 [PATCH 00/21] Power supply register with devm Andrew Davis
2024-01-23 16:36 ` [PATCH 01/21] power: supply: da9030: Use devm_power_supply_register() helper Andrew Davis
2024-01-23 16:36 ` [PATCH 02/21] power: supply: da9052: " Andrew Davis
2024-01-23 16:36 ` [PATCH 03/21] power: supply: ds2760: " Andrew Davis
2024-01-23 16:36 ` [PATCH 04/21] power: supply: goldfish: " Andrew Davis
2024-01-23 16:36 ` [PATCH 05/21] power: supply: lp8727: " Andrew Davis
2024-01-23 16:36 ` [PATCH 06/21] power: supply: lp8788: " Andrew Davis
2024-01-23 16:36 ` [PATCH 07/21] power: supply: max14577: " Andrew Davis
2024-01-23 16:36 ` [PATCH 08/21] power: supply: max77693: " Andrew Davis
2024-01-26 11:56 ` kernel test robot
2024-01-23 16:36 ` [PATCH 09/21] power: supply: max8925: " Andrew Davis
2024-01-26 12:28 ` kernel test robot
2024-01-23 16:36 ` [PATCH 10/21] power: supply: pcf50633: " Andrew Davis
2024-01-23 16:36 ` [PATCH 11/21] power: supply: rt5033: " Andrew Davis
2024-01-23 16:36 ` [PATCH 12/21] power: supply: tps65090: " Andrew Davis
2024-01-23 16:36 ` [PATCH 13/21] power: supply: wm831x: " Andrew Davis
2024-01-23 16:36 ` [PATCH 14/21] " Andrew Davis
2024-01-23 16:36 ` [PATCH 15/21] power: supply: wm8350: " Andrew Davis
2024-01-26 13:00 ` kernel test robot
2024-01-23 16:36 ` [PATCH 16/21] power: supply: da9150: Use devm_iio_channel_get() helper Andrew Davis
2024-01-23 16:36 ` [PATCH 17/21] power: supply: da9150: Use devm_power_supply_register() helper Andrew Davis
2024-01-23 16:36 ` Andrew Davis [this message]
2024-01-23 16:36 ` [PATCH 19/21] power: supply: rx51: " Andrew Davis
2024-01-23 16:36 ` [PATCH 20/21] power: supply: twl4030_madc: Use devm_iio_channel_get() helper Andrew Davis
2024-01-23 16:36 ` [PATCH 21/21] power: supply: twl4030_madc: Use devm_power_supply_register() helper Andrew Davis
2024-01-27 0:48 ` (subset) [PATCH 00/21] Power supply register with devm 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=20240123163653.384385-19-afd@ti.com \
--to=afd@ti.com \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=pali@kernel.org \
--cc=sre@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).