From: Sebastian Reichel <sebastian.reichel@collabora.com>
To: Sebastian Reichel <sre@kernel.org>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel@collabora.com,
Sebastian Reichel <sebastian.reichel@collabora.com>
Subject: [PATCH 4/7] power: supply: sbs-manager: use managed i2c_mux_adapter
Date: Tue, 9 Mar 2021 19:04:04 +0100 [thread overview]
Message-ID: <20210309180407.650943-5-sebastian.reichel@collabora.com> (raw)
In-Reply-To: <20210309180407.650943-1-sebastian.reichel@collabora.com>
Simplify code by using devm_add_action_or_reset to unregister
the i2c_mux_adapter.
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
drivers/power/supply/sbs-manager.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/drivers/power/supply/sbs-manager.c b/drivers/power/supply/sbs-manager.c
index 666243d9dd59..cd2bf0b247fe 100644
--- a/drivers/power/supply/sbs-manager.c
+++ b/drivers/power/supply/sbs-manager.c
@@ -311,6 +311,12 @@ static const struct power_supply_desc sbsm_default_psy_desc = {
.property_is_writeable = &sbsm_prop_is_writeable,
};
+static void sbsm_del_mux_adapter(void *data)
+{
+ struct sbsm_data *sbsm = data;
+ i2c_mux_del_adapters(sbsm->muxc);
+}
+
static int sbsm_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@@ -350,6 +356,10 @@ static int sbsm_probe(struct i2c_client *client,
}
data->muxc->priv = data;
+ ret = devm_add_action_or_reset(dev, sbsm_del_mux_adapter, data);
+ if (ret)
+ return ret;
+
/* register muxed i2c channels. One for each supported battery */
for (i = 0; i < SBSM_MAX_BATS; ++i) {
if (data->supported_bats & BIT(i)) {
@@ -395,20 +405,10 @@ static int sbsm_probe(struct i2c_client *client,
err_psy:
err_mux_register:
- i2c_mux_del_adapters(data->muxc);
-
err_mux_alloc:
return ret;
}
-static int sbsm_remove(struct i2c_client *client)
-{
- struct sbsm_data *data = i2c_get_clientdata(client);
-
- i2c_mux_del_adapters(data->muxc);
- return 0;
-}
-
static const struct i2c_device_id sbsm_ids[] = {
{ "sbs-manager", 0 },
{ "ltc1760", 0 },
@@ -431,7 +431,6 @@ static struct i2c_driver sbsm_driver = {
.of_match_table = of_match_ptr(sbsm_dt_ids),
},
.probe = sbsm_probe,
- .remove = sbsm_remove,
.alert = sbsm_alert,
.id_table = sbsm_ids
};
--
2.30.1
next prev parent reply other threads:[~2021-03-09 18:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-09 18:04 [PATCH 0/7] Cleanup SBS power-supply drivers Sebastian Reichel
2021-03-09 18:04 ` [PATCH 1/7] power: supply: sbs-battery: use dev_err_probe Sebastian Reichel
2021-03-09 18:04 ` [PATCH 2/7] power: supply: sbs-charger: " Sebastian Reichel
2021-03-09 18:04 ` [PATCH 3/7] power: supply: sbs-charger: drop unused gpio includes Sebastian Reichel
2021-03-09 18:04 ` Sebastian Reichel [this message]
2021-03-09 18:04 ` [PATCH 5/7] power: supply: sbs-manager: use dev_err_probe Sebastian Reichel
2021-03-09 18:04 ` [PATCH 6/7] power: supply: sbs-manager: update gpio include Sebastian Reichel
2021-03-09 18:04 ` [PATCH 7/7] power: supply: core: reduce loglevel for probe defer info 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=20210309180407.650943-5-sebastian.reichel@collabora.com \
--to=sebastian.reichel@collabora.com \
--cc=kernel@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--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).