From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: linux-media@vger.kernel.org,
Songjun Wu <songjun.wu@microchip.com>,
Hans Verkuil <hans.verkuil@cisco.com>
Subject: Re: [RFC PATCH 4/7] ov7670: get xvclk
Date: Wed, 17 Aug 2016 15:30:40 +0300 [thread overview]
Message-ID: <3609336.4L2FU6pBu3@avalon> (raw)
In-Reply-To: <1471415383-38531-5-git-send-email-hverkuil@xs4all.nl>
Hi Hans,
Thank you for the patch.
On Wednesday 17 Aug 2016 08:29:40 Hans Verkuil wrote:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> Get the clock for this sensor.
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
> drivers/media/i2c/ov7670.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c
> index fe527b2..57adf3d 100644
> --- a/drivers/media/i2c/ov7670.c
> +++ b/drivers/media/i2c/ov7670.c
> @@ -10,6 +10,7 @@
> * This file may be distributed under the terms of the GNU General
> * Public License, version 2.
> */
> +#include <linux/clk.h>
> #include <linux/init.h>
> #include <linux/module.h>
> #include <linux/slab.h>
> @@ -18,6 +19,7 @@
> #include <linux/videodev2.h>
> #include <media/v4l2-device.h>
> #include <media/v4l2-ctrls.h>
> +#include <media/v4l2-clk.h>
> #include <media/v4l2-mediabus.h>
> #include <media/v4l2-image-sizes.h>
> #include <media/i2c/ov7670.h>
> @@ -228,6 +230,7 @@ struct ov7670_info {
> struct v4l2_ctrl *hue;
> };
> struct ov7670_format_struct *fmt; /* Current format */
> + struct v4l2_clk *clk;
> int min_width; /* Filter out smaller sizes */
> int min_height; /* Filter out smaller sizes */
> int clock_speed; /* External clock speed (MHz) */
> @@ -1588,8 +1591,19 @@ static int ov7670_probe(struct i2c_client *client,
> info->pclk_hb_disable = true;
> }
>
> + info->clk = v4l2_clk_get(&client->dev, "xvclk");
> + if (IS_ERR(info->clk))
> + return -EPROBE_DEFER;
> + v4l2_clk_enable(info->clk);
Do you really need the V4L2 clock API here, or could you use the CCF API
directly ?
> + info->clock_speed = v4l2_clk_get_rate(info->clk) / 1000000;
> + if (info->clock_speed < 12 ||
> + info->clock_speed > 48)
> + return -EINVAL;
> +
You need error handling here too. I recommend adding error handling code at
the end of the function and using goto's.
> /* Make sure it's an ov7670 */
> ret = ov7670_detect(sd);
> +
No need for a blank line here.
> if (ret) {
> v4l_dbg(1, debug, client,
> "chip found @ 0x%x (%s) is not an ov7670 chip.\n",
> @@ -1682,6 +1696,7 @@ static int ov7670_remove(struct i2c_client *client)
> #if defined(CONFIG_MEDIA_CONTROLLER)
> media_entity_cleanup(&sd->entity);
> #endif
> + v4l2_clk_put(info->clk);
Don't you need to call v4l2_clk_disable() before ?
> return 0;
> }
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2016-08-17 12:31 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-17 6:29 [RFC PATCH 0/7] atmel-isi: convert to a standalone driver Hans Verkuil
2016-08-17 6:29 ` [RFC PATCH 1/7] ov7670: add media controller support Hans Verkuil
2016-08-17 12:25 ` Laurent Pinchart
2016-08-17 6:29 ` [RFC PATCH 2/7] ov7670: call v4l2_async_register_subdev Hans Verkuil
2016-08-17 12:27 ` Laurent Pinchart
2016-08-17 6:29 ` [RFC PATCH 3/7] ov7670: fix g/s_parm Hans Verkuil
2016-08-17 6:29 ` [RFC PATCH 4/7] ov7670: get xvclk Hans Verkuil
2016-08-17 12:30 ` Laurent Pinchart [this message]
2016-09-21 11:18 ` Sakari Ailus
2016-08-17 6:29 ` [RFC PATCH 5/7] ov7670: add devicetree support Hans Verkuil
2016-08-17 12:44 ` Laurent Pinchart
2016-08-26 7:45 ` Hans Verkuil
2016-09-21 13:30 ` Laurent Pinchart
2016-09-21 11:33 ` Sakari Ailus
2016-09-21 12:39 ` Laurent Pinchart
2016-09-21 11:09 ` Sakari Ailus
2016-08-17 6:29 ` [RFC PATCH 6/7] atmel-isi: remove dependency of the soc-camera framework Hans Verkuil
2016-08-18 5:53 ` Wu, Songjun
2016-09-21 7:04 ` Hans Verkuil
2016-09-23 6:05 ` Wu, Songjun
2016-10-18 9:21 ` Wu, Songjun
2016-10-18 10:58 ` Hans Verkuil
2016-10-19 7:36 ` Wu, Songjun
2016-10-19 7:46 ` Hans Verkuil
2016-10-19 7:48 ` Wu, Songjun
2016-11-14 8:19 ` Hans Verkuil
2016-11-14 8:22 ` Wu, Songjun
2016-08-17 6:29 ` [RFC PATCH 7/7] sama5d3 dts: enable atmel-isi Hans Verkuil
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=3609336.4L2FU6pBu3@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=hans.verkuil@cisco.com \
--cc=hverkuil@xs4all.nl \
--cc=linux-media@vger.kernel.org \
--cc=songjun.wu@microchip.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).