mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] media: i2c: dw9714: Register a callback to disable the regulator
@ 2022-04-09 14:09 Zheyu Ma
  2022-04-13 12:09 ` Sakari Ailus
  0 siblings, 1 reply; 3+ messages in thread
From: Zheyu Ma @ 2022-04-09 14:09 UTC (permalink / raw)
  To: sakari.ailus, mchehab; +Cc: linux-media, linux-kernel, Zheyu Ma

When the driver fails to probe, we will get the following splat:

[   59.305988] ------------[ cut here ]------------
[   59.306417] WARNING: CPU: 2 PID: 395 at drivers/regulator/core.c:2257 _regulator_put+0x3ec/0x4e0
[   59.310345] RIP: 0010:_regulator_put+0x3ec/0x4e0
[   59.318362] Call Trace:
[   59.318582]  <TASK>
[   59.318765]  regulator_put+0x1f/0x30
[   59.319058]  devres_release_group+0x319/0x3d0
[   59.319420]  i2c_device_probe+0x766/0x940

Fix this by adding a callback that will deal with the disabling when the
driver fails to probe.

Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
---
 drivers/media/i2c/dw9714.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/media/i2c/dw9714.c b/drivers/media/i2c/dw9714.c
index cd7008ad8f2f..eccd05fc50c7 100644
--- a/drivers/media/i2c/dw9714.c
+++ b/drivers/media/i2c/dw9714.c
@@ -137,6 +137,13 @@ static int dw9714_init_controls(struct dw9714_device *dev_vcm)
 	return hdl->error;
 }
 
+static void dw9714_disable_regulator(void *arg)
+{
+	struct dw9714_device *dw9714_dev = arg;
+
+	regulator_disable(dw9714_dev->vcc);
+}
+
 static int dw9714_probe(struct i2c_client *client)
 {
 	struct dw9714_device *dw9714_dev;
@@ -157,6 +164,10 @@ static int dw9714_probe(struct i2c_client *client)
 		return rval;
 	}
 
+	rval = devm_add_action_or_reset(&client->dev, dw9714_disable_regulator, dw9714_dev);
+	if (rval)
+		return rval;
+
 	v4l2_i2c_subdev_init(&dw9714_dev->sd, client, &dw9714_ops);
 	dw9714_dev->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE |
 				V4L2_SUBDEV_FL_HAS_EVENTS;
-- 
2.25.1


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

end of thread, other threads:[~2022-04-14  2:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-09 14:09 [PATCH] media: i2c: dw9714: Register a callback to disable the regulator Zheyu Ma
2022-04-13 12:09 ` Sakari Ailus
2022-04-14  2:35   ` Zheyu Ma

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®