media: i2c: dw9714: Register a callback to disable the regulator
PATCH 1/1 media: i2c: dw9714: Register a callback to disable the regulator
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.
--- drivers/media/i2c/dw9714.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/media/i2c/dw9714.c +11 -0
@@ -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 ;
Signature · 1 line
2.25.1
Sakari Ailus
maintainerHi Zheyu,
Thanks for the patch.
Quoted 38 lines · 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/0x940Fix this by adding a callback that will deal with the disabling when the driver fails to probe.
Signed-off-by Zheyu Ma <[email protected]>--- drivers/media/i2c/dw9714.c | 11 +++++++++++ 1 file changed, 11 insertions(+)drivers/media/i2c/dw9714.c +7
-0@@ -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;
drivers/media/i2c/dw9714.c static int dw9714_probe(struct i2c_client *client) · line 173
Quoted 10 lines
drivers/media/i2c/dw9714.c +4
-0@@ -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 ;
Could you instead disable the regulator in error handling in the probe function?
Signature · 1 line
Sakari Ailus
Quoted 47 lines · Sakari Ailus
Hi Zheyu,
Thanks for the patch.
Quoted 41 lines · 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/0x940Fix this by adding a callback that will deal with the disabling when the driver fails to probe.
Signed-off-by Zheyu Ma <[email protected]>--- drivers/media/i2c/dw9714.c | 11 +++++++++++ 1 file changed, 11 insertions(+)drivers/media/i2c/dw9714.c +7
-0@@ -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; }
Quoted 10 lines
drivers/media/i2c/dw9714.c static int dw9714_probe(struct i2c_client *client) · line 173
Quoted 7 lines
drivers/media/i2c/dw9714.c +4
-0+ 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 ;Could you instead disable the regulator in error handling in the probe function?
OK, I will send a v2 patch.
Zheyu Ma