From patchwork Fri Sep 9 13:39:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 12971802 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C8302ECAAA1 for ; Fri, 9 Sep 2022 13:42:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uX4+MXJWLS1UWrZ7uqxgvSuY47esLIl2FGm8PEU9IcE=; b=GnBHAzqBvIhhVg FRdsgSVhJOI/MJBzoaz4TwPVXXifVqhjLl2dVzpD9LNEe5LyM84jXmEzTBpVA0RWxpllhIfGEXyeA 6gywF4KFy4dN7thbcxL+zBbqg+RzqcknZxUsEhPWs5JyQN3Vyi3gXCFj/NsS2j974AuWQ0BczvB5I Mm9GlMVB05oRB/Vsi9fpSZkWg5aYwtCC0Rd1PmKd2EqcPKE81r70Uu81VrFsEmDo4ofhes5GRdGdu bvkbc6dNtqDICLxeEv5TVVl3phnjSCUazKjIafi+kOT9XqVW/CMCPl9tlXQfbs5BP3yKpKq6boPCd 38KXLiJCsBTG/sdcmUFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oWeFl-00GNiX-B3; Fri, 09 Sep 2022 13:41:05 +0000 Received: from relay5-d.mail.gandi.net ([217.70.183.197]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oWeFG-00GNXw-CM for linux-arm-kernel@lists.infradead.org; Fri, 09 Sep 2022 13:40:36 +0000 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220909_064034_707283_9E6582E8 X-CRM114-Status: GOOD ( 16.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 controller") 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_mipi_csi2_device *csi2_dev) struct v4l2_async_notifier *notifier = &bridge->notifier; struct media_pad *pads = bridge->pads; struct device *dev = csi2_dev->dev; + bool notifier_registered = false; int ret; mutex_init(&bridge->lock); @@ -535,12 +536,17 @@ static int sun6i_mipi_csi2_bridge_setup(struct sun6i_mipi_csi2_device *csi2_dev) notifier->ops = &sun6i_mipi_csi2_notifier_ops; ret = sun6i_mipi_csi2_bridge_source_setup(csi2_dev); - if (ret) + if (ret && ret != -ENODEV) goto error_v4l2_notifier_cleanup; - ret = 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 != -ENODEV) { + ret = v4l2_async_subdev_nf_register(subdev, notifier); + if (ret < 0) + goto error_v4l2_notifier_cleanup; + + notifier_registered = true; + } /* V4L2 Subdev */ @@ -551,7 +557,8 @@ static int sun6i_mipi_csi2_bridge_setup(struct sun6i_mipi_csi2_device *csi2_dev) return 0; error_v4l2_notifier_unregister: - v4l2_async_nf_unregister(notifier); + if (notifier_registered) + v4l2_async_nf_unregister(notifier); error_v4l2_notifier_cleanup: v4l2_async_nf_cleanup(notifier);