Re: [PATCH] media: i2c: dw9714: Register a callback to disable the regulator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Zheyu,

Thanks for the patch.

On Sat, Apr 09, 2022 at 10:09:39PM +0800, Zheyu Ma wrote:
> 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@xxxxxxxxx>
> ---
>  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;

Could you instead disable the regulator in error handling in the probe
function?

-- 
Sakari Ailus



[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux