From patchwork Wed Feb 15 17:16:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frieder Schrempf X-Patchwork-Id: 654325 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 60107C636D4 for ; Wed, 15 Feb 2023 17:17:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230055AbjBORRn (ORCPT ); Wed, 15 Feb 2023 12:17:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229904AbjBORRj (ORCPT ); Wed, 15 Feb 2023 12:17:39 -0500 X-Greylist: delayed 89012 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 15 Feb 2023 09:17:32 PST Received: from mail.fris.de (mail.fris.de [IPv6:2a01:4f8:c2c:390b::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E6CF2DE4C; Wed, 15 Feb 2023 09:17:32 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 4008ABFAEB; Wed, 15 Feb 2023 18:17:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fris.de; s=dkim; t=1676481448; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding; bh=tOQ4GCJqQIcdutDt62TtDCuCrq+2rPI1vsV+AOkH/r8=; b=DphvDi3j8QPey/TUZO9u7AlpSHBaHmKDiQxYftklbw9BLqxiGyluP3FY9rW2lNKHLyMI/Q B1GQpG4K2jXr1+gCme2TKjDXiAE7xRXaS8dVGaRMQ7vkIVyZJtdblYceCuPA7O4kfE6VN/ WMGvvuKEKq9eWE5iEPkpizJwoAnYSoQCK1c6ZdR2Tb4fQRjfc2u6MKZa4nPQP6VL3W8jZE 5KJ6WxM+SsJwGIieBsLb1mh3tTbFmqbMrlodH80A2W6nkjQ5xprId8SBX5V5QZF+HIVLLa o7s/tgILz5lPqUMJ+ZlrB3c7bXctSUTU0AsTuvys0H8j2aeVFF/8Hj6JyBELIA== From: Frieder Schrempf To: Laurent Pinchart , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, Mauro Carvalho Chehab , Rui Miguel Silva , Sascha Hauer , Shawn Guo Cc: Frieder Schrempf , Fabio Estevam , NXP Linux Team , Paul Elder , Pengutronix Kernel Team Subject: [PATCH v2] media: imx: imx7-media-csi: Fix error handling in imx7_csi_async_register() Date: Wed, 15 Feb 2023 18:16:38 +0100 Message-Id: <20230215171642.2122786-1-frieder@fris.de> MIME-Version: 1.0 X-Last-TLS-Session-Version: TLSv1.3 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Frieder Schrempf The CSI requires a connected source subdev to operate. If fwnode_graph_get_endpoint_by_id() fails and returns NULL, there is no point in going on. Print an error message and abort instead. Also we don't need to check for an existing asd. Any failure of v4l2_async_nf_add_fwnode_remote() should abort the probe. Suggested-by: Laurent Pinchart Signed-off-by: Frieder Schrempf --- Changes for v2: * Improve commit message * Use dev_err_probe --- drivers/media/platform/nxp/imx7-media-csi.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c index 886374d3a6ff..76ce6ff2c60a 100644 --- a/drivers/media/platform/nxp/imx7-media-csi.c +++ b/drivers/media/platform/nxp/imx7-media-csi.c @@ -2191,19 +2191,18 @@ static int imx7_csi_async_register(struct imx7_csi *csi) ep = fwnode_graph_get_endpoint_by_id(dev_fwnode(csi->dev), 0, 0, FWNODE_GRAPH_ENDPOINT_NEXT); - if (ep) { - asd = v4l2_async_nf_add_fwnode_remote(&csi->notifier, ep, - struct v4l2_async_subdev); + if (!ep) + return dev_err_probe(csi->dev, -ENOTCONN, + "Failed to get remote endpoint\n"); - fwnode_handle_put(ep); + asd = v4l2_async_nf_add_fwnode_remote(&csi->notifier, ep, + struct v4l2_async_subdev); - if (IS_ERR(asd)) { - ret = PTR_ERR(asd); - /* OK if asd already exists */ - if (ret != -EEXIST) - return ret; - } - } + fwnode_handle_put(ep); + + if (IS_ERR(asd)) + return dev_err_probe(csi->dev, PTR_ERR(asd), + "Failed to add remote subdev to notifier\n"); csi->notifier.ops = &imx7_csi_notify_ops;