All of lore.kernel.org
 help / color / mirror / Atom feed
From: Janusz Krzysztofik <jmkrzyszt@gmail.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	Hans Verkuil <hans.verkuil@cisco.com>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	Janusz Krzysztofik <jmkrzyszt@gmail.com>
Subject: [PATCH v3 1/2] media: ov6650: Move v4l2_clk_get() to ov6650_video_probe() helper
Date: Sat, 30 Mar 2019 02:06:09 +0100	[thread overview]
Message-ID: <20190330010610.15094-2-jmkrzyszt@gmail.com> (raw)
In-Reply-To: <20190330010610.15094-1-jmkrzyszt@gmail.com>

In preparation for adding asynchronous subdevice support to the driver,
don't acquire v4l2_clk from the driver .probe() callback as that may
fail if the clock is provided by a bridge driver which may be not yet
initialized.  Move the v4l2_clk_get() to ov6650_video_probe() helper
which is going to be converted to v4l2_subdev_internal_ops.registered()
callback, executed only when the bridge driver is ready.

Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
---
 drivers/media/i2c/ov6650.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c
index f9359b11fa5c..de7d9790f054 100644
--- a/drivers/media/i2c/ov6650.c
+++ b/drivers/media/i2c/ov6650.c
@@ -810,9 +810,16 @@ static int ov6650_video_probe(struct i2c_client *client)
 	u8		pidh, pidl, midh, midl;
 	int		ret;
 
+	priv->clk = v4l2_clk_get(&client->dev, NULL);
+	if (IS_ERR(priv->clk)) {
+		ret = PTR_ERR(priv->clk);
+		dev_err(&client->dev, "v4l2_clk request err: %d\n", ret);
+		return ret;
+	}
+
 	ret = ov6650_s_power(&priv->subdev, 1);
 	if (ret < 0)
-		return ret;
+		goto eclkput;
 
 	msleep(20);
 
@@ -849,6 +856,11 @@ static int ov6650_video_probe(struct i2c_client *client)
 
 done:
 	ov6650_s_power(&priv->subdev, 0);
+	if (!ret)
+		return 0;
+eclkput:
+	v4l2_clk_put(priv->clk);
+
 	return ret;
 }
 
@@ -991,18 +1003,9 @@ static int ov6650_probe(struct i2c_client *client,
 	priv->code	  = MEDIA_BUS_FMT_YUYV8_2X8;
 	priv->colorspace  = V4L2_COLORSPACE_JPEG;
 
-	priv->clk = v4l2_clk_get(&client->dev, NULL);
-	if (IS_ERR(priv->clk)) {
-		ret = PTR_ERR(priv->clk);
-		goto eclkget;
-	}
-
 	ret = ov6650_video_probe(client);
-	if (ret) {
-		v4l2_clk_put(priv->clk);
-eclkget:
+	if (ret)
 		v4l2_ctrl_handler_free(&priv->hdl);
-	}
 
 	return ret;
 }
-- 
2.19.2


  reply	other threads:[~2019-03-30  1:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-25  0:34 [PATCH 0/2] media: ov6650: Add V4L2 asynchronous subdevice support Janusz Krzysztofik
2019-03-25  0:35 ` [PATCH 1/2] media: ov6650: Move v4l2_clk_get() to ov6650_video_probe() helper Janusz Krzysztofik
2019-03-29 18:39   ` Sakari Ailus
2019-03-29 19:48     ` Janusz Krzysztofik
2019-03-29 19:51       ` Sakari Ailus
2019-03-25  0:35 ` [PATCH 2/2] media: ov6650: Register with asynchronous subdevice framework Janusz Krzysztofik
2019-03-29 20:29 ` [PATCH v2 0/2] media: ov6650: Add V4L2 asynchronous subdevice support Janusz Krzysztofik
2019-03-29 20:29   ` [PATCH v2 1/2] media: ov6650: Move v4l2_clk_get() to ov6650_video_probe() helper Janusz Krzysztofik
2019-03-29 20:29   ` [PATCH v2 2/2] media: ov6650: Register with asynchronous subdevice framework Janusz Krzysztofik
2019-03-29 22:35     ` Sakari Ailus
2019-03-30  1:06   ` [PATCH v3 0/2] media: ov6650: Add V4L2 asynchronous subdevice support Janusz Krzysztofik
2019-03-30  1:06     ` Janusz Krzysztofik [this message]
2019-03-30  1:06     ` [PATCH v3 2/2] media: ov6650: Register with asynchronous subdevice framework Janusz Krzysztofik
2019-04-02  8:24       ` Sakari Ailus

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=20190330010610.15094-2-jmkrzyszt@gmail.com \
    --to=jmkrzyszt@gmail.com \
    --cc=hans.verkuil@cisco.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.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 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.