* [PATCH] media: i2c: t4ka3: power down sensor on resume failure and use devm_mutex_init
@ 2026-07-24 8:39 kr494167
0 siblings, 0 replies; only message in thread
From: kr494167 @ 2026-07-24 8:39 UTC (permalink / raw)
To: hpa, mchehab
Cc: johannes.goede, sakari.ailus, hverkuil+cisco, linux-media,
linux-kernel, Surendra Singh Chouhan
From: Surendra Singh Chouhan <kr494167@gmail.com>
t4ka3_probe() calls t4ka3_pm_resume() to power on the sensor during
initialization. If t4ka3_pm_resume() failed (e.g. due to GPIO configuration
or hardware errors), t4ka3_probe() returned directly without calling
t4ka3_pm_suspend(), leaving powerdown/reset GPIOs in a partially
initialized powered-on state.
Fix this by invoking t4ka3_pm_suspend() if t4ka3_pm_resume() fails during
probe. In addition, replace mutex_init() with devm_mutex_init() for managed
resource lifecycle handling.
Fixes: fd5531969215 ("media: Add t4ka3 camera sensor driver")
Signed-off-by: Surendra Singh Chouhan <kr494167@gmail.com>
---
drivers/media/i2c/t4ka3.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/media/i2c/t4ka3.c b/drivers/media/i2c/t4ka3.c
index a5a68e3fbec2..0c38bb8dc718 100644
--- a/drivers/media/i2c/t4ka3.c
+++ b/drivers/media/i2c/t4ka3.c
@@ -968,7 +968,9 @@ static int t4ka3_probe(struct i2c_client *client)
if (ret)
return ret;
- mutex_init(&sensor->lock);
+ ret = devm_mutex_init(&client->dev, &sensor->lock);
+ if (ret)
+ return ret;
v4l2_i2c_subdev_init(&sensor->sd, client, &t4ka3_ops);
sensor->sd.internal_ops = &t4ka3_internal_ops;
@@ -991,8 +993,10 @@ static int t4ka3_probe(struct i2c_client *client)
return PTR_ERR(sensor->regmap);
ret = t4ka3_pm_resume(sensor->dev);
- if (ret)
+ if (ret) {
+ t4ka3_pm_suspend(sensor->dev);
return ret;
+ }
pm_runtime_set_active(&client->dev);
pm_runtime_enable(&client->dev);
--
2.55.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-07-24 8:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-24 8:39 [PATCH] media: i2c: t4ka3: power down sensor on resume failure and use devm_mutex_init kr494167
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®