From patchwork Sat Mar 30 01:06:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10877983 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 BA6C9922 for ; Sat, 30 Mar 2019 01:06:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA757290CE for ; Sat, 30 Mar 2019 01:06:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9BCF629301; Sat, 30 Mar 2019 01:06:37 +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 453CE290CE for ; Sat, 30 Mar 2019 01:06:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731502AbfC3BGf (ORCPT ); Fri, 29 Mar 2019 21:06:35 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:36069 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731312AbfC3BGe (ORCPT ); Fri, 29 Mar 2019 21:06:34 -0400 Received: by mail-lf1-f68.google.com with SMTP id d18so2630855lfn.3; Fri, 29 Mar 2019 18:06:32 -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=W5e9S/rdf3vJLpWgNnvi7r633xmhxhxcPT+bSdF3Vi+xEjNjjA9+t4UYsxehh5pAuY B/CXHjUQOjG6Xo2zFSKhvchdX0r7CgfalXTPbsVshcrU3j8guX9VS1H+pTfNFefSkabE Xpo23WqPEGxc093ueePxXxHNpdIDjhbSEuktsCDISL7pHjHaINuLTI1u+w9SnztI4FGf bUGscay7CjjaUZdWPtMAxI/h8uU4ftfArbiE6HZk90CDsNbtNMk2+jZslvzhN2GQOFl4 EJUbOuthSms0JZ38ExSEgnQy3WfB0X9ahKKr9Lwde8adhqPrEKO0uud5Z8ALHfWDcuce ueOw== 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=oO0nyIFKYPHEWzIrsQyc25Hq5q6/2DaLYNjC2nIM4kh6ZnmS9RNZZcBHJ5dbjAIMti +hwW6mws1n69y6gyrnWXGly7LRRTX7g03szvl/wuGcszsDudCto9swJAM8l8wzFRMIB6 DATVYsOFeE4T4NjWAI1UJZt9CYB3mZCQ/6MIZTFVjf1z+3n+wj0ye0smjab6mEObBehp KdPJth9BkcHWvHU0+84P9uOAgJYRfksr7yGAUf8coC6Ru4wwTP/y3UyQaTWZP10MXu37 mjnHd2qzyG1n74dCYkIPztPLvze+EpIQvh+W9OuknF0Pl96V4HFnjjheaopV+i3lq20c KjdA== X-Gm-Message-State: APjAAAX4dZat3TFFkRTLZnM55aACl3riMuLjNxWHEOLiakR2/fYmhUT+ 74upK0D7DT231pOAL3DMnhw= X-Google-Smtp-Source: APXvYqzNxWfPOafn2Dfl9MqfKj0j1h3I5UBSCqE5SswiHd+QfvhKdfnrhjXG2FlpKlzM8Geo6s9KnA== X-Received: by 2002:a19:6a02:: with SMTP id u2mr8666250lfu.20.1553907992193; Fri, 29 Mar 2019 18:06:32 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id v21sm556514lfg.26.2019.03.29.18.06.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Mar 2019 18:06:31 -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 v3 1/2] media: ov6650: Move v4l2_clk_get() to ov6650_video_probe() helper Date: Sat, 30 Mar 2019 02:06:09 +0100 Message-Id: <20190330010610.15094-2-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190330010610.15094-1-jmkrzyszt@gmail.com> References: <20190329202903.5622-1-jmkrzyszt@gmail.com> <20190330010610.15094-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 Sat Mar 30 01:06:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10877985 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 0F98F14DE for ; Sat, 30 Mar 2019 01:06:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF330290CE for ; Sat, 30 Mar 2019 01:06:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E361D29301; Sat, 30 Mar 2019 01:06:51 +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 8CBA6290CE for ; Sat, 30 Mar 2019 01:06:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731545AbfC3BGg (ORCPT ); Fri, 29 Mar 2019 21:06:36 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:45755 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730847AbfC3BGf (ORCPT ); Fri, 29 Mar 2019 21:06:35 -0400 Received: by mail-lj1-f194.google.com with SMTP id y6so3451512ljd.12; Fri, 29 Mar 2019 18:06:34 -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=Shu1qD9JXT2LMrmuOPOiVO+RXclrNPuRngondPpOLHc=; b=Kghjx4v6/YYAiGka7w+pqIsv8znZ7t9HneM9fWnGwhC3HsccFsCGu5/8nRhcG3HcQL oMcKG3gJQ+XTmTOMfwAyTD6nsL9GD0ZTJ2rHHre/wA5diiknhzTaGnOiQ+qnBR4752EA Po/FmKKYLrH0WhIE3XWS39TKBHhrcOmh1J2oUsM1S8ict0epLkDQ22p3/skhiha5ezFj C2yUZ87vg/rMxaCnDPBf7Szsi/x9idDNIe65KK5jV6uMDG2YyWjHtUUdB8psEQc8CEWw 2yZUNhZulGM3ISR4H56u1uTqpekIqZgACLO/dfwkHuyeGOmeftns5o3E9y0Zcy5L3KC6 oLjQ== 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=Shu1qD9JXT2LMrmuOPOiVO+RXclrNPuRngondPpOLHc=; b=KmvW5cO4xV1HTqAvvl6kWuGbeg/MfZEqFuU8tV8WY7e1PXh8gpbs6hDo/GKabgRJnc KoceYwMUqr78KuE6FsYapodLAjoe5iTFJ8kzC9onBapJtp0vetALX/c99z4BQiFEeWiT Z73110SyBtI+UdtlpRsQo64cs55l4HMURoSpO7rRRF1X0/MFM67/HG0J8S90vVPpRO2X TCb2FAnE5zTRtxKHyZWXBd8wdKKWsbQTlJ0m+T4O2tVC2zU+w3jjXVCTHS1167qxcju0 Rg07TpWtL6AhFT9eM+sjp8j/0Jakq7xSWMIzqELOpaYuy+Dpa7dH2AhfPg1Lj9adC9Bv qOOQ== X-Gm-Message-State: APjAAAVloVBHHQgYkeFSTwKb8PrpgA8XQBe59DQyKrIMgHGW5c5YRm60 XzUXG9nzRagO+KzVdwKHAIQ= X-Google-Smtp-Source: APXvYqz4EnJlW34qzOevji4BKrIJhvT/nuEwc1Yj/vlee2acpgyaAJ6WV8ZmOCYNy78WQbsP9p+bww== X-Received: by 2002:a2e:960b:: with SMTP id v11mr18259084ljh.135.1553907993452; Fri, 29 Mar 2019 18:06:33 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id v21sm556514lfg.26.2019.03.29.18.06.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Mar 2019 18:06:32 -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 v3 2/2] media: ov6650: Register with asynchronous subdevice framework Date: Sat, 30 Mar 2019 02:06:10 +0100 Message-Id: <20190330010610.15094-3-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190330010610.15094-1-jmkrzyszt@gmail.com> References: <20190329202903.5622-1-jmkrzyszt@gmail.com> <20190330010610.15094-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 | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c index de7d9790f054..7145bb68a9e1 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,11 @@ 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; + v4l2_i2c_subdev_set_name(&priv->subdev, client, NULL, NULL); + + ret = v4l2_async_register_subdev(&priv->subdev); if (ret) v4l2_ctrl_handler_free(&priv->hdl); @@ -1015,7 +1024,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; }