mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: kr494167@gmail.com
To: hpa@redhat.com, mchehab@kernel.org
Cc: johannes.goede@oss.qualcomm.com, sakari.ailus@linux.intel.com,
	hverkuil+cisco@kernel.org, linux-media@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Surendra Singh Chouhan <kr494167@gmail.com>
Subject: [PATCH] media: i2c: t4ka3: power down sensor on resume failure and use devm_mutex_init
Date: Fri, 24 Jul 2026 14:09:01 +0530	[thread overview]
Message-ID: <20260724083901.50942-1-kr494167@gmail.com> (raw)

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


                 reply	other threads:[~2026-07-24  8:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260724083901.50942-1-kr494167@gmail.com \
    --to=kr494167@gmail.com \
    --cc=hpa@redhat.com \
    --cc=hverkuil+cisco@kernel.org \
    --cc=johannes.goede@oss.qualcomm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.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

all inboxes | Powered by JetHome®