From patchwork Mon Mar 25 00:35:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10867801 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DBD921390 for ; Mon, 25 Mar 2019 00:35:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BAD45291B2 for ; Mon, 25 Mar 2019 00:35:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB33E291C1; Mon, 25 Mar 2019 00:35:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47E42291B2 for ; Mon, 25 Mar 2019 00:35:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729238AbfCYAfs (ORCPT ); Sun, 24 Mar 2019 20:35:48 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:39454 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729182AbfCYAfs (ORCPT ); Sun, 24 Mar 2019 20:35:48 -0400 Received: by mail-lj1-f193.google.com with SMTP id l7so6249900ljg.6; Sun, 24 Mar 2019 17:35:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VVcpEikfavp7o3/zPNhsZuUbJZE00gtSshpha6Y1Jok=; b=dCkSHuqDzjkslP1Ri+bLBDyc9aOTHjR3vxvE8iDQNPDiPQ1I5VrmdjKYRx8VcJQ3In 9VxJqNdOgHb9I1n9hQyWp1l7Yf/9/J2H36yrKV7IEYMd6P0NvyZ7lY7DikZLTsHuXZ7W BiGRHhh/nbYRArOWfH/HTf2VmJ4VZtuKvx6lIBaARgmzDOXdqY3l0j6N1FAk2drhmd2H 6725Rv8L+hM54kBq2/W9jovrPQXbdxl12Cx13vMOMETFDjFLuD6sN10y3xxChKEhGrtG dnu4zjHKl5JlWFzYLoTx2r8o1xJQ/nxKE6JUJC8+zU+CN6bo3YtZjhpYGWIoEP/AlhAZ Y5yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VVcpEikfavp7o3/zPNhsZuUbJZE00gtSshpha6Y1Jok=; b=IRfvkLyXdKUwd2TfYho7g0YGylJbVa0PN9UiovDS02pSys00iimHig5uhrsgpCpDK7 W1WJ5Y279xQIjNGvp0zk+wD166qkHHqCXtMqfNrflmUpWP5YRtudekOk7nZKIhDtNH00 Hss+GcRjtoYQqSD/aLmt9895lRrIo1LJyCc+sGRWxTDefu+nguZ3H6e1AypjHCF6Ochn yHEo0hogxHpOvoiztnBs2a6SeWimhNxOrAirsMB7ok7i03zW7Bgg+DT94SpEJ2iTqgXo yXaH2TCxzqnrXC55W3SRoxbMRwuCledYxm3iv8xM9DEy7Q0hC1m4RebFGTFMl1dYVX79 Gwvg== X-Gm-Message-State: APjAAAVrW4hryo4jNfg82/bLneWXu8pafNXttpYwKWR3k/WQgxpPcU7w jf4BArGcrojX1XT11pYxY40= X-Google-Smtp-Source: APXvYqxO+OBnABcmobxfooN5Pcn+H9nJd0nKS1OeECP4NobJ12vHW/bm6htW4FdOBBzKPReXS605cg== X-Received: by 2002:a2e:9b13:: with SMTP id u19mr8814990lji.134.1553474145742; Sun, 24 Mar 2019 17:35:45 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id y17sm1217993ljd.54.2019.03.24.17.35.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Mar 2019 17:35:45 -0700 (PDT) From: Janusz Krzysztofik To: Mauro Carvalho Chehab Cc: Hans Verkuil , Sakari Ailus , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH 1/2] media: ov6650: Move v4l2_clk_get() to ov6650_video_probe() helper Date: Mon, 25 Mar 2019 01:35:00 +0100 Message-Id: <20190325003501.14687-2-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190325003501.14687-1-jmkrzyszt@gmail.com> References: <20190325003501.14687-1-jmkrzyszt@gmail.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 c33fd584cb44..f10b8053ed73 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; /* * check and show product ID and manufacturer ID @@ -847,6 +854,11 @@ static int ov6650_video_probe(struct i2c_client *client) done: ov6650_s_power(&priv->subdev, 0); + if (ret) { +eclkput: + v4l2_clk_put(priv->clk); + } + return ret; } @@ -989,18 +1001,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; } From patchwork Mon Mar 25 00:35:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10867803 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F292318A6 for ; Mon, 25 Mar 2019 00:35:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF14D291B2 for ; Mon, 25 Mar 2019 00:35:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D38FA291C1; Mon, 25 Mar 2019 00:35:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 78C0D291B7 for ; Mon, 25 Mar 2019 00:35:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729262AbfCYAfv (ORCPT ); Sun, 24 Mar 2019 20:35:51 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:34041 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729146AbfCYAft (ORCPT ); Sun, 24 Mar 2019 20:35:49 -0400 Received: by mail-lj1-f195.google.com with SMTP id j89so6273512ljb.1; Sun, 24 Mar 2019 17:35:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YUIheokwKP1iea+PUIcrfKDpgFD2izisvAZon9oQcUk=; b=VQ48qullWSVtP7SkdrAx0pjwc63YKBGaxmG0YJGhd1J6ZhPWi2fOWgKoSGOGbvDng8 BzYfnTrFthKy29foIWRTZO/ESztt6qkPlPJxqwq31sBLIoTQ8Msk9EyYCF2RR/jqNZVk BmJF6iwdU1g1v+8vsIb6oHGLR/SDbdRuNs9aIBIPJHlptHpQTUqyg72cxZvUunfJsKIk GJwmRwshJS5RSNnGfGvQtmP3yvHYYRt+I3CfTlKy3Uey+skGG16vLsTBb1ufOxid+db4 XA86VlVw7zpESnXVxpOHNuSmlviBmIfQaMTekveM7ArYxh6pIAXgoiYrAM/mVnbVCAoJ +Gqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YUIheokwKP1iea+PUIcrfKDpgFD2izisvAZon9oQcUk=; b=fxU75qzWbN/YgFW25cbUplACV2GcSNBjHPuJ53QXBHrpAW0UY9xEFcEHH/eHr/d8qW EQqTC9S49xdTy3IWIqrCYrW2Id5W18XgY2/rjjdplQLch588QnK4maMt64Fl+DDGsUm5 P98tAL5abdAiKLKpG0GcDH72no3bWbmHUDWhb5Nl03OyyvnrAOyh5gpt2pwj+cGLdPra /bROCXwM2aLiktAxzgSztEg7XXQFNQWox/9+cmhvfwwxmqocjUIw6VZwSehb+phDDNu/ z+vACakaCT23jdHP2P+QMmRxbzOPjn7dw6/i4fWY+VzO9G852bJMngkuhkNHg0c8M3/N GOHg== X-Gm-Message-State: APjAAAWd3qqv65fPTkW1iJleqgNbN7wNOkhdb7aKtuZYbKJO8ekeWauB Qby0ogd4CQud79f79en+nL0= X-Google-Smtp-Source: APXvYqxfK6aYTyQ5eCBY6yvXZlnOljx3XRyPj+HwkTQKsnxrckwqoxSs/0Zqql6y8LQ3pu7kVmDZ8g== X-Received: by 2002:a2e:4209:: with SMTP id p9mr4969871lja.175.1553474146994; Sun, 24 Mar 2019 17:35:46 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id y17sm1217993ljd.54.2019.03.24.17.35.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Mar 2019 17:35:46 -0700 (PDT) From: Janusz Krzysztofik To: Mauro Carvalho Chehab Cc: Hans Verkuil , Sakari Ailus , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH 2/2] media: ov6650: Register with asynchronous subdevice framework Date: Mon, 25 Mar 2019 01:35:01 +0100 Message-Id: <20190325003501.14687-3-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190325003501.14687-1-jmkrzyszt@gmail.com> References: <20190325003501.14687-1-jmkrzyszt@gmail.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Register V4L2 subdevice implemented by the driver to the V4L2 asynchronous subdevice framework. Signed-off-by: Janusz Krzysztofik --- drivers/media/i2c/ov6650.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c index f10b8053ed73..cc9e5388d5ec 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -804,8 +804,9 @@ static int ov6650_prog_dflt(struct i2c_client *client) return ret; } -static int ov6650_video_probe(struct i2c_client *client) +static int ov6650_video_probe(struct v4l2_subdev *sd) { + struct i2c_client *client = v4l2_get_subdevdata(sd); struct ov6650 *priv = to_ov6650(client); u8 pidh, pidl, midh, midl; int ret; @@ -817,7 +818,7 @@ static int ov6650_video_probe(struct i2c_client *client) return ret; } - ret = ov6650_s_power(&priv->subdev, 1); + ret = ov6650_s_power(sd, 1); if (ret < 0) goto eclkput; @@ -853,7 +854,7 @@ static int ov6650_video_probe(struct i2c_client *client) ret = v4l2_ctrl_handler_setup(&priv->hdl); done: - ov6650_s_power(&priv->subdev, 0); + ov6650_s_power(sd, 0); if (ret) { eclkput: v4l2_clk_put(priv->clk); @@ -941,6 +942,10 @@ static const struct v4l2_subdev_ops ov6650_subdev_ops = { .pad = &ov6650_pad_ops, }; +static const struct v4l2_subdev_internal_ops ov6650_internal_ops = { + .registered = ov6650_video_probe, +}; + /* * i2c_driver function */ @@ -1001,7 +1006,12 @@ static int ov6650_probe(struct i2c_client *client, priv->code = MEDIA_BUS_FMT_YUYV8_2X8; priv->colorspace = V4L2_COLORSPACE_JPEG; - ret = ov6650_video_probe(client); + priv->subdev.internal_ops = &ov6650_internal_ops; + priv->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; + snprintf(priv->subdev.name, sizeof(priv->subdev.name), "%s %d-%04x", + did->name, i2c_adapter_id(client->adapter), client->addr); + + ret = v4l2_async_register_subdev(&priv->subdev); if (ret) v4l2_ctrl_handler_free(&priv->hdl); @@ -1013,7 +1023,7 @@ static int ov6650_remove(struct i2c_client *client) struct ov6650 *priv = to_ov6650(client); v4l2_clk_put(priv->clk); - v4l2_device_unregister_subdev(&priv->subdev); + v4l2_async_unregister_subdev(&priv->subdev); v4l2_ctrl_handler_free(&priv->hdl); return 0; }