From: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Rob Herring <robh+dt@kernel.org>,
Maxime Ripard <mripard@kernel.org>,
Hans Verkuil <hverkuil@xs4all.nl>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: Re: [PATCH v4 2/2] media: i2c: Add support for the OV5648 image sensor
Date: Wed, 9 Dec 2020 15:05:28 +0100 [thread overview]
Message-ID: <X9DZqMdTfJLKNI5L@aptenodytes> (raw)
In-Reply-To: <20201208233436.GF25763@paasikivi.fi.intel.com>
[-- Attachment #1: Type: text/plain, Size: 2076 bytes --]
Hi Sakari,
On Wed 09 Dec 20, 01:34, Sakari Ailus wrote:
> Hi Paul,
>
> On Sat, Nov 28, 2020 at 03:33:50PM +0100, Paul Kocialkowski wrote:
> ...
> > + if (ret)
> > + goto error_ctrls;
> > +
> > + /* V4L2 subdev register */
> > +
> > + ret = v4l2_async_register_subdev_sensor_common(subdev);
>
> The driver's device node may be already available to the user here...
>
> > + if (ret)
> > + goto error_ctrls;
> > +
> > + /* Runtime PM */
> > +
> > + pm_runtime_enable(sensor->dev);
> > + pm_runtime_set_suspended(sensor->dev);
>
> but runtime PM is enabled here.
>
> This needs to be done in a different order. Otherwise chances are that the
> device node is accessed before the device is powered on.
Oh that makes sense yes. Good catch :)
> > +
> > + return 0;
> > +
> > +error_ctrls:
> > + v4l2_ctrl_handler_free(&sensor->ctrls.handler);
> > +
> > +error_mutex:
> > + mutex_destroy(&sensor->mutex);
> > +
> > +error_entity:
> > + media_entity_cleanup(&sensor->subdev.entity);
> > +
> > +error_endpoint:
> > + v4l2_fwnode_endpoint_free(&sensor->endpoint);
> > +
> > + return ret;
> > +}
> > +
> > +static int ov5648_remove(struct i2c_client *client)
> > +{
> > + struct v4l2_subdev *subdev = i2c_get_clientdata(client);
> > + struct ov5648_sensor *sensor = ov5648_subdev_sensor(subdev);
> > +
> > + clk_rate_exclusive_put(sensor->xvclk);
> > +
> > + v4l2_async_unregister_subdev(subdev);
> > + mutex_destroy(&sensor->mutex);
> > + media_entity_cleanup(&subdev->entity);
> > + v4l2_device_unregister_subdev(subdev);
> > + pm_runtime_disable(sensor->dev);
> > +
> > + ov5648_sensor_power(sensor, false);
>
> This needs to go, too, as there's no corresponding operation that powered
> on the device.
>
> Also don't forget to release the control handler.
>
> I believe these apply to both of the two drivers.
Fair enough and I think runtime PM will have called that already anyways.
Cheers,
Paul
--
Paul Kocialkowski, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
prev parent reply other threads:[~2020-12-09 14:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-28 14:33 [PATCH v4 0/2] media: i2c: OV5648 image sensor support Paul Kocialkowski
2020-11-28 14:33 ` [PATCH v4 1/2] dt-bindings: media: i2c: Add OV5648 bindings documentation Paul Kocialkowski
2020-11-28 14:33 ` [PATCH v4 2/2] media: i2c: Add support for the OV5648 image sensor Paul Kocialkowski
2020-11-30 9:28 ` Sakari Ailus
2020-11-30 13:48 ` Paul Kocialkowski
2020-11-30 13:53 ` Sakari Ailus
2020-12-02 13:50 ` Paul Kocialkowski
2020-12-08 23:34 ` Sakari Ailus
2020-12-09 14:05 ` Paul Kocialkowski [this message]
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=X9DZqMdTfJLKNI5L@aptenodytes \
--to=paul.kocialkowski@bootlin.com \
--cc=devicetree@vger.kernel.org \
--cc=hverkuil@xs4all.nl \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=mripard@kernel.org \
--cc=robh+dt@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=thomas.petazzoni@bootlin.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;
as well as URLs for NNTP newsgroup(s).