From nobody Wed Apr 8 14:46:28 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31853ECAAD3 for ; Fri, 9 Sep 2022 13:41:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231494AbiIINl2 (ORCPT ); Fri, 9 Sep 2022 09:41:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230408AbiIINkl (ORCPT ); Fri, 9 Sep 2022 09:40:41 -0400 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4813B9C52B; Fri, 9 Sep 2022 06:40:34 -0700 (PDT) Received: (Authenticated sender: paul.kocialkowski@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 405B21C0002; Fri, 9 Sep 2022 13:40:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1662730833; 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=ZerUL4Gdisb2y9R2p//xDrZ6J/om1/Cqv1NWlhDE1r0=; b=SStNj42S1NJs6+iKh8x8tOPS+CgWTGDLxl2w3+iLzSnti4UpfHViowxfZ2C+dP8FbPuJId xRgWYeAjZ3QD89dNItbMtMg9VhwlTTLyrzdfXoM2F6QZgDCadtZXK83Po/iLeu1D4fmZ9O MfyKHZYA9A71qvgx/5EIIEvWMFhEKn+migqRzSFljVMTx8bPtPfSn8chwEpBenx9Aizfs0 axkMmCz/sZiojdgqxEXA4wBCKQa4hljMGWRuEOJ/uShcKrhbZQx5VoUBs09qvljoE6Nvmg sw2yAK9sS73dec9J4sZ6bhROFGA/JE6eWww1+1kvr+catp8vgnePO0hw2G6ZHA== From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Cc: Paul Kocialkowski , Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Hans Verkuil , Maxime Ripard , Thomas Petazzoni , Laurent Pinchart Subject: [PATCH 3/4] media: sun6i-mipi-csi2: Register async subdev with no sensor attached Date: Fri, 9 Sep 2022 15:39:53 +0200 Message-Id: <20220909133954.97010-4-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220909133954.97010-1-paul.kocialkowski@bootlin.com> References: <20220909133954.97010-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This allows the device to probe and register its async subdev without a sensor attached. The rationale is that the parent driver might otherwise wait for the subdev to be registered when it should be available (from the fwnode graph endpoint perspective). This is generally not problematic when the MIPI CSI-2 bridge is the only device attached to the parent, but in the case of a CSI controller that can feed from both MIPI CSI-2 and parallel, it would prevent using the parallel sensor due to the parent waiting for the MIPI CSI-2 subdev to register. Fixes: af54b4f4c17f ("media: sunxi: Add support for the A31 MIPI CSI-2 cont= roller") Signed-off-by: Paul Kocialkowski --- .../sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c= b/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c index 340380a5f66f..484ac5f054d5 100644 --- a/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c +++ b/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c @@ -498,6 +498,7 @@ static int sun6i_mipi_csi2_bridge_setup(struct sun6i_mi= pi_csi2_device *csi2_dev) struct v4l2_async_notifier *notifier =3D &bridge->notifier; struct media_pad *pads =3D bridge->pads; struct device *dev =3D csi2_dev->dev; + bool notifier_registered =3D false; int ret; =20 mutex_init(&bridge->lock); @@ -535,12 +536,17 @@ static int sun6i_mipi_csi2_bridge_setup(struct sun6i_= mipi_csi2_device *csi2_dev) notifier->ops =3D &sun6i_mipi_csi2_notifier_ops; =20 ret =3D sun6i_mipi_csi2_bridge_source_setup(csi2_dev); - if (ret) + if (ret && ret !=3D -ENODEV) goto error_v4l2_notifier_cleanup; =20 - ret =3D v4l2_async_subdev_nf_register(subdev, notifier); - if (ret < 0) - goto error_v4l2_notifier_cleanup; + /* Only register the notifier when a sensor is connected. */ + if (ret !=3D -ENODEV) { + ret =3D v4l2_async_subdev_nf_register(subdev, notifier); + if (ret < 0) + goto error_v4l2_notifier_cleanup; + + notifier_registered =3D true; + } =20 /* V4L2 Subdev */ =20 @@ -551,7 +557,8 @@ static int sun6i_mipi_csi2_bridge_setup(struct sun6i_mi= pi_csi2_device *csi2_dev) return 0; =20 error_v4l2_notifier_unregister: - v4l2_async_nf_unregister(notifier); + if (notifier_registered) + v4l2_async_nf_unregister(notifier); =20 error_v4l2_notifier_cleanup: v4l2_async_nf_cleanup(notifier); --=20 2.37.3