From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Jacopo Mondi <jacopo+renesas@jmondi.org>
Cc: magnus.damm@gmail.com, geert@glider.be, mchehab@kernel.org,
hverkuil@xs4all.nl, linux-renesas-soc@vger.kernel.org,
linux-media@vger.kernel.org, linux-sh@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 08/10] media: i2c: ov772x: Remove soc_camera dependencies
Date: Mon, 11 Dec 2017 16:47:55 +0200 [thread overview]
Message-ID: <2078986.UahPtJ6YpD@avalon> (raw)
In-Reply-To: <1510743363-25798-9-git-send-email-jacopo+renesas@jmondi.org>
Hi Jacopo,
Thank you for the patch.
On Wednesday, 15 November 2017 12:56:01 EET Jacopo Mondi wrote:
> Remove soc_camera framework dependencies from ov772x sensor driver.
> - Handle clock directly
> - Register async subdevice
> - Add platform specific enable/disable functions
> - Adjust build system
>
> This commit does not remove the original soc_camera based driver.
>
> Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> ---
> drivers/media/i2c/Kconfig | 12 +++++++
> drivers/media/i2c/Makefile | 1 +
> drivers/media/i2c/ov772x.c | 88 ++++++++++++++++++++++++++++---------------
> include/media/i2c/ov772x.h | 3 ++
> 4 files changed, 76 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
> index 9415389..ff251ce 100644
> --- a/drivers/media/i2c/Kconfig
> +++ b/drivers/media/i2c/Kconfig
> @@ -629,6 +629,18 @@ config VIDEO_OV5670
> To compile this driver as a module, choose M here: the
> module will be called ov5670.
>
> +config VIDEO_OV772X
> + tristate "OmniVision OV772x sensor support"
> + depends on I2C && VIDEO_V4L2
> + depends on MEDIA_CAMERA_SUPPORT
> + ---help---
> + This is a Video4Linux2 sensor-level driver for the OmniVision
> + OV772x camera.
> +
> + To compile this driver as a module, choose M here: the
> + module will be called ov772x.
> +
> +
A single blank line is enough.
> config VIDEO_OV7640
> tristate "OmniVision OV7640 sensor support"
> depends on I2C && VIDEO_V4L2
> diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
> index f104650..b2459a1 100644
> --- a/drivers/media/i2c/Makefile
> +++ b/drivers/media/i2c/Makefile
> @@ -66,6 +66,7 @@ obj-$(CONFIG_VIDEO_OV5645) += ov5645.o
> obj-$(CONFIG_VIDEO_OV5647) += ov5647.o
> obj-$(CONFIG_VIDEO_OV5670) += ov5670.o
> obj-$(CONFIG_VIDEO_OV6650) += ov6650.o
> +obj-$(CONFIG_VIDEO_OV772X) += ov772x.o
> obj-$(CONFIG_VIDEO_OV7640) += ov7640.o
> obj-$(CONFIG_VIDEO_OV7670) += ov7670.o
> obj-$(CONFIG_VIDEO_OV9650) += ov9650.o
> diff --git a/drivers/media/i2c/ov772x.c b/drivers/media/i2c/ov772x.c
> index 8063835..9be7e4e 100644
> --- a/drivers/media/i2c/ov772x.c
> +++ b/drivers/media/i2c/ov772x.c
[snip]
> @@ -650,13 +651,36 @@ static int ov772x_s_register(struct v4l2_subdev *sd,
> }
> #endif
>
> +static int ov772x_power_on(struct ov772x_priv *priv)
> +{
> + int ret;
> +
> + if (priv->info->platform_enable) {
> + ret = priv->info->platform_enable();
> + if (ret)
> + return ret;
> + }
> +
> + /* drivers/sh/clk/core.c returns -EINVAL if clk is NULL */
> + return clk_enable(priv->clk) <= 0 ? 0 : 1;
Then please don't call clk_enable() if priv->clk is NULL, and propagate errors
from clk_enable() back to the caller.
And shouldn't you call clk_prepare_enable() (and clk_disable_unprepare()
below) ?
> +}
> +
> +static int ov772x_power_off(struct ov772x_priv *priv)
> +{
> + if (priv->info->platform_enable)
> + priv->info->platform_disable();
> +
> + clk_disable(priv->clk);
> +
> + return 0;
> +}
[snip]
> @@ -1073,21 +1092,33 @@ static int ov772x_probe(struct i2c_client *client,
> if (priv->hdl.error)
> return priv->hdl.error;
>
> - priv->clk = v4l2_clk_get(&client->dev, "mclk");
> - if (IS_ERR(priv->clk)) {
> + priv->clk = clk_get(&client->dev, "mclk");
> + if (PTR_ERR(priv->clk) == -ENOENT) {
> + priv->clk = NULL;
> + } else if (IS_ERR(priv->clk)) {
> + dev_err(&client->dev, "Unable to get mclk clock\n");
> ret = PTR_ERR(priv->clk);
> - goto eclkget;
You need a priv->clk = NULL here otherwise the error path will oops.
> + goto error_clk_enable;
> }
>
> ret = ov772x_video_probe(priv);
> - if (ret < 0) {
> - v4l2_clk_put(priv->clk);
> -eclkget:
> - v4l2_ctrl_handler_free(&priv->hdl);
> - } else {
> - priv->cfmt = &ov772x_cfmts[0];
> - priv->win = &ov772x_win_sizes[0];
> - }
> + if (ret < 0)
> + goto error_video_probe;
> +
> + priv->cfmt = &ov772x_cfmts[0];
> + priv->win = &ov772x_win_sizes[0];
> +
> + ret = v4l2_async_register_subdev(&priv->subdev);
> + if (ret)
> + goto error_video_probe;
> +
> + return 0;
> +
> +error_video_probe:
> + if (priv->clk)
> + clk_put(priv->clk);
clk_put() accepts a NULL clock, you don't have to check the pointer first.
> +error_clk_enable:
> + v4l2_ctrl_handler_free(&priv->hdl);
>
> return ret;
> }
> @@ -1096,7 +1127,8 @@ static int ov772x_remove(struct i2c_client *client)
> {
> struct ov772x_priv *priv = to_ov772x(i2c_get_clientdata(client));
>
> - v4l2_clk_put(priv->clk);
> + if (priv->clk)
> + clk_put(priv->clk);
Same here.
> v4l2_device_unregister_subdev(&priv->subdev);
> v4l2_ctrl_handler_free(&priv->hdl);
> return 0;
> diff --git a/include/media/i2c/ov772x.h b/include/media/i2c/ov772x.h
> index 00dbb7c..5896dff 100644
> --- a/include/media/i2c/ov772x.h
> +++ b/include/media/i2c/ov772x.h
> @@ -54,6 +54,9 @@ struct ov772x_edge_ctrl {
> struct ov772x_camera_info {
> unsigned long flags;
> struct ov772x_edge_ctrl edgectrl;
> +
> + int (*platform_enable)(void);
> + void (*platform_disable)(void);
> };
>
> #endif /* __OV772X_H__ */
--
Regards,
Laurent Pinchart
WARNING: multiple messages have this Message-ID (diff)
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Jacopo Mondi <jacopo+renesas@jmondi.org>
Cc: magnus.damm@gmail.com, geert@glider.be, mchehab@kernel.org,
hverkuil@xs4all.nl, linux-renesas-soc@vger.kernel.org,
linux-media@vger.kernel.org, linux-sh@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 08/10] media: i2c: ov772x: Remove soc_camera dependencies
Date: Mon, 11 Dec 2017 14:47:55 +0000 [thread overview]
Message-ID: <2078986.UahPtJ6YpD@avalon> (raw)
In-Reply-To: <1510743363-25798-9-git-send-email-jacopo+renesas@jmondi.org>
Hi Jacopo,
Thank you for the patch.
On Wednesday, 15 November 2017 12:56:01 EET Jacopo Mondi wrote:
> Remove soc_camera framework dependencies from ov772x sensor driver.
> - Handle clock directly
> - Register async subdevice
> - Add platform specific enable/disable functions
> - Adjust build system
>
> This commit does not remove the original soc_camera based driver.
>
> Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> ---
> drivers/media/i2c/Kconfig | 12 +++++++
> drivers/media/i2c/Makefile | 1 +
> drivers/media/i2c/ov772x.c | 88 ++++++++++++++++++++++++++++---------------
> include/media/i2c/ov772x.h | 3 ++
> 4 files changed, 76 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
> index 9415389..ff251ce 100644
> --- a/drivers/media/i2c/Kconfig
> +++ b/drivers/media/i2c/Kconfig
> @@ -629,6 +629,18 @@ config VIDEO_OV5670
> To compile this driver as a module, choose M here: the
> module will be called ov5670.
>
> +config VIDEO_OV772X
> + tristate "OmniVision OV772x sensor support"
> + depends on I2C && VIDEO_V4L2
> + depends on MEDIA_CAMERA_SUPPORT
> + ---help---
> + This is a Video4Linux2 sensor-level driver for the OmniVision
> + OV772x camera.
> +
> + To compile this driver as a module, choose M here: the
> + module will be called ov772x.
> +
> +
A single blank line is enough.
> config VIDEO_OV7640
> tristate "OmniVision OV7640 sensor support"
> depends on I2C && VIDEO_V4L2
> diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
> index f104650..b2459a1 100644
> --- a/drivers/media/i2c/Makefile
> +++ b/drivers/media/i2c/Makefile
> @@ -66,6 +66,7 @@ obj-$(CONFIG_VIDEO_OV5645) += ov5645.o
> obj-$(CONFIG_VIDEO_OV5647) += ov5647.o
> obj-$(CONFIG_VIDEO_OV5670) += ov5670.o
> obj-$(CONFIG_VIDEO_OV6650) += ov6650.o
> +obj-$(CONFIG_VIDEO_OV772X) += ov772x.o
> obj-$(CONFIG_VIDEO_OV7640) += ov7640.o
> obj-$(CONFIG_VIDEO_OV7670) += ov7670.o
> obj-$(CONFIG_VIDEO_OV9650) += ov9650.o
> diff --git a/drivers/media/i2c/ov772x.c b/drivers/media/i2c/ov772x.c
> index 8063835..9be7e4e 100644
> --- a/drivers/media/i2c/ov772x.c
> +++ b/drivers/media/i2c/ov772x.c
[snip]
> @@ -650,13 +651,36 @@ static int ov772x_s_register(struct v4l2_subdev *sd,
> }
> #endif
>
> +static int ov772x_power_on(struct ov772x_priv *priv)
> +{
> + int ret;
> +
> + if (priv->info->platform_enable) {
> + ret = priv->info->platform_enable();
> + if (ret)
> + return ret;
> + }
> +
> + /* drivers/sh/clk/core.c returns -EINVAL if clk is NULL */
> + return clk_enable(priv->clk) <= 0 ? 0 : 1;
Then please don't call clk_enable() if priv->clk is NULL, and propagate errors
from clk_enable() back to the caller.
And shouldn't you call clk_prepare_enable() (and clk_disable_unprepare()
below) ?
> +}
> +
> +static int ov772x_power_off(struct ov772x_priv *priv)
> +{
> + if (priv->info->platform_enable)
> + priv->info->platform_disable();
> +
> + clk_disable(priv->clk);
> +
> + return 0;
> +}
[snip]
> @@ -1073,21 +1092,33 @@ static int ov772x_probe(struct i2c_client *client,
> if (priv->hdl.error)
> return priv->hdl.error;
>
> - priv->clk = v4l2_clk_get(&client->dev, "mclk");
> - if (IS_ERR(priv->clk)) {
> + priv->clk = clk_get(&client->dev, "mclk");
> + if (PTR_ERR(priv->clk) = -ENOENT) {
> + priv->clk = NULL;
> + } else if (IS_ERR(priv->clk)) {
> + dev_err(&client->dev, "Unable to get mclk clock\n");
> ret = PTR_ERR(priv->clk);
> - goto eclkget;
You need a priv->clk = NULL here otherwise the error path will oops.
> + goto error_clk_enable;
> }
>
> ret = ov772x_video_probe(priv);
> - if (ret < 0) {
> - v4l2_clk_put(priv->clk);
> -eclkget:
> - v4l2_ctrl_handler_free(&priv->hdl);
> - } else {
> - priv->cfmt = &ov772x_cfmts[0];
> - priv->win = &ov772x_win_sizes[0];
> - }
> + if (ret < 0)
> + goto error_video_probe;
> +
> + priv->cfmt = &ov772x_cfmts[0];
> + priv->win = &ov772x_win_sizes[0];
> +
> + ret = v4l2_async_register_subdev(&priv->subdev);
> + if (ret)
> + goto error_video_probe;
> +
> + return 0;
> +
> +error_video_probe:
> + if (priv->clk)
> + clk_put(priv->clk);
clk_put() accepts a NULL clock, you don't have to check the pointer first.
> +error_clk_enable:
> + v4l2_ctrl_handler_free(&priv->hdl);
>
> return ret;
> }
> @@ -1096,7 +1127,8 @@ static int ov772x_remove(struct i2c_client *client)
> {
> struct ov772x_priv *priv = to_ov772x(i2c_get_clientdata(client));
>
> - v4l2_clk_put(priv->clk);
> + if (priv->clk)
> + clk_put(priv->clk);
Same here.
> v4l2_device_unregister_subdev(&priv->subdev);
> v4l2_ctrl_handler_free(&priv->hdl);
> return 0;
> diff --git a/include/media/i2c/ov772x.h b/include/media/i2c/ov772x.h
> index 00dbb7c..5896dff 100644
> --- a/include/media/i2c/ov772x.h
> +++ b/include/media/i2c/ov772x.h
> @@ -54,6 +54,9 @@ struct ov772x_edge_ctrl {
> struct ov772x_camera_info {
> unsigned long flags;
> struct ov772x_edge_ctrl edgectrl;
> +
> + int (*platform_enable)(void);
> + void (*platform_disable)(void);
> };
>
> #endif /* __OV772X_H__ */
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2017-12-11 14:47 UTC|newest]
Thread overview: 118+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-15 10:55 [PATCH v1 00/10] Renesas Capture Engine Unit (CEU) V4L2 driver Jacopo Mondi
2017-11-15 10:55 ` Jacopo Mondi
2017-11-15 10:55 ` [PATCH v1 01/10] dt-bindings: media: Add Renesas CEU bindings Jacopo Mondi
2017-11-15 10:55 ` Jacopo Mondi
2017-11-15 11:32 ` Kieran Bingham
2017-11-15 12:33 ` Sakari Ailus
2017-11-15 12:33 ` Sakari Ailus
2017-12-11 14:24 ` Laurent Pinchart
2017-12-11 14:24 ` Laurent Pinchart
2017-11-15 13:07 ` Geert Uytterhoeven
2017-11-15 13:07 ` Geert Uytterhoeven
2017-11-15 13:07 ` Geert Uytterhoeven
2017-11-15 18:15 ` jacopo mondi
2017-11-15 18:15 ` jacopo mondi
2017-11-15 18:39 ` Geert Uytterhoeven
2017-11-15 18:39 ` Geert Uytterhoeven
2017-11-15 10:55 ` [PATCH v1 02/10] include: media: Add Renesas CEU driver interface Jacopo Mondi
2017-11-15 10:55 ` Jacopo Mondi
2017-11-15 12:36 ` Sakari Ailus
2017-11-15 12:36 ` Sakari Ailus
2017-12-11 14:26 ` Laurent Pinchart
2017-12-11 14:26 ` Laurent Pinchart
2017-12-11 14:32 ` Laurent Pinchart
2017-12-11 14:32 ` Laurent Pinchart
2017-11-15 10:55 ` [PATCH v1 03/10] v4l: platform: Add Renesas CEU driver Jacopo Mondi
2017-11-15 10:55 ` Jacopo Mondi
2017-11-15 12:45 ` Sakari Ailus
2017-11-15 12:45 ` Sakari Ailus
2017-11-15 14:25 ` jacopo mondi
2017-11-15 14:25 ` jacopo mondi
2017-11-17 0:36 ` Sakari Ailus
2017-11-17 0:36 ` Sakari Ailus
2017-11-17 9:33 ` jacopo mondi
2017-11-17 9:33 ` jacopo mondi
2017-11-25 15:56 ` Sakari Ailus
2017-11-25 15:56 ` Sakari Ailus
2017-11-25 18:17 ` jacopo mondi
2017-11-25 18:17 ` jacopo mondi
2017-12-11 15:04 ` Laurent Pinchart
2017-12-11 15:04 ` Laurent Pinchart
2017-12-11 16:15 ` Laurent Pinchart
2017-12-11 16:15 ` Laurent Pinchart
2017-12-18 12:25 ` jacopo mondi
2017-12-18 12:25 ` jacopo mondi
2017-12-18 15:28 ` Laurent Pinchart
2017-12-18 15:28 ` Laurent Pinchart
2017-12-21 16:27 ` jacopo mondi
2017-12-21 16:27 ` jacopo mondi
2017-12-22 12:03 ` Laurent Pinchart
2017-12-22 12:03 ` Laurent Pinchart
2017-12-22 14:40 ` jacopo mondi
2017-12-22 14:40 ` jacopo mondi
2017-12-23 11:39 ` Laurent Pinchart
2017-12-23 11:39 ` Laurent Pinchart
2017-12-19 11:57 ` jacopo mondi
2017-12-19 11:57 ` jacopo mondi
2017-12-19 13:07 ` Laurent Pinchart
2017-12-19 13:07 ` Laurent Pinchart
2017-12-19 13:28 ` Sakari Ailus
2017-12-19 13:28 ` Sakari Ailus
2017-12-19 13:52 ` Laurent Pinchart
2017-12-19 13:52 ` Laurent Pinchart
2017-12-13 12:03 ` Hans Verkuil
2017-12-13 12:03 ` Hans Verkuil
2017-12-18 14:12 ` jacopo mondi
2017-12-18 14:12 ` jacopo mondi
2017-11-15 10:55 ` [PATCH v1 04/10] ARM: dts: r7s72100: Add Capture Engine Unit (CEU) Jacopo Mondi
2017-11-15 10:55 ` Jacopo Mondi
2017-11-17 14:22 ` Simon Horman
2017-11-17 14:22 ` Simon Horman
2017-11-23 9:41 ` Geert Uytterhoeven
2017-11-23 9:41 ` Geert Uytterhoeven
2017-11-15 10:55 ` [PATCH v1 05/10] arch: sh: migor: Use new renesas-ceu camera driver Jacopo Mondi
2017-11-15 10:55 ` Jacopo Mondi
2017-12-11 14:36 ` Laurent Pinchart
2017-12-11 14:36 ` Laurent Pinchart
2017-12-12 10:00 ` Laurent Pinchart
2017-12-12 10:00 ` Laurent Pinchart
2017-12-21 20:31 ` jacopo mondi
2017-12-21 20:31 ` jacopo mondi
2017-12-22 8:04 ` Geert Uytterhoeven
2017-12-22 8:04 ` Geert Uytterhoeven
2017-12-22 11:56 ` Laurent Pinchart
2017-12-22 11:56 ` Laurent Pinchart
2017-11-15 10:55 ` [PATCH v1 06/10] sh: sh7722: Rename CEU clock Jacopo Mondi
2017-11-15 10:55 ` Jacopo Mondi
2017-11-15 13:13 ` Geert Uytterhoeven
2017-11-15 13:13 ` Geert Uytterhoeven
2017-11-17 9:15 ` jacopo mondi
2017-11-17 9:15 ` jacopo mondi
2017-11-15 10:56 ` [PATCH v1 07/10] v4l: i2c: Copy ov772x soc_camera sensor driver Jacopo Mondi
2017-11-15 10:56 ` Jacopo Mondi
2017-12-11 14:49 ` Laurent Pinchart
2017-12-11 14:49 ` Laurent Pinchart
2017-12-13 12:10 ` Hans Verkuil
2017-12-13 12:10 ` Hans Verkuil
2017-12-13 13:02 ` Philippe Ombredanne
2017-12-13 13:02 ` Philippe Ombredanne
2017-11-15 10:56 ` [PATCH v1 08/10] media: i2c: ov772x: Remove soc_camera dependencies Jacopo Mondi
2017-11-15 10:56 ` Jacopo Mondi
2017-11-17 0:43 ` Sakari Ailus
2017-11-17 0:43 ` Sakari Ailus
2017-11-17 9:14 ` jacopo mondi
2017-11-17 9:14 ` jacopo mondi
2017-11-25 16:04 ` Sakari Ailus
2017-11-25 16:04 ` Sakari Ailus
2017-12-11 14:47 ` Laurent Pinchart [this message]
2017-12-11 14:47 ` Laurent Pinchart
2017-11-15 10:56 ` [PATCH v1 09/10] v4l: i2c: Copy tw9910 soc_camera sensor driver Jacopo Mondi
2017-11-15 10:56 ` Jacopo Mondi
2017-12-11 14:50 ` Laurent Pinchart
2017-12-11 14:50 ` Laurent Pinchart
2017-11-15 10:56 ` [PATCH v1 10/10] media: i2c: tw9910: Remove soc_camera dependencies Jacopo Mondi
2017-11-15 10:56 ` Jacopo Mondi
2017-12-11 14:55 ` Laurent Pinchart
2017-12-11 14:55 ` Laurent Pinchart
2017-12-13 12:13 ` Hans Verkuil
2017-12-13 12:13 ` 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=2078986.UahPtJ6YpD@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=geert@glider.be \
--cc=hverkuil@xs4all.nl \
--cc=jacopo+renesas@jmondi.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=magnus.damm@gmail.com \
--cc=mchehab@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.