From patchwork Thu Dec 19 13:49:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13915109 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41404224AE3 for ; Thu, 19 Dec 2024 13:49:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734616192; cv=none; b=pPtkY/O6fOp91/Lj/cLZO7VVptKQBcl/U7CB4XVZZV1WwpFqGJhUha6SMbo0NA6JVEUgEqyF3Z3r4cx9Qw2jez687B2JHIxxJ3lxf/y7m4/1dRnZQ0GjyixRjsrlVi3WRC1Lk8pWwAUc085mTZVmKOg+zsshAalL9C3WQ7zh9Cg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734616192; c=relaxed/simple; bh=pDmgfodYgcujR/zkjQksND3Tbo7bQdDfdx+CHhRLe/A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b14MMRk0ZjGW6AiQReN5WkBNFj2+JcCp+Cq3ECcQqHDZMsf8AhXllkGVW5YzodRMCL8RMpB/LIjTuTL1ak8IagCZ9ST8BGJHjm1d/NH8MhfNeIcHp84HwBMwE/HEH2igkWIkkz29o+jIkV8lmf8eUZNheT/G7b4pW1nA3ywxsNo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=VHx2tL2g; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VHx2tL2g" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734616190; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1TNuKj/GC6BKRW7dRblC0wfxYIk0g1MD46Ol1TJX8c4=; b=VHx2tL2gh0GC9evu1GvgZqRSoqF6C9a4AqSWtyFAcSu3WZkejVO8wz+pzf9cJuyIg6CEI4 u8VcmMe92WN41aFXQw0qXkBrWlZzPrKcU0gHRoLj3NMI9aEb7pe3RG3JhPhTR6JRw13TMR 4/i99fANfA+SOi4PwXSkajYuZXcyIc0= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-350-1QBQyP1tO8i_lr74X9K_Ng-1; Thu, 19 Dec 2024 08:49:47 -0500 X-MC-Unique: 1QBQyP1tO8i_lr74X9K_Ng-1 X-Mimecast-MFC-AGG-ID: 1QBQyP1tO8i_lr74X9K_Ng Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DFA2E19560BD; Thu, 19 Dec 2024 13:49:45 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.39.194.60]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CBC131955F54; Thu, 19 Dec 2024 13:49:43 +0000 (UTC) From: Hans de Goede To: Sakari Ailus , Jason Chen , Bryan O'Donoghue Cc: Hans de Goede , Mauro Carvalho Chehab , linux-media@vger.kernel.org Subject: [PATCH 1/8] media: ov08x40: Properly turn sensor on/off when runtime-suspended Date: Thu, 19 Dec 2024 14:49:33 +0100 Message-ID: <20241219134940.15472-2-hdegoede@redhat.com> In-Reply-To: <20241219134940.15472-1-hdegoede@redhat.com> References: <20241219134940.15472-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Commit df1ae2251a50 ("media: ov08x40: Add OF probe support") added support for a reset GPIO, regulators and a clk provider controlled through new ov08x40_power_off() and ov08x40_power_on() functions. But it missed adding a pm ops structure to call these functions on runtime suspend/resume. Add the missing pm ops and only call ov08x40_power_off() on remove() when not already runtime-suspended to avoid unbalanced regulator / clock disable calls. Fixes: df1ae2251a50 ("media: ov08x40: Add OF probe support") Signed-off-by: Hans de Goede Tested-by: Bryan O'Donoghue --- drivers/media/i2c/ov08x40.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c index b9682264e2f5..aae923da1e86 100644 --- a/drivers/media/i2c/ov08x40.c +++ b/drivers/media/i2c/ov08x40.c @@ -2324,11 +2324,14 @@ static void ov08x40_remove(struct i2c_client *client) ov08x40_free_controls(ov08x); pm_runtime_disable(&client->dev); + if (!pm_runtime_status_suspended(&client->dev)) + ov08x40_power_off(&client->dev); pm_runtime_set_suspended(&client->dev); - - ov08x40_power_off(&client->dev); } +static DEFINE_RUNTIME_DEV_PM_OPS(ov08x40_pm_ops, ov08x40_power_on, + ov08x40_power_off, NULL); + #ifdef CONFIG_ACPI static const struct acpi_device_id ov08x40_acpi_ids[] = { {"OVTI08F4"}, @@ -2349,6 +2352,7 @@ static struct i2c_driver ov08x40_i2c_driver = { .name = "ov08x40", .acpi_match_table = ACPI_PTR(ov08x40_acpi_ids), .of_match_table = ov08x40_of_match, + .pm = pm_sleep_ptr(&ov08x40_pm_ops), }, .probe = ov08x40_probe, .remove = ov08x40_remove, From patchwork Thu Dec 19 13:49:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13915110 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C4D5270816 for ; Thu, 19 Dec 2024 13:49:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734616193; cv=none; b=jiUku6XYPs9ZYSRhpx6JY1mw3BEHjebgCczxEEcJOkzOV2OhjgaVg97RsEADGaRdpE1VnTEcQQsCjt/cop4QWU35gUph0i7YgBO2da+5rxZqvzWfcttPo+oOi49duD6gtOVEwQJZnx+lfjmb8F2IxCaL6bhV89crstPko2A5Nn0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734616193; c=relaxed/simple; bh=1R0NFm/zZaFNauvBSR570WFPr8UadYIPS0HZELE4w2k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JK7ispMnEFWF4Xa429EXAESFjugj3SjvC4hdkkgdlg4m2uI3X/Q8c71ADQfvHB3HKS3wrNkGW3rGjkXRXPJgwQXQLPd1Tbdi3Om3TNVq2o1Wy2Nm9mGDteie9Q5zf9iDTD+DAqK0DD0f5qNVBEpAS6al1MemR7xjZwUlimdyFHA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=EUooxpTP; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="EUooxpTP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734616190; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a5ALT+0jie9Pj9j8UhNajjiwinE0wi9Rq3q5FBFq9N0=; b=EUooxpTP9SjdCHvhj02bNFsG07rXDMI558G1Oc9iQ9mPRKEPIU4jSEBG5QeTxX1q5X78Rn 4v2+zw96+COr14tkBRjwJ9LJtS5GuEn3OxtO8O2yKrmwDqSGWnuYlPdXdfYf6TK0OT+NBB xEpGQfFU4FrR3iAblEXvNhsjWXcZFcY= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-108-POiJwr_-OXeNt0LBceFu3w-1; Thu, 19 Dec 2024 08:49:49 -0500 X-MC-Unique: POiJwr_-OXeNt0LBceFu3w-1 X-Mimecast-MFC-AGG-ID: POiJwr_-OXeNt0LBceFu3w Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 23D2C19560A3; Thu, 19 Dec 2024 13:49:48 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.39.194.60]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 50B231955F54; Thu, 19 Dec 2024 13:49:46 +0000 (UTC) From: Hans de Goede To: Sakari Ailus , Jason Chen , Bryan O'Donoghue Cc: Hans de Goede , Mauro Carvalho Chehab , linux-media@vger.kernel.org Subject: [PATCH 2/8] media: ov08x40: Move fwnode_graph_get_next_endpoint() call up Date: Thu, 19 Dec 2024 14:49:34 +0100 Message-ID: <20241219134940.15472-3-hdegoede@redhat.com> In-Reply-To: <20241219134940.15472-1-hdegoede@redhat.com> References: <20241219134940.15472-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 If the bridge has not yet setup the fwnode-graph then the fwnode_property_read_u32("clock-frequency") call will fail. Make the fwnode_graph_get_next_endpoint() call the first call in ov08x40_check_hwcfg() and return -EPROBE_DEFER if it fails. Signed-off-by: Hans de Goede Tested-by: Bryan O'Donoghue --- Changes in v2: - Rebase on top of Bryan O'Donoghue OF support changes --- drivers/media/i2c/ov08x40.c | 40 +++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c index aae923da1e86..e4046d4705c3 100644 --- a/drivers/media/i2c/ov08x40.c +++ b/drivers/media/i2c/ov08x40.c @@ -2151,23 +2151,37 @@ static int ov08x40_check_hwcfg(struct ov08x40 *ov08x, struct device *dev) int ret; u32 xvclk_rate; - if (!fwnode) - return -ENXIO; + /* + * Sometimes the fwnode graph is initialized by the bridge driver. + * Bridge drivers doing this also add sensor properties, wait for this. + */ + ep = fwnode_graph_get_next_endpoint(fwnode, NULL); + if (!ep) + return dev_err_probe(dev, -EPROBE_DEFER, + "waiting for fwnode graph endpoint\n"); + + ret = v4l2_fwnode_endpoint_alloc_parse(ep, &bus_cfg); + fwnode_handle_put(ep); + if (ret) + return ret; if (!is_acpi_node(fwnode)) { ov08x->xvclk = devm_clk_get(dev, NULL); if (IS_ERR(ov08x->xvclk)) { dev_err(dev, "could not get xvclk clock (%pe)\n", ov08x->xvclk); - return PTR_ERR(ov08x->xvclk); + ret = PTR_ERR(ov08x->xvclk); + goto out_err; } xvclk_rate = clk_get_rate(ov08x->xvclk); ov08x->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); - if (IS_ERR(ov08x->reset_gpio)) - return PTR_ERR(ov08x->reset_gpio); + if (IS_ERR(ov08x->reset_gpio)) { + ret = PTR_ERR(ov08x->reset_gpio); + goto out_err; + } for (i = 0; i < ARRAY_SIZE(ov08x40_supply_names); i++) ov08x->supplies[i].supply = ov08x40_supply_names[i]; @@ -2176,31 +2190,23 @@ static int ov08x40_check_hwcfg(struct ov08x40 *ov08x, struct device *dev) ARRAY_SIZE(ov08x40_supply_names), ov08x->supplies); if (ret) - return ret; + goto out_err; } else { ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency", &xvclk_rate); if (ret) { dev_err(dev, "can't get clock frequency"); - return ret; + goto out_err; } } if (xvclk_rate != OV08X40_XVCLK) { dev_err(dev, "external clock %d is not supported", xvclk_rate); - return -EINVAL; + ret = -EINVAL; + goto out_err; } - ep = fwnode_graph_get_next_endpoint(fwnode, NULL); - if (!ep) - return -ENXIO; - - ret = v4l2_fwnode_endpoint_alloc_parse(ep, &bus_cfg); - fwnode_handle_put(ep); - if (ret) - return ret; - if (bus_cfg.bus.mipi_csi2.num_data_lanes != OV08X40_DATA_LANES) { dev_err(dev, "number of CSI2 data lanes %d is not supported", bus_cfg.bus.mipi_csi2.num_data_lanes); From patchwork Thu Dec 19 13:49:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13915111 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E01031F8682 for ; Thu, 19 Dec 2024 13:49:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734616197; cv=none; b=eIh7w7Qah0j9aVgf4rlm8j9iDmFLDow5nWpNLLRyBmcF9VYGcXDUqDIbHEeMu8KYkFvwvWLvMcyYzZ3FMQ0T/GnhPZYLLxbHN2GxG4dGHSOkKIgkabpU8PazUSicJ4tCBY15EjJJs+DW3WY9nBnwl8cEoZtz041T7SaAHeKveMw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734616197; c=relaxed/simple; bh=YW+eGRpnQ47Ek+2Gagg8zqTYJT2S93HObo3hyoiSCJE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IWE/um9x6mq9OhiR7ZgaLjeVywHhnjqgbYm2ghb2Q+R+2grZ54pCAPdGOu1yqOPwloAptG3/SEIl9qQGOMi+6p+/2y1d5YqbtDpHAt41SYXgKdqEtjWl78p47dQ9xDbB9MekGDbBDePvXmJrJD4yi1kyLifOgfD2Gw32ZInKex0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=CF8pS286; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CF8pS286" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734616194; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4B1ntKcwAXxvtIhEAEuErzDpXJ6V+fFs7P8G0AvEbe0=; b=CF8pS286AV3/BFcVxdqqk87FSRe2FN7OXzj0pl55uIXPEFvDNiZ4c+8/YXer0v18XN8eKh dPOgqetYLlnQha8JiIOLi3HKr8RlHeJjzZEFqG3ssFA8/wd4BflcAeSffIcCRdb/M03gjD G7KkmmwlHAIGlW8gYjREArHbsS85nZY= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-171-MjmjRPPjMUGEvW3vyAzX5w-1; Thu, 19 Dec 2024 08:49:51 -0500 X-MC-Unique: MjmjRPPjMUGEvW3vyAzX5w-1 X-Mimecast-MFC-AGG-ID: MjmjRPPjMUGEvW3vyAzX5w Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 57B571955E70; Thu, 19 Dec 2024 13:49:50 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.39.194.60]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9184D1955F54; Thu, 19 Dec 2024 13:49:48 +0000 (UTC) From: Hans de Goede To: Sakari Ailus , Jason Chen , Bryan O'Donoghue Cc: Hans de Goede , Mauro Carvalho Chehab , linux-media@vger.kernel.org Subject: [PATCH 3/8] media: ov08x40: Get reset GPIO and regulators on ACPI platforms too Date: Thu, 19 Dec 2024 14:49:35 +0100 Message-ID: <20241219134940.15472-4-hdegoede@redhat.com> In-Reply-To: <20241219134940.15472-1-hdegoede@redhat.com> References: <20241219134940.15472-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 ACPI platforms might also have a reset GPIO and regulators, move the code to get these outside of the if (!is_acpi_node(fwnode)) check. This also removes the is_acpi_node(fwnode) checks from ov08x40_power_on() / ov08x40_power_off() both the GPIO hand the clk frameworks functions used there will happily accept the NULL pointer returned from the optional get() functions when there is no reset GPIO / no clk. While moving the code around also at error logging to the error exit path for getting the reset GPIO. Signed-off-by: Hans de Goede Tested-by: Bryan O'Donoghue --- drivers/media/i2c/ov08x40.c | 38 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c index e4046d4705c3..8b1380506778 100644 --- a/drivers/media/i2c/ov08x40.c +++ b/drivers/media/i2c/ov08x40.c @@ -1322,9 +1322,6 @@ static int ov08x40_power_on(struct device *dev) struct ov08x40 *ov08x = to_ov08x40(sd); int ret; - if (is_acpi_node(dev_fwnode(dev))) - return 0; - ret = clk_prepare_enable(ov08x->xvclk); if (ret < 0) { dev_err(dev, "failed to enable xvclk\n"); @@ -1360,9 +1357,6 @@ static int ov08x40_power_off(struct device *dev) struct v4l2_subdev *sd = dev_get_drvdata(dev); struct ov08x40 *ov08x = to_ov08x40(sd); - if (is_acpi_node(dev_fwnode(dev))) - return 0; - gpiod_set_value_cansleep(ov08x->reset_gpio, 1); regulator_bulk_disable(ARRAY_SIZE(ov08x40_supply_names), ov08x->supplies); @@ -2165,6 +2159,22 @@ static int ov08x40_check_hwcfg(struct ov08x40 *ov08x, struct device *dev) if (ret) return ret; + ov08x->reset_gpio = devm_gpiod_get_optional(dev, "reset", + GPIOD_OUT_LOW); + if (IS_ERR(ov08x->reset_gpio)) { + ret = dev_err_probe(dev, PTR_ERR(ov08x->reset_gpio), + "getting reset GPIO\n"); + goto out_err; + } + + for (i = 0; i < ARRAY_SIZE(ov08x40_supply_names); i++) + ov08x->supplies[i].supply = ov08x40_supply_names[i]; + + ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ov08x40_supply_names), + ov08x->supplies); + if (ret) + goto out_err; + if (!is_acpi_node(fwnode)) { ov08x->xvclk = devm_clk_get(dev, NULL); if (IS_ERR(ov08x->xvclk)) { @@ -2175,22 +2185,6 @@ static int ov08x40_check_hwcfg(struct ov08x40 *ov08x, struct device *dev) } xvclk_rate = clk_get_rate(ov08x->xvclk); - - ov08x->reset_gpio = devm_gpiod_get_optional(dev, "reset", - GPIOD_OUT_LOW); - if (IS_ERR(ov08x->reset_gpio)) { - ret = PTR_ERR(ov08x->reset_gpio); - goto out_err; - } - - for (i = 0; i < ARRAY_SIZE(ov08x40_supply_names); i++) - ov08x->supplies[i].supply = ov08x40_supply_names[i]; - - ret = devm_regulator_bulk_get(dev, - ARRAY_SIZE(ov08x40_supply_names), - ov08x->supplies); - if (ret) - goto out_err; } else { ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency", &xvclk_rate); From patchwork Thu Dec 19 13:49:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13915112 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 022511F8682 for ; Thu, 19 Dec 2024 13:49:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734616200; cv=none; b=JdmR8O+cQU1mt1nrR4e4nhV+237/feC00fa1EmFOKs3ri0HDoEaxmhjpMDTEITsnTqgHaxOprtMrtc3od+/ov62cCc0y66spNMFKwBfObC6jXzCVV+BobXX7hPoH7uACDsEF+s8rLSs0jqR7T1X99sjx0GnLfWzANy0HNU78EJw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734616200; c=relaxed/simple; bh=d4/TevPymctqsnNVqMhRRYhDLsvm21ITOlv8kVHNxYg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A8MEKnE9KLDw2dNHDmM4A9htIDRBL4beifEc/Swp1PRxKAupNDZuQ9WkLSjK+T1RNqO2v/MPw5YK+QA0S6IZQM2uSQNL1HHFW13YeRbWxndCAINKUS+7ORvbbFfxsFOnsn/Vn8SErMrNJfPWk2xjdOvxUP0A8iuRoRHMrdgLJlw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=P0q+tyzG; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="P0q+tyzG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734616198; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SYcMqN0xprIBz0c5VREduwqaJY59wFvqmhIwCvl9maY=; b=P0q+tyzGdLJewYeEIdJJSsYyw97u1IKPvtF8M7+Pizk10L1iSUqLOxrxPrzH/t5ABbHcnY e3WOxltSK3WHJgT8dBdSPejmgrxlgdIP+8B9Ifa8Lo7LhmtRlBvpzsE4xkktWI59RN8eq1 PMrv8epcndyuZcZ62eXCTjEtUU1SY/g= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-428-LY92QmcAMQmCrCElChRwdw-1; Thu, 19 Dec 2024 08:49:54 -0500 X-MC-Unique: LY92QmcAMQmCrCElChRwdw-1 X-Mimecast-MFC-AGG-ID: LY92QmcAMQmCrCElChRwdw Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8D68119560A3; Thu, 19 Dec 2024 13:49:52 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.39.194.60]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BD5AC1955F54; Thu, 19 Dec 2024 13:49:50 +0000 (UTC) From: Hans de Goede To: Sakari Ailus , Jason Chen , Bryan O'Donoghue Cc: Hans de Goede , Mauro Carvalho Chehab , linux-media@vger.kernel.org Subject: [PATCH 4/8] media: ov08x40: Get clock on ACPI platforms too Date: Thu, 19 Dec 2024 14:49:36 +0100 Message-ID: <20241219134940.15472-5-hdegoede@redhat.com> In-Reply-To: <20241219134940.15472-1-hdegoede@redhat.com> References: <20241219134940.15472-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 ACPI platforms might also have a clk provider which needs to be controlled, always try to get a clk using clk_get_optional() and when that fails fall back to getting the xvclk frequency from the "clock-frequency" property. Signed-off-by: Hans de Goede Tested-by: Bryan O'Donoghue --- drivers/media/i2c/ov08x40.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c index 8b1380506778..de8291e8b6e7 100644 --- a/drivers/media/i2c/ov08x40.c +++ b/drivers/media/i2c/ov08x40.c @@ -2175,15 +2175,13 @@ static int ov08x40_check_hwcfg(struct ov08x40 *ov08x, struct device *dev) if (ret) goto out_err; - if (!is_acpi_node(fwnode)) { - ov08x->xvclk = devm_clk_get(dev, NULL); - if (IS_ERR(ov08x->xvclk)) { - dev_err(dev, "could not get xvclk clock (%pe)\n", - ov08x->xvclk); - ret = PTR_ERR(ov08x->xvclk); - goto out_err; - } - + ov08x->xvclk = devm_clk_get_optional(dev, NULL); + if (IS_ERR(ov08x->xvclk)) { + ret = dev_err_probe(dev, PTR_ERR(ov08x->xvclk), + "getting xvclk\n"); + goto out_err; + } + if (ov08x->xvclk) { xvclk_rate = clk_get_rate(ov08x->xvclk); } else { ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency", From patchwork Thu Dec 19 13:49:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13915114 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9330B224AE2 for ; Thu, 19 Dec 2024 13:50:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734616202; cv=none; b=ADH7YkQSkMCk2+hZwNbidklx2mDyIPhuJqtpMRh/4vJjdt30bUBV/B+MK1sXFtfdclyAvuI9GMMyYfigRY26h43uxGCOJTcolPY8SXtc9VYiuodG2o3xQXQPG775wL+wu3haV9BfmJkZCXiQn7MdXCEuO4sNAi9AqLPO8ILXuQE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734616202; c=relaxed/simple; bh=3iRlFbw/K2s7a1bQ5oQPXGfheamMiCbkAKtqeGcyZX8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L6RENNSL8OEAet5lmCm+ykKU/LBLNo3CWNtFu33no8GB+QlOran0LlqjEH1GXs2Bhx9spCDtpDKnaSnXe9oHIBdssknZyj29mForHm7n1VciP5/H3Il1jNzFxZF9Tu7y7thRG0gEeHG6QgpCiWecBw49glVngUhsIFO70gsSzp8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=g8hHSxkV; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="g8hHSxkV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734616199; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+TPNHDCY+ZVW1/YfFzlwJrNsMDY/FroqwNoqV41XJIs=; b=g8hHSxkVladEdXiJEDll3fXtZ2/xUGB6jeJjZ0AJZkE9u4FfLb5HmaY/YYnOXFj9Xlscc+ 30TOM/Cm5NC4S7WcmXMKXcBb73iF6KA+LXFryXdMO42YG8uRaHaeUvh/l+71gzBrkwJl/Q YH9LuJXj5nXt21EyYocZ0ycqbgQh7aU= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-60-li8UEwV0PLuwVD-_A4bn5Q-1; Thu, 19 Dec 2024 08:49:56 -0500 X-MC-Unique: li8UEwV0PLuwVD-_A4bn5Q-1 X-Mimecast-MFC-AGG-ID: li8UEwV0PLuwVD-_A4bn5Q Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BB39D1956048; Thu, 19 Dec 2024 13:49:54 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.39.194.60]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id F223A1955F54; Thu, 19 Dec 2024 13:49:52 +0000 (UTC) From: Hans de Goede To: Sakari Ailus , Jason Chen , Bryan O'Donoghue Cc: Hans de Goede , Mauro Carvalho Chehab , linux-media@vger.kernel.org Subject: [PATCH 5/8] media: ov08x40: Move ov08x40_identify_module() function up Date: Thu, 19 Dec 2024 14:49:37 +0100 Message-ID: <20241219134940.15472-6-hdegoede@redhat.com> In-Reply-To: <20241219134940.15472-1-hdegoede@redhat.com> References: <20241219134940.15472-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Move the ov08x40_identify_module() function to above ov08x40_set_stream() this is a preparation patch for adding a missing ov08x40_identify_module() call to ov08x40_set_stream(). No functional changes, just moving code around. Signed-off-by: Hans de Goede Tested-by: Bryan O'Donoghue --- drivers/media/i2c/ov08x40.c | 52 ++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c index de8291e8b6e7..44989a37c2f3 100644 --- a/drivers/media/i2c/ov08x40.c +++ b/drivers/media/i2c/ov08x40.c @@ -1931,6 +1931,32 @@ static int ov08x40_stop_streaming(struct ov08x40 *ov08x) OV08X40_REG_VALUE_08BIT, OV08X40_MODE_STANDBY); } +/* Verify chip ID */ +static int ov08x40_identify_module(struct ov08x40 *ov08x) +{ + struct i2c_client *client = v4l2_get_subdevdata(&ov08x->sd); + int ret; + u32 val; + + if (ov08x->identified) + return 0; + + ret = ov08x40_read_reg(ov08x, OV08X40_REG_CHIP_ID, + OV08X40_REG_VALUE_24BIT, &val); + if (ret) + return ret; + + if (val != OV08X40_CHIP_ID) { + dev_err(&client->dev, "chip id mismatch: %x!=%x\n", + OV08X40_CHIP_ID, val); + return -ENXIO; + } + + ov08x->identified = true; + + return 0; +} + static int ov08x40_set_stream(struct v4l2_subdev *sd, int enable) { struct ov08x40 *ov08x = to_ov08x40(sd); @@ -1968,32 +1994,6 @@ static int ov08x40_set_stream(struct v4l2_subdev *sd, int enable) return ret; } -/* Verify chip ID */ -static int ov08x40_identify_module(struct ov08x40 *ov08x) -{ - struct i2c_client *client = v4l2_get_subdevdata(&ov08x->sd); - int ret; - u32 val; - - if (ov08x->identified) - return 0; - - ret = ov08x40_read_reg(ov08x, OV08X40_REG_CHIP_ID, - OV08X40_REG_VALUE_24BIT, &val); - if (ret) - return ret; - - if (val != OV08X40_CHIP_ID) { - dev_err(&client->dev, "chip id mismatch: %x!=%x\n", - OV08X40_CHIP_ID, val); - return -ENXIO; - } - - ov08x->identified = true; - - return 0; -} - static const struct v4l2_subdev_video_ops ov08x40_video_ops = { .s_stream = ov08x40_set_stream, }; From patchwork Thu Dec 19 13:49:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13915113 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D11A224894 for ; Thu, 19 Dec 2024 13:49:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734616201; cv=none; b=rcjVTLbnZDIQmxGqZPHRvLKs+jRAbLNYFCiM0xjdkrlJr72LyTU7hx+x9pBnpI4gNk1MwkQHimktHy8EuQ6j5hzQjJovk+5uztLbc93OwVx9GV/JrT/+oHyfJcXZYXGtBBo2njHFWfkg31yx/W/kykLgr8kjTaWh50AfCCg3KF8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734616201; c=relaxed/simple; bh=uVIfIubwkNgqYcKl/EDxb/O4CFOk0Xj8MMumzIGqpC8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RCuVFzJ1K95EoBTmG0Aae5PxeprGepvwiOvTkkfyRefNEtmJPkqaiT63DKVeWcme5b36P222jRuQ7SYuqqfprXwynF+YrayCUUHhLmli4SI6zOnPcEbfgwDdyuWppSjeW8Ulb88APe9PVxIenr2VYYsDm8wmgXyDaC6HhDwyyRU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=GM4RooXf; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="GM4RooXf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734616199; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dwOhFmuEJa4E1H2W1LJCuIH6zWMQjyleFWA7Drhp6WI=; b=GM4RooXfcKO6ABaRvi/J3EaaufaLb90upW3kfbos9oYJZr87VvlKZW1HnujbZxiKCQg8Sp fR52R3SJFxzpVtk4VRwmyJfWx8MDtmVUxXSn+HRo3mIs27XGFln+it6z7mGe+XbHiKQl6f FeQjmUP5MouvPXRJw9Qr/puNH9vLy2E= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-675-Fh8dN66hNc2Dfrx3MQbfcA-1; Thu, 19 Dec 2024 08:49:58 -0500 X-MC-Unique: Fh8dN66hNc2Dfrx3MQbfcA-1 X-Mimecast-MFC-AGG-ID: Fh8dN66hNc2Dfrx3MQbfcA Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EAB5E19560AD; Thu, 19 Dec 2024 13:49:56 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.39.194.60]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 299831955F77; Thu, 19 Dec 2024 13:49:54 +0000 (UTC) From: Hans de Goede To: Sakari Ailus , Jason Chen , Bryan O'Donoghue Cc: Hans de Goede , Mauro Carvalho Chehab , linux-media@vger.kernel.org Subject: [PATCH 6/8] media: ov08x40: Improve ov08x40_identify_module() error logging Date: Thu, 19 Dec 2024 14:49:38 +0100 Message-ID: <20241219134940.15472-7-hdegoede@redhat.com> In-Reply-To: <20241219134940.15472-1-hdegoede@redhat.com> References: <20241219134940.15472-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 ov08x40_identify_module() already logs an error if the read ID mismatches, so having its caller also log an error results in 2 errors in this case. Add error logging to the ID register read in ov08x40_identify_module() and drop the error logging in the caller. Signed-off-by: Hans de Goede Tested-by: Bryan O'Donoghue --- drivers/media/i2c/ov08x40.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c index 44989a37c2f3..ca004343a9d8 100644 --- a/drivers/media/i2c/ov08x40.c +++ b/drivers/media/i2c/ov08x40.c @@ -1943,8 +1943,10 @@ static int ov08x40_identify_module(struct ov08x40 *ov08x) ret = ov08x40_read_reg(ov08x, OV08X40_REG_CHIP_ID, OV08X40_REG_VALUE_24BIT, &val); - if (ret) + if (ret) { + dev_err(&client->dev, "error reading chip-id register: %d\n", ret); return ret; + } if (val != OV08X40_CHIP_ID) { dev_err(&client->dev, "chip id mismatch: %x!=%x\n", @@ -2262,10 +2264,8 @@ static int ov08x40_probe(struct i2c_client *client) /* Check module identity */ ret = ov08x40_identify_module(ov08x); - if (ret) { - dev_err(&client->dev, "failed to find sensor: %d\n", ret); + if (ret) goto probe_power_off; - } } /* Set default mode to max resolution */ From patchwork Thu Dec 19 13:49:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13915116 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76CE0224AE2 for ; Thu, 19 Dec 2024 13:50:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734616209; cv=none; b=hCUIq6hSgDZHzlH7yx0NbdQXqcCHHAAjJHh3FpYOm2Hrn0ElmnNRyJ68MIhHU1Kc2KLPVqVRZ7Bfc88IkWNrv5seL0K1jxBuL/mmKiz3DmypVrhBbM4GYKAm+tba1rHxb8ePbVKcboCxnbRMm35XPb7qvcONQIiNBoq069+Vf/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734616209; c=relaxed/simple; bh=mfF/l6+L1SsYUaG5EcW4TES5zQnHAJwiLWYQuJRJvkA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pXIZp+msJn1V89KYGWyZobPM+Jqzn4MzpNIiBnMejkLE1K2J24ORpRCzptgfKjU/RbSi4a0YxzXk89sVQFnLPPsG0uNeY7mjxyzmAjeNwbqhCES23DXvHwVQ24BguHOp3LT6HKmF7NlIEyk4DfJ1f/KK2xD29FdnzZHM9q5ouFA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=WIOfw/Oq; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WIOfw/Oq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734616205; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=06TmFM3SQ3VJkJ/46+Gz0gj7967oZLxEJrAuIsnG3xk=; b=WIOfw/OqqaD8gXnF8CY/vfS/L+3jGsSgO+zNPrtSQ0Nnrs9YirRgYfNjWg6AwWhvHMccYq xRLuE0MyqLuG88ZyeFNanDIMMpB2hd32IeRFdGlbtaO66dBkCzglSpz/luKNzyLvFN9sAI iK1b6zHKo08kEdPKzaVX/kd7lmWKZkU= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-414-9c65JYopOPGBoqt2ATTzEw-1; Thu, 19 Dec 2024 08:50:01 -0500 X-MC-Unique: 9c65JYopOPGBoqt2ATTzEw-1 X-Mimecast-MFC-AGG-ID: 9c65JYopOPGBoqt2ATTzEw Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2395919560A3; Thu, 19 Dec 2024 13:49:59 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.39.194.60]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5C1E01955F68; Thu, 19 Dec 2024 13:49:57 +0000 (UTC) From: Hans de Goede To: Sakari Ailus , Jason Chen , Bryan O'Donoghue Cc: Hans de Goede , Mauro Carvalho Chehab , linux-media@vger.kernel.org Subject: [PATCH 7/8] media: ov08x40: Improve ov08x40_[read|write]_reg() error returns Date: Thu, 19 Dec 2024 14:49:39 +0100 Message-ID: <20241219134940.15472-8-hdegoede@redhat.com> In-Reply-To: <20241219134940.15472-1-hdegoede@redhat.com> References: <20241219134940.15472-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Improve ov08x40_[read|write]_reg() error returns, if we got an errno value from the I2C core use that instead of always returning -EIO. Signed-off-by: Hans de Goede Tested-by: Bryan O'Donoghue --- drivers/media/i2c/ov08x40.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c index ca004343a9d8..7fde422039cb 100644 --- a/drivers/media/i2c/ov08x40.c +++ b/drivers/media/i2c/ov08x40.c @@ -1394,7 +1394,7 @@ static int ov08x40_read_reg(struct ov08x40 *ov08x, ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); if (ret != ARRAY_SIZE(msgs)) - return -EIO; + return ret < 0 ? ret : -EIO; *val = be32_to_cpu(data_be); @@ -1463,7 +1463,7 @@ static int ov08x40_write_reg(struct ov08x40 *ov08x, u16 reg, u32 len, u32 __val) { struct i2c_client *client = v4l2_get_subdevdata(&ov08x->sd); - int buf_i, val_i; + int buf_i, val_i, ret; u8 buf[6], *val_p; __be32 val; @@ -1481,8 +1481,9 @@ static int ov08x40_write_reg(struct ov08x40 *ov08x, while (val_i < 4) buf[buf_i++] = val_p[val_i++]; - if (i2c_master_send(client, buf, len + 2) != len + 2) - return -EIO; + ret = i2c_master_send(client, buf, len + 2); + if (ret != len + 2) + return ret < 0 ? ret : -EIO; return 0; } From patchwork Thu Dec 19 13:49:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13915115 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7ECB6224AE3 for ; Thu, 19 Dec 2024 13:50:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734616208; cv=none; b=kZ9jGIxka8o4zKaMuQiPw0Mv2VJ9IlGMdP1t/HgkAndJHegOKjTu/9FQTBF0ub6i6IsmPdf2PqhED8MSvgO3Ma0Qq0Feh3LLXaX0bBdTJ0/jCFZY850Goy28XvjHxsN9TiJq+xbOh+nF4hJTiOSSjEPDnXvh5SYrL7x8RRrQQI8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734616208; c=relaxed/simple; bh=cKbZYuxocWcfHJxtpHEF79TfP1nZS2tLT7BDedmiM0I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OQhoEVJiekDlpIzykqduqs0y+0NHktDsmIDmGz+C+6xERJV/3GxJXEq9v+XbHAO5lIvRLA/OXs8RUlfrhe9df6wL3Aey/zKjmbvZI/gbkv0TPhRF3yydZUasdYkg6DpYL2yVVZgZXhRQH3Hnia1HWjte05uru2aGt/GVB0ZZZQ8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=i0clzlV/; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="i0clzlV/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734616205; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NkNup+eK0ow0PsI+wZGs/PEPe8hoG2SrzQGcdg5Ge0Y=; b=i0clzlV/zGVmWMKS8DIZPA+Iq1MgoVBUWJxiEDjmxScyLXqbX8lvQg1JmA7ZqP2o+ZRURk dHZQCe0hFRBHdnkzBRDhr2hxOG/uES7Yjb5MpR0kX783xRTDBc2dDiTVFpsqZ0JP/h1g49 WoKZPYd/d32O6sfQ9wwkwbV1qUIy/6w= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-245-APSlTSgyNWebqmuxnwC8yQ-1; Thu, 19 Dec 2024 08:50:02 -0500 X-MC-Unique: APSlTSgyNWebqmuxnwC8yQ-1 X-Mimecast-MFC-AGG-ID: APSlTSgyNWebqmuxnwC8yQ Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5E7331956096; Thu, 19 Dec 2024 13:50:01 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.39.194.60]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 86EAF1955F57; Thu, 19 Dec 2024 13:49:59 +0000 (UTC) From: Hans de Goede To: Sakari Ailus , Jason Chen , Bryan O'Donoghue Cc: Hans de Goede , Mauro Carvalho Chehab , linux-media@vger.kernel.org Subject: [PATCH 8/8] media: ov08x40: Add missing ov08x40_identify_module() call on stream-start Date: Thu, 19 Dec 2024 14:49:40 +0100 Message-ID: <20241219134940.15472-9-hdegoede@redhat.com> In-Reply-To: <20241219134940.15472-1-hdegoede@redhat.com> References: <20241219134940.15472-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 The driver might skip the ov08x40_identify_module() on probe() based on the acpi_dev_state_d0() check done in probe(). If the ov08x40_identify_module() call is skipped on probe() it should be done on the first stream start. Add the missing call. Note ov08x40_identify_module() will only do something on its first call, subsequent calls are no-ops. Signed-off-by: Hans de Goede Tested-by: Bryan O'Donoghue --- drivers/media/i2c/ov08x40.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c index 7fde422039cb..b6e69e0c2ecf 100644 --- a/drivers/media/i2c/ov08x40.c +++ b/drivers/media/i2c/ov08x40.c @@ -1973,6 +1973,10 @@ static int ov08x40_set_stream(struct v4l2_subdev *sd, int enable) if (ret < 0) goto err_unlock; + ret = ov08x40_identify_module(ov08x); + if (ret) + goto err_rpm_put; + /* * Apply default & customized values * and then start streaming.