From patchwork Fri Mar 29 20:29:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10877693 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 89A661669 for ; Fri, 29 Mar 2019 20:29:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E1C6291B6 for ; Fri, 29 Mar 2019 20:29:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 61FD82922C; Fri, 29 Mar 2019 20:29:54 +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 543C8291B6 for ; Fri, 29 Mar 2019 20:29:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730143AbfC2U3s (ORCPT ); Fri, 29 Mar 2019 16:29:48 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:42400 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730094AbfC2U3q (ORCPT ); Fri, 29 Mar 2019 16:29:46 -0400 Received: by mail-lf1-f65.google.com with SMTP id b7so2304601lfg.9; Fri, 29 Mar 2019 13:29:45 -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=Io1qbMYC3j8dQAZIVD5s7ZIU2u1hZ0/nBzYbRzUgKlU=; b=YT3Rj3W2nqbg0coT56bl+YAose+IeD68CItY82GektYwWyCis2xl6iHgKzY+cINCOc dy9tC02um2MILByBw33MEi/EnGr3dD2NqY8WjWdIEhjIz9A5RTMLzaZoA0m/dpgcaYLx 7hYbJ9h4ynhOGQwCynsIezYPq/5oeWZYGMZbHErc9gHLLWuZ2D83Wy2BCe7w8X/Hk4kq 1PWwayZR1q75yEpoxDNJ2+stw/GD3BV4Df3QIUT+U4OosdNLLLnbUpFFr+NsMiNJgQhO Zy5eglkupPB4O0HzKRQD5SVfevyOTbV/FoqTyclitH7nqA/ygVhWJcKrcwYX+xzD3fSk mxzw== 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=Io1qbMYC3j8dQAZIVD5s7ZIU2u1hZ0/nBzYbRzUgKlU=; b=CYkqxwLliLWleQ/XApTlErP9wwWWeCQG7AhcQMQi9w/3w6cIzORCpKuQSsyuxyvUfB vRpo0R6zKF1Mm3ybtZFFd6w9eV1k/J5h0BT2CNGAvNbKSKXqRZRyNc8DnqRu/MTazf/c TqkD9D7XM47sk0kINwB6UHbqMGQAKvHCGAv5LLfo7RF3Hi20bS/WhhZ1JdPLh57qM4LG uUkVhSyTPylwy8kacyeyJgTIQZ+XOZ8iWaHITzkuf18AblftarOn1rcekw2HZMR3+iwi DPjN0+TSguTC0vDC67ZcdBzNhkiA6WRqck2iw+6f3KU1H8txtLQbsXgs2f3/wfDCqjE7 I2IA== X-Gm-Message-State: APjAAAVDGVwYkZBOEHldDHAD9iqIb8XjZrt/x/C4lSXIQ11DeGHpvlXb T67+5xPLiabFGod6v/CNk/M= X-Google-Smtp-Source: APXvYqzhsmKAz5VmRPSKaazOx0L+g4++/D11tDyGD8k/X/8pXCzJDy17Vdu7PyKnV0PN8ggGUXx5cw== X-Received: by 2002:a19:6b14:: with SMTP id d20mr25358056lfa.152.1553891384414; Fri, 29 Mar 2019 13:29:44 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id l16sm542645ljb.24.2019.03.29.13.29.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Mar 2019 13:29:43 -0700 (PDT) From: Janusz Krzysztofik To: Sakari Ailus Cc: Mauro Carvalho Chehab , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH v2 1/2] media: ov6650: Move v4l2_clk_get() to ov6650_video_probe() helper Date: Fri, 29 Mar 2019 21:29:02 +0100 Message-Id: <20190329202903.5622-2-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190329202903.5622-1-jmkrzyszt@gmail.com> References: <20190325003501.14687-1-jmkrzyszt@gmail.com> <20190329202903.5622-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 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; } From patchwork Fri Mar 29 20:29:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10877695 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 4616E1669 for ; Fri, 29 Mar 2019 20:30:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3617D2922C for ; Fri, 29 Mar 2019 20:30:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A95129245; Fri, 29 Mar 2019 20:30:00 +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 6FBAA291B6 for ; Fri, 29 Mar 2019 20:29:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730156AbfC2U3y (ORCPT ); Fri, 29 Mar 2019 16:29:54 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:44496 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729996AbfC2U3r (ORCPT ); Fri, 29 Mar 2019 16:29:47 -0400 Received: by mail-lj1-f195.google.com with SMTP id h16so3063020ljg.11; Fri, 29 Mar 2019 13:29: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=MlDXCuI7PsVS0X8mcb37dasmOR6g2cXO+GpBONhlG14=; b=I0j6X1xSwo1gjfZ+fWUm5bTgJYGrAb4d/d3QCP8p3ogsijcmJ9l7uMZgGgnJVz3Kcq 6dQLN0UtyzxPM9prCCYhKtvaZSpufdSkevQ0tTSxJlFCZP+gO8x6kOeXZrN31nua/gc8 Klqbqq+ZmLJ7FUtgOUoP5NY/M9D4cifUCb2ouiCkT9/3Q0qKQLiVeQxzc6rbZancatzr yXAEQ8csUNNHLZ/kdJVEbHrFFBoH9Q88zYHvwDd3qr0soypF9DOx/JxCG5dIlo57LGYz Maty9qL83DQpm2vTy6itNyHatrA8XN+jCgiOsxoC6XfU50h0tg3TEAIDpKCpcaLk3aFK ax+Q== 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=MlDXCuI7PsVS0X8mcb37dasmOR6g2cXO+GpBONhlG14=; b=FZ3fLcd2XeRNx70+OeGubsvFzUCpcHR95Y6LcAYirCcWxwVHBhpBvk9JzMygd46wCn VILOapOjbs51btzkRNxpc8RpXF3CbjSxcu/SjeeKCTNPVhBLKq7shjpmz9dH9KQZ2mHU ydntvO972XeVlar7lokFQ8oP25Um/9fT4JFCeidu+cHXt8Gg3LppFQHIc8/Xmtmgn5ON atcWYFL+lsnZ+nymR515aNeFEi8lZKNtvoTRO8Kyqu13AjHLtE/dGopPqb4rR/R8ipCT Sb1nHhFOXlRTfLx3TKxxWwKHDzZFwazpgXcFfVuDB89q9q7BNuX6v9/ulOtAx1Yqchho WEaQ== X-Gm-Message-State: APjAAAX++AEnqgcdTCbrBFW+cnBVKCo0s9HrqMg7PXxHisJlq45vWhTd 1lIUsFGPmPvQtO/F+Ttyzdc= X-Google-Smtp-Source: APXvYqzvCPDBZ3TK/dLLYAf5QuDVrUFwRMJREyRZlF9lNHYY/36M5zDFhOfb5AeGPY1Hm7ZgLUbyxw== X-Received: by 2002:a2e:3010:: with SMTP id w16mr2882731ljw.62.1553891385821; Fri, 29 Mar 2019 13:29: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 l16sm542645ljb.24.2019.03.29.13.29.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Mar 2019 13:29:45 -0700 (PDT) From: Janusz Krzysztofik To: Sakari Ailus Cc: Mauro Carvalho Chehab , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH v2 2/2] media: ov6650: Register with asynchronous subdevice framework Date: Fri, 29 Mar 2019 21:29:03 +0100 Message-Id: <20190329202903.5622-3-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190329202903.5622-1-jmkrzyszt@gmail.com> References: <20190325003501.14687-1-jmkrzyszt@gmail.com> <20190329202903.5622-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 de7d9790f054..50e60da73036 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; @@ -855,7 +856,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) return 0; eclkput: @@ -943,6 +944,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 */ @@ -1003,7 +1008,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); @@ -1015,7 +1025,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; }