public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: i2c: imx415: Drop redundant runtime PM callbacks
@ 2026-03-24 12:45 Elgin Perumbilly
  2026-03-24 19:42 ` Michael Riesch
  0 siblings, 1 reply; 4+ messages in thread
From: Elgin Perumbilly @ 2026-03-24 12:45 UTC (permalink / raw)
  To: sakari.ailus
  Cc: tarang.raval, Elgin Perumbilly, Michael Riesch,
	Mauro Carvalho Chehab, linux-media, linux-kernel

Replace runtime_suspend/resume wrappers by using power helpers
directly with DEFINE_RUNTIME_DEV_PM_OPS().

Signed-off-by: Elgin Perumbilly <elgin.perumbilly@siliconsignals.io>
---
 drivers/media/i2c/imx415.c | 44 +++++++++++++++-----------------------
 1 file changed, 17 insertions(+), 27 deletions(-)

diff --git a/drivers/media/i2c/imx415.c b/drivers/media/i2c/imx415.c
index 0b424c17e880..b7d44f3e165b 100644
--- a/drivers/media/i2c/imx415.c
+++ b/drivers/media/i2c/imx415.c
@@ -1129,8 +1129,12 @@ static void imx415_subdev_cleanup(struct imx415 *sensor)
 	v4l2_ctrl_handler_free(&sensor->ctrls);
 }

-static int imx415_power_on(struct imx415 *sensor)
+static int imx415_power_on(struct device *dev)
 {
+	struct i2c_client *client = to_i2c_client(dev);
+	struct v4l2_subdev *subdev = i2c_get_clientdata(client);
+	struct imx415 *sensor = to_imx415(subdev);
+
 	int ret;

 	ret = regulator_bulk_enable(ARRAY_SIZE(sensor->supplies),
@@ -1161,11 +1165,17 @@ static int imx415_power_on(struct imx415 *sensor)
 	return ret;
 }

-static void imx415_power_off(struct imx415 *sensor)
+static int imx415_power_off(struct device *dev)
 {
+	struct i2c_client *client = to_i2c_client(dev);
+	struct v4l2_subdev *subdev = i2c_get_clientdata(client);
+	struct imx415 *sensor = to_imx415(subdev);
+
 	clk_disable_unprepare(sensor->clk);
 	gpiod_set_value_cansleep(sensor->reset, 1);
 	regulator_bulk_disable(ARRAY_SIZE(sensor->supplies), sensor->supplies);
+
+	return 0;
 }

 static int imx415_identify_model(struct imx415 *sensor)
@@ -1371,7 +1381,7 @@ static int imx415_probe(struct i2c_client *client)
 	 * work when runtime PM is disabled in the kernel. To that end, power
 	 * the sensor on manually here, identify it, and fully initialize it.
 	 */
-	ret = imx415_power_on(sensor);
+	ret = imx415_power_on(sensor->dev);
 	if (ret)
 		return ret;

@@ -1411,7 +1421,7 @@ static int imx415_probe(struct i2c_client *client)
 	pm_runtime_put_noidle(sensor->dev);
 	imx415_subdev_cleanup(sensor);
 err_power:
-	imx415_power_off(sensor);
+	imx415_power_off(sensor->dev);
 	return ret;
 }

@@ -1430,32 +1440,12 @@ static void imx415_remove(struct i2c_client *client)
 	 */
 	pm_runtime_disable(sensor->dev);
 	if (!pm_runtime_status_suspended(sensor->dev))
-		imx415_power_off(sensor);
+		imx415_power_off(sensor->dev);
 	pm_runtime_set_suspended(sensor->dev);
 }

-static int imx415_runtime_resume(struct device *dev)
-{
-	struct i2c_client *client = to_i2c_client(dev);
-	struct v4l2_subdev *subdev = i2c_get_clientdata(client);
-	struct imx415 *sensor = to_imx415(subdev);
-
-	return imx415_power_on(sensor);
-}
-
-static int imx415_runtime_suspend(struct device *dev)
-{
-	struct i2c_client *client = to_i2c_client(dev);
-	struct v4l2_subdev *subdev = i2c_get_clientdata(client);
-	struct imx415 *sensor = to_imx415(subdev);
-
-	imx415_power_off(sensor);
-
-	return 0;
-}
-
-static DEFINE_RUNTIME_DEV_PM_OPS(imx415_pm_ops, imx415_runtime_suspend,
-				 imx415_runtime_resume, NULL);
+static DEFINE_RUNTIME_DEV_PM_OPS(imx415_pm_ops, imx415_power_off,
+				 imx415_power_on, NULL);

 static const struct of_device_id imx415_of_match[] = {
 	{ .compatible = "sony,imx415" },
--
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-25 19:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-24 12:45 [PATCH] media: i2c: imx415: Drop redundant runtime PM callbacks Elgin Perumbilly
2026-03-24 19:42 ` Michael Riesch
2026-03-25 12:28   ` Sakari Ailus
2026-03-25 19:36     ` Michael Riesch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox