From patchwork Fri Dec 20 14:41:21 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: 852667 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 D027121859D for ; Fri, 20 Dec 2024 14:41:47 +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=1734705709; cv=none; b=udxXecnGL/l7s+KwxgJ7UJ9bh7RPZR+tSqLyGJWUnigQsWz0B/Z3PanE3ogKHMDye7tlUcm1VJkH+GMh5/MyQNLqlw+sp+sHmAKpF54JKayNiOb6KmRWPgwvKarWPODElY0UwX4okovPFETVjTVY8s6KATTBfdc4eMc8JqHUCMY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734705709; c=relaxed/simple; bh=S79IH9uQrKnSpqwqyKNdK8l18xDH1QS/F1MGC3GTQGc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UPN0PIFVaRprIz9nOxWFa8dSiQHSYqg2OPGKzS31tzRJWmtXtP2U7tHjK5THwBa24IY/iYS5/UBpc2KFvKicmccmuMWlj7roaAagVLWGhYDoKdNiIhRxYNF8y/swFcebFvwk8gHLzbm6pqMZDEAdGOqpxbOTQETraurXnyumMOs= 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=WwGd34zs; 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="WwGd34zs" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734705706; 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=vg3rH1dUVRipxtVAruGyIBJRtszYktTBFbJ2xpH6gSc=; b=WwGd34zsQjWBFPARLpZlcQZXzV1PbdSVtLGtJXp749FSRwncCUx0qrnoOGJBQP3ln/RBsf rUUS1Yyb59Yp265O0Wm3/rKbxjf1EvQ7uWqXb0AQbykUeZmm4VRNOOPWwKm4LeSpkawD9l Yz7Jf5o26CM+ISkRn5fhkEaZkt7z1/g= 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-417-IFCnUmbZPw2zrXhJaS2weQ-1; Fri, 20 Dec 2024 09:41:45 -0500 X-MC-Unique: IFCnUmbZPw2zrXhJaS2weQ-1 X-Mimecast-MFC-AGG-ID: IFCnUmbZPw2zrXhJaS2weQ Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 71EAE195608B; Fri, 20 Dec 2024 14:41:43 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.193.74]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9D51219560AD; Fri, 20 Dec 2024 14:41:41 +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 v2 01/10] media: ov08x40: Properly turn sensor on/off when runtime-suspended Date: Fri, 20 Dec 2024 15:41:21 +0100 Message-ID: <20241220144130.66765-2-hdegoede@redhat.com> In-Reply-To: <20241220144130.66765-1-hdegoede@redhat.com> References: <20241220144130.66765-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.40 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") Tested-by: Bryan O'Donoghue Signed-off-by: Hans de Goede --- Changes in v2: - Fix wrong argument order of DEFINE_RUNTIME_DEV_PM_OPS() macro (oops) --- 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..83b49cf114ac 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_off, + ov08x40_power_on, 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 Fri Dec 20 14:41:23 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: 852666 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 8AFE72185A7 for ; Fri, 20 Dec 2024 14:41:54 +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=1734705716; cv=none; b=E1LYb8vrG3FqiCCn11ONudZkNkOWX9p8FQwrdKrK1tqcg3adKjo8HedfBFN1dAPBqNiUiVphAjMWqRi7gmc6MvqJUhZXiybwAKuZ2R8nu+ge3y/LktwEIqP/i9+kcL2m5O3NKi+wYCBJheY0Bdj6yp43pPiQ+znSLd/msDBWdu8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734705716; c=relaxed/simple; bh=cDeYy42VrI+rHEWzR12frA1lswbIArosPc69mRv8mPw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J6BVsGKZl2YgsmS4VFUpLiuuxTL9CBIaAfz8CDp3L1CcXR8VGd0iB0jIGKDZ+6JaUGv2eDkDgOPw2JBgWhrEqYaIm6satEluROqxui/5fIDlFJateVOG4ZPxcmnWSRyE2dJfSwZvYyA4bTXYVPRzjqwl5JWf2pM6//5cKBso81I= 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=a6f8gYbA; 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="a6f8gYbA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734705713; 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=rFRkAECr7mR1qjc5X9Wcb8rdkxBaKEscQj6VLXd18go=; b=a6f8gYbAwg/Y+dGlNG5HDx/40Zn9BfCH8c719l6+bJy5xOrsyCFgxLxUWsJyK8Y1xixqJl ZN6l/R6kxjAFP3Be6Rn33B/9z1Oz2JOHKxW8kHjIC98zhJnj8haeibzHPFARxm5ml47wFq PWmG2Gsa+0EAES4uUqI00QI0lk7UP4c= 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-346-t_VKuZIfNGqRROyo0sDsgw-1; Fri, 20 Dec 2024 09:41:49 -0500 X-MC-Unique: t_VKuZIfNGqRROyo0sDsgw-1 X-Mimecast-MFC-AGG-ID: t_VKuZIfNGqRROyo0sDsgw Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 0E8E01955F41; Fri, 20 Dec 2024 14:41:48 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.193.74]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 43B1919560AD; Fri, 20 Dec 2024 14:41:45 +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 v2 03/10] media: ov08x40: Get reset GPIO and regulators on ACPI platforms too Date: Fri, 20 Dec 2024 15:41:23 +0100 Message-ID: <20241220144130.66765-4-hdegoede@redhat.com> In-Reply-To: <20241220144130.66765-1-hdegoede@redhat.com> References: <20241220144130.66765-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.40 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. Tested-by: Bryan O'Donoghue Signed-off-by: Hans de Goede --- 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 908a4752117b..21f36d16ed1e 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 Fri Dec 20 14:41:24 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: 852665 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 D9E9E218828 for ; Fri, 20 Dec 2024 14:41:56 +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=1734705718; cv=none; b=B2WM5ELb9USfLmzNaWywK6YBBUuK1+f4uMjYWLGLffeFDScjOA4VUIcPKnlMwC1Kx80LlDCXdYKqeKh/2l6lFQ7FhIHkoYROkYjwvBYmUJ8UCYsPNpwwXcVHqDzPmWSKRnAx3C95uCkgW8jqnBLA3MyffB9KtW5a4fi7GIZtJNs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734705718; c=relaxed/simple; bh=Lqo8npuMKZ6VyG1lnHGsmw7FhIF2X/8NgZQCySVY4bk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HgyP0jQEWEuH44DmjxsOewVqrFnHSo5Iq0udG9PTyithEsKIsNEmJui3AbKsWCESocEoO2FNFE/o7euA7ilSNH3wTaVFroR32zuWz+UG7fdADygRMXnvjZLcbzL/fTYjPOc6KQG6i/qBUwh268u9NXJxpNiIMd9RxWIXyhS2de8= 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=YYcr1zIO; 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="YYcr1zIO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734705715; 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=qwlPUwb4AcwGNEUf/ODdOOrdvyeeiwL0rnMx6NwfYz4=; b=YYcr1zIOkkfCZY0LV8wphno5NGyt94DQp4+Nh4MEsV/LiJQbaLcA8zf8zR66RO7ktuQNwt oi44UYr2VtOKHxAIc3H0BAwZZVbfv38Fn9WVGCzWBdb24gdlLqZVQn5MikUBwfWpiEz71S q/kOiPjkxCFvewwXDvXYDKLU1Qnb93k= 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-376-aeS2jYIGPbK4glRKwhi9Xw-1; Fri, 20 Dec 2024 09:41:51 -0500 X-MC-Unique: aeS2jYIGPbK4glRKwhi9Xw-1 X-Mimecast-MFC-AGG-ID: aeS2jYIGPbK4glRKwhi9Xw Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 3ADF519560B6; Fri, 20 Dec 2024 14:41:50 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.193.74]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 733EA19560AD; Fri, 20 Dec 2024 14:41: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 v2 04/10] media: ov08x40: Get clock on ACPI platforms too Date: Fri, 20 Dec 2024 15:41:24 +0100 Message-ID: <20241220144130.66765-5-hdegoede@redhat.com> In-Reply-To: <20241220144130.66765-1-hdegoede@redhat.com> References: <20241220144130.66765-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.40 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. Tested-by: Bryan O'Donoghue Signed-off-by: Hans de Goede --- 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 21f36d16ed1e..a01c5333ce6e 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 Fri Dec 20 14:41:27 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: 852664 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 EF4BA2185A4 for ; Fri, 20 Dec 2024 14:42:01 +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=1734705723; cv=none; b=QWwcoNColMXeELFhROwIfmjPviPajKWLZCqmpogr3zD8vODGZdQlaHTTysrDhzSnFfJDEI80f6l9Jadc7TyRbWPXcalL9yiPrGD2q8we5Em17Cs/5OHOo1uefLLPyCQYFFvxEGFwKr+W211SMT/Pnf0N09MRtKizcdXUEcYiteQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734705723; c=relaxed/simple; bh=snSjHXnZpNhsDn2iUZ4O6a4vEzqQsA6t/Gi4s6XkoHE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q9j+1UoCtcmaz0YlYgnm+5klNG/njpC5pzwo8s4aiBSRWf5gfvfFZUlwdW1xddYEri+dzHkH5bkKJpCdmvu9OzO7Y/X0UL9Mv6VhwTJ8GTO5orNHZaLyqL1FKDHJVTLmfzodn7+8tkvfZf2xh+EYL2ZqOyuETkKJFD4G7j+dgLs= 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=ThIC7h83; 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="ThIC7h83" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734705721; 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=r2eBgYZUkWOHjCvjJbUprRewqayE/iArLk0RD3FHKkc=; b=ThIC7h83ae8yKCUDPtLm7ywWJBznGjmkHm3bYKPFMzBIpw+ggcPoaULOZ4QJhAD2YcUaWe SyjZnlfrtcFf+ZhpjS75kjbux++vRZYedBID5dpmkTmTp33VX1x53SA8Np5su9YuN3ll9s jZ73+bT4HJ8Q1uR+qF/D/fBpqTQyetw= 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-125-KALhif2vPJet5iy1Kez_SQ-1; Fri, 20 Dec 2024 09:41:57 -0500 X-MC-Unique: KALhif2vPJet5iy1Kez_SQ-1 X-Mimecast-MFC-AGG-ID: KALhif2vPJet5iy1Kez_SQ Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 A6DC41955F42; Fri, 20 Dec 2024 14:41:56 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.193.74]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E6BAB19560AD; Fri, 20 Dec 2024 14:41: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 v2 07/10] media: ov08x40: Improve ov08x40_[read|write]_reg() error returns Date: Fri, 20 Dec 2024 15:41:27 +0100 Message-ID: <20241220144130.66765-8-hdegoede@redhat.com> In-Reply-To: <20241220144130.66765-1-hdegoede@redhat.com> References: <20241220144130.66765-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.40 Improve ov08x40_[read|write]_reg() error returns, if we got an errno value from the I2C core use that instead of always returning -EIO. Tested-by: Bryan O'Donoghue Signed-off-by: Hans de Goede --- 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 10ec9896ca61..39430528f54f 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 Fri Dec 20 14:41:29 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: 852663 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 E9A2B21885F for ; Fri, 20 Dec 2024 14:42:04 +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=1734705726; cv=none; b=TYKevH6hUeSE8PbkH+4+kDzMXFv+hKNKrpc5B1y+V5/ZjST6XBSFKH6iFl8b33fkCEElVhgWrITMEAX/1Gi4w9h9Qi+sYJL9BtqaCnMHAf9bROYcFCJ9r7Mz6NT+Jqm0HCav9zgYhBsaygDKRFustkQz/PJ/LbYEZoaqrGw+NTY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734705726; c=relaxed/simple; bh=wLOkJd4R7+1SKUDUR0U5ABL5bDe4gnxLtsTkYNWdU30=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FTrnGZgMZ4BQIL9/TYoZW3Ywqo9DZ86RKKtSsf9vIp5JzJUjepclkxOBGV4OxII4TDbE/ypcHrMj8ZEPeMz7qOBwtt0Mlj/r4h4XybSiqRJqSSEAWZ7nbWJx/+014gbsO7Fdz/I/uQN+jjVJYO0q9SYyou2D07t5ludlUFTNGTg= 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=HbZbJ9Fa; 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="HbZbJ9Fa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734705724; 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=bkvQTbRa8pWhTHpELJKs1/AvJz910487S2ItXLxGCzQ=; b=HbZbJ9FaZJQWaqc+Ybn8s5naCgHi273K/OZ2+KawbuF3WBfdXeyMZK/81NAcNqkpv5/pE4 ZgTPmD5kS2ypAM9yoc0G/niVO/JWvYFZ0S9g2jSEzBAxhsGJSefA2NFgbbTlHE3se0QX0+ L3bUTrsHzMC1GYDOxN839/yMa/7RQSI= 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-467-kWsIAN8BPmi4o9yY5Mjaxg-1; Fri, 20 Dec 2024 09:42:02 -0500 X-MC-Unique: kWsIAN8BPmi4o9yY5Mjaxg-1 X-Mimecast-MFC-AGG-ID: kWsIAN8BPmi4o9yY5Mjaxg Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 25DBE195609D; Fri, 20 Dec 2024 14:42:01 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.193.74]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4D9BD19560AD; Fri, 20 Dec 2024 14:41: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 v2 09/10] media: ov08x40: Add missing '\n' to ov08x40_check_hwcfg() error messages Date: Fri, 20 Dec 2024 15:41:29 +0100 Message-ID: <20241220144130.66765-10-hdegoede@redhat.com> In-Reply-To: <20241220144130.66765-1-hdegoede@redhat.com> References: <20241220144130.66765-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.40 A number of dev_err() error messages miss a terminating '\n', add the missing '\n' to these. Signed-off-by: Hans de Goede --- drivers/media/i2c/ov08x40.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c index 7d00740222c1..e7012ee84822 100644 --- a/drivers/media/i2c/ov08x40.c +++ b/drivers/media/i2c/ov08x40.c @@ -2194,27 +2194,27 @@ static int ov08x40_check_hwcfg(struct ov08x40 *ov08x, struct device *dev) ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency", &xvclk_rate); if (ret) { - dev_err(dev, "can't get clock frequency"); + dev_err(dev, "can't get clock frequency\n"); goto out_err; } } if (xvclk_rate != OV08X40_XVCLK) { - dev_err(dev, "external clock %d is not supported", + dev_err(dev, "external clock %d is not supported\n", xvclk_rate); ret = -EINVAL; goto out_err; } if (bus_cfg.bus.mipi_csi2.num_data_lanes != OV08X40_DATA_LANES) { - dev_err(dev, "number of CSI2 data lanes %d is not supported", + dev_err(dev, "number of CSI2 data lanes %d is not supported\n", bus_cfg.bus.mipi_csi2.num_data_lanes); ret = -EINVAL; goto out_err; } if (!bus_cfg.nr_of_link_frequencies) { - dev_err(dev, "no link frequencies defined"); + dev_err(dev, "no link frequencies defined\n"); ret = -EINVAL; goto out_err; } @@ -2227,7 +2227,7 @@ static int ov08x40_check_hwcfg(struct ov08x40 *ov08x, struct device *dev) } if (j == bus_cfg.nr_of_link_frequencies) { - dev_err(dev, "no link frequency %lld supported", + dev_err(dev, "no link frequency %lld supported\n", link_freq_menu_items[i]); ret = -EINVAL; goto out_err; @@ -2252,7 +2252,7 @@ static int ov08x40_probe(struct i2c_client *client) /* Check HW config */ ret = ov08x40_check_hwcfg(ov08x, &client->dev); if (ret) { - dev_err(&client->dev, "failed to check hwcfg: %d", ret); + dev_err(&client->dev, "failed to check hwcfg: %d\n", ret); return ret; }