From: Guoniu Zhou <guoniu.zhou@oss.nxp.com>
To: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>, Frank Li <Frank.Li@nxp.com>,
Vladimir Zapolskiy <vz@mleia.com>,
Linus Walleij <linusw@kernel.org>,
Bartosz Golaszewski <brgl@kernel.org>
Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, imx@lists.linux.dev,
linux-gpio@vger.kernel.org, Guoniu Zhou <guoniu.zhou@nxp.com>
Subject: [PATCH v6 3/4] media: i2c: ds90ub953: use devm_mutex_init() to simplify code
Date: Fri, 24 Apr 2026 09:42:26 +0800 [thread overview]
Message-ID: <20260424-ds90ub953-v6-3-7a84efbab316@oss.nxp.com> (raw)
In-Reply-To: <20260424-ds90ub953-v6-0-7a84efbab316@oss.nxp.com>
From: Guoniu Zhou <guoniu.zhou@nxp.com>
Use devm_mutex_init() to simplify the code. No functional change.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com>
---
Changes in v6:
- Added Reviewed-by tag from Tomi Valkeinen
Changes in v2:
- Move PTR_ERR() in dev_err_probe();
---
drivers/media/i2c/ds90ub953.c | 33 +++++++++++++--------------------
1 file changed, 13 insertions(+), 20 deletions(-)
diff --git a/drivers/media/i2c/ds90ub953.c b/drivers/media/i2c/ds90ub953.c
index da63dcfbbbc3..c37d9cbe88b9 100644
--- a/drivers/media/i2c/ds90ub953.c
+++ b/drivers/media/i2c/ds90ub953.c
@@ -1299,7 +1299,9 @@ static int ub953_probe(struct i2c_client *client)
if (!priv->plat_data)
return dev_err_probe(dev, -ENODEV, "Platform data missing\n");
- mutex_init(&priv->reg_lock);
+ ret = devm_mutex_init(dev, &priv->reg_lock);
+ if (ret)
+ return ret;
/*
* Initialize to invalid values so that the first reg writes will
@@ -1308,32 +1310,26 @@ static int ub953_probe(struct i2c_client *client)
priv->current_indirect_target = 0xff;
priv->regmap = devm_regmap_init_i2c(client, &ub953_regmap_config);
- if (IS_ERR(priv->regmap)) {
- ret = PTR_ERR(priv->regmap);
- dev_err_probe(dev, ret, "Failed to init regmap\n");
- goto err_mutex_destroy;
- }
+ if (IS_ERR(priv->regmap))
+ return dev_err_probe(dev, PTR_ERR(priv->regmap),
+ "Failed to init regmap\n");
priv->clkin = devm_clk_get_optional(dev, "clkin");
- if (IS_ERR(priv->clkin)) {
- ret = PTR_ERR(priv->clkin);
- dev_err_probe(dev, ret, "failed to parse 'clkin'\n");
- goto err_mutex_destroy;
- }
+ if (IS_ERR(priv->clkin))
+ return dev_err_probe(dev, PTR_ERR(priv->clkin),
+ "Failed to parse 'clkin'\n");
ret = ub953_parse_dt(priv);
if (ret)
- goto err_mutex_destroy;
+ return ret;
ret = ub953_hw_init(priv);
if (ret)
- goto err_mutex_destroy;
+ return ret;
ret = ub953_gpiochip_probe(priv);
- if (ret) {
- dev_err_probe(dev, ret, "Failed to init gpiochip\n");
- goto err_mutex_destroy;
- }
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to init gpiochip\n");
ret = ub953_register_clkout(priv);
if (ret) {
@@ -1357,8 +1353,6 @@ static int ub953_probe(struct i2c_client *client)
ub953_subdev_uninit(priv);
err_gpiochip_remove:
ub953_gpiochip_remove(priv);
-err_mutex_destroy:
- mutex_destroy(&priv->reg_lock);
return ret;
}
@@ -1373,7 +1367,6 @@ static void ub953_remove(struct i2c_client *client)
ub953_subdev_uninit(priv);
ub953_gpiochip_remove(priv);
- mutex_destroy(&priv->reg_lock);
}
static const struct ub953_hw_data ds90ub953_hw = {
--
2.34.1
next prev parent reply other threads:[~2026-04-24 1:40 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-24 1:42 [PATCH v6 0/4] media: i2c: ds90ub953: Add back channel GPIO support Guoniu Zhou
2026-04-24 1:42 ` [PATCH v6 1/4] dt-bindings: media: ti,ds90ub953: Add support for remote GPIO data source Guoniu Zhou
2026-04-24 17:09 ` Conor Dooley
2026-04-27 8:12 ` G.N. Zhou (OSS)
2026-04-27 19:22 ` Conor Dooley
2026-04-26 8:36 ` Linus Walleij
2026-04-27 9:12 ` G.N. Zhou (OSS)
2026-04-27 20:50 ` Linus Walleij
2026-04-28 6:17 ` G.N. Zhou (OSS)
2026-04-28 6:54 ` Tomi Valkeinen
2026-04-29 18:59 ` Linus Walleij
2026-04-24 1:42 ` [PATCH v6 2/4] media: i2c: ds90ub953: Add back channel GPIO support Guoniu Zhou
2026-04-24 1:42 ` Guoniu Zhou [this message]
2026-04-24 8:14 ` [PATCH v6 3/4] media: i2c: ds90ub953: use devm_mutex_init() to simplify code Bartosz Golaszewski
2026-04-24 1:42 ` [PATCH v6 4/4] media: i2c: ds90ub953: use guard() " Guoniu Zhou
2026-04-24 8:15 ` Bartosz Golaszewski
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=20260424-ds90ub953-v6-3-7a84efbab316@oss.nxp.com \
--to=guoniu.zhou@oss.nxp.com \
--cc=Frank.Li@nxp.com \
--cc=brgl@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=guoniu.zhou@nxp.com \
--cc=imx@lists.linux.dev \
--cc=krzk+dt@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=robh@kernel.org \
--cc=tomi.valkeinen@ideasonboard.com \
--cc=vz@mleia.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