From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Zheyu Ma <zheyuma97@gmail.com>
Cc: mchehab@kernel.org, linux-media@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] media: i2c: dw9714: Register a callback to disable the regulator
Date: Wed, 13 Apr 2022 15:09:35 +0300 [thread overview]
Message-ID: <Yla9f03/j9sEB2Rc@paasikivi.fi.intel.com> (raw)
In-Reply-To: <20220409140939.2176161-1-zheyuma97@gmail.com>
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@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;
Could you instead disable the regulator in error handling in the probe
function?
--
Sakari Ailus
next prev parent reply other threads:[~2022-04-13 12:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-09 14:09 Zheyu Ma
2022-04-13 12:09 ` Sakari Ailus [this message]
2022-04-14 2:35 ` Zheyu Ma
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=Yla9f03/j9sEB2Rc@paasikivi.fi.intel.com \
--to=sakari.ailus@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=zheyuma97@gmail.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®