devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: jacopo mondi <jacopo-AW8dsiIh9cEdnm+yROfE0A@public.gmane.org>
To: Shunqian Zheng <zhengsq-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
Cc: mchehab-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	mark.rutland-5wv7dgnIgG8@public.gmane.org,
	linux-media-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	ddl-TNX95d0MmH7DzftRWevZcw@public.gmane.org,
	tfiga-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org
Subject: Re: [PATCH v5 2/4] media: ov5695: add support for OV5695 sensor
Date: Wed, 10 Jan 2018 10:08:36 +0100	[thread overview]
Message-ID: <20180110090836.GB6834@w540> (raw)
In-Reply-To: <1515549967-5302-3-git-send-email-zhengsq-TNX95d0MmH7DzftRWevZcw@public.gmane.org>

Hello Shunqian,

On Wed, Jan 10, 2018 at 10:06:05AM +0800, Shunqian Zheng wrote:

[snip]

> +static int __ov5695_start_stream(struct ov5695 *ov5695)
> +{
> +	int ret;
> +
> +	ret = ov5695_write_array(ov5695->client, ov5695_global_regs);
> +	if (ret)
> +		return ret;
> +	ret = ov5695_write_array(ov5695->client, ov5695->cur_mode->reg_list);
> +	if (ret)
> +		return ret;
> +
> +	/* In case these controls are set before streaming */
> +	ret = __v4l2_ctrl_handler_setup(&ov5695->ctrl_handler);
> +	if (ret)
> +		return ret;
> +
> +	return ov5695_write_reg(ov5695->client, OV5695_REG_CTRL_MODE,
> +				OV5695_REG_VALUE_08BIT, OV5695_MODE_STREAMING);
> +}
> +
> +static int __ov5695_stop_stream(struct ov5695 *ov5695)
> +{
> +	return ov5695_write_reg(ov5695->client, OV5695_REG_CTRL_MODE,
> +				OV5695_REG_VALUE_08BIT, OV5695_MODE_SW_STANDBY);
> +}
> +
> +static int ov5695_s_stream(struct v4l2_subdev *sd, int on)
> +{
> +	struct ov5695 *ov5695 = to_ov5695(sd);
> +	struct i2c_client *client = ov5695->client;
> +	int ret = 0;
> +
> +	mutex_lock(&ov5695->mutex);
> +	on = !!on;
> +	if (on == ov5695->streaming)
> +		goto unlock_and_return;
> +
> +	if (on) {
> +		ret = pm_runtime_get_sync(&client->dev);
> +		if (ret < 0) {
> +			pm_runtime_put_noidle(&client->dev);
> +			goto unlock_and_return;
> +		}
> +
> +		ret = __ov5695_start_stream(ov5695);
> +		if (ret) {
> +			v4l2_err(sd, "start stream failed while write regs\n");
> +			pm_runtime_put(&client->dev);
> +			goto unlock_and_return;
> +		}
> +	} else {
> +		__ov5695_stop_stream(ov5695);
> +		ret = pm_runtime_put(&client->dev);

I would return the result of __ov5695_stop_stream() instead of
pm_runtime_put().

I know I asked for this, but if the first s_stream(0) fails, the
sensor may not have been stopped but the interface will be put in
"streaming = 0" state, preventing a second s_stream(0) to be issued
because of your check "on == ov5695->streaming" a few lines above.

I can't tell how bad this is. Imho is acceptable but I would like to
hear someone else opinion here :)

> +	}
> +
> +	ov5695->streaming = on;
> +
> +unlock_and_return:
> +	mutex_unlock(&ov5695->mutex);
> +
> +	return ret;
> +}
> +
> +

[snip]

> +static const struct of_device_id ov5695_of_match[] = {
> +	{ .compatible = "ovti,ov5695" },
> +	{},
> +};

If you don't list CONFIG_OF as a dependecy for this driver (which you
should not imho), please guard this with:

#if IS_ENABLED(CONFIG_OF)

#endif

> +
> +static struct i2c_driver ov5695_i2c_driver = {
> +	.driver = {
> +		.name = "ov5695",
> +		.owner = THIS_MODULE,
> +		.pm = &ov5695_pm_ops,
> +		.of_match_table = ov5695_of_match
> +	},
> +	.probe		= &ov5695_probe,
> +	.remove		= &ov5695_remove,
> +};
> +
> +module_i2c_driver(ov5695_i2c_driver);
> +
> +MODULE_DESCRIPTION("OmniVision ov5695 sensor driver");
> +MODULE_LICENSE("GPL v2");

As you've fixed my comments on v1, and with the above bits addressed:

Reviewed-by: Jacopo Mondi <jacopo+renesas-AW8dsiIh9cEdnm+yROfE0A@public.gmane.org>

Thanks
   j

> --
> 1.9.1
>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2018-01-10  9:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-10  2:06 [PATCH v5 0/4] Add supports for OV2685 and OV5695 sensors Shunqian Zheng
2018-01-10  2:06 ` [PATCH v5 1/4] dt-bindings: media: Add bindings for OV5695 Shunqian Zheng
     [not found]   ` <1515549967-5302-2-git-send-email-zhengsq-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2018-01-10  9:20     ` jacopo mondi
2018-01-10  9:33       ` jacopo mondi
2018-01-11  6:44       ` Shunqian Zheng
     [not found]         ` <807c4307-0617-788e-7129-039b33ce99d5-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2018-01-18 22:30           ` Sakari Ailus
2018-01-10  2:06 ` [PATCH v5 2/4] media: ov5695: add support for OV5695 sensor Shunqian Zheng
     [not found]   ` <1515549967-5302-3-git-send-email-zhengsq-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2018-01-10  9:08     ` jacopo mondi [this message]
2018-01-11  6:21       ` Shunqian Zheng
2018-01-10  2:06 ` [PATCH v5 3/4] dt-bindings: media: Add bindings for OV2685 Shunqian Zheng
     [not found] ` <1515549967-5302-1-git-send-email-zhengsq-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2018-01-10  2:06   ` [PATCH v5 4/4] media: ov2685: add support for OV2685 sensor Shunqian Zheng

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=20180110090836.GB6834@w540 \
    --to=jacopo-aw8dsiih9cednm+yrofe0a@public.gmane.org \
    --cc=ddl-TNX95d0MmH7DzftRWevZcw@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-media-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=mchehab-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=tfiga-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=zhengsq-TNX95d0MmH7DzftRWevZcw@public.gmane.org \
    /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).