From mboxrd@z Thu Jan 1 00:00:00 1970 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 5434DC636D4 for ; Wed, 15 Feb 2023 17:26:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230072AbjBOR0u (ORCPT ); Wed, 15 Feb 2023 12:26:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230056AbjBOR0r (ORCPT ); Wed, 15 Feb 2023 12:26:47 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E99713A86B; Wed, 15 Feb 2023 09:26:29 -0800 (PST) Received: from pendragon.ideasonboard.com (213-243-189-158.bb.dnainternet.fi [213.243.189.158]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 69F2425E; Wed, 15 Feb 2023 18:26:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1676481987; bh=SxkvjF5LPJ3U8784zKitL4PQRcqzkRD/JLzq6HKfh74=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YLiJgMLEwTuOuuuORFNyDJe30GhMzqEqzMnZIcBvqVkKSY64GQyGbkc5qqvMAHfwR g64JXkZFWM4Usls8tbBc+Udl4D8S6fyGjQZOVFIN6s1biCA60vAj//SN6Nzj6j26gR iOmNiFTsXmi4pLF+7Dy9P5Z4u1E5R8U+ECs/R9No= Date: Wed, 15 Feb 2023 19:26:26 +0200 From: Laurent Pinchart To: Frieder Schrempf Cc: 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 , Frieder Schrempf , Fabio Estevam , NXP Linux Team , Paul Elder , Pengutronix Kernel Team Subject: Re: [PATCH v2] media: imx: imx7-media-csi: Fix error handling in imx7_csi_async_register() Message-ID: References: <20230215171642.2122786-1-frieder@fris.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230215171642.2122786-1-frieder@fris.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Frieder, Thank you for the patch. On Wed, Feb 15, 2023 at 06:16:38PM +0100, Frieder Schrempf wrote: > 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 Reviewed-by: Laurent Pinchart > --- > 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; > -- Regards, Laurent Pinchart