From patchwork Sun Jan 29 02:34:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 648432 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 2D676C61DA4 for ; Sun, 29 Jan 2023 02:34:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233641AbjA2Ces (ORCPT ); Sat, 28 Jan 2023 21:34:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234382AbjA2Cep (ORCPT ); Sat, 28 Jan 2023 21:34:45 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87A2E233DD for ; Sat, 28 Jan 2023 18:34:44 -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 87142FE8; Sun, 29 Jan 2023 03:34:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1674959682; bh=gxeXGrKdiZbwcQszKCnIUXsMb5XT/hlCD79EmxriPFU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KGQ/XVM8pnlneYqQTXjhTZF4hWNDFkIoeHD5Wu4PPLZacI2xYtAZPLeKvG97Y8Bj6 QSPlz6WhVkcQPglL4u4qEN8bO10qQhWdy5VEbmPbcPIgsA0PI/VgIaRPOtcW4dVq2E 5xpktnb2yIC6OkRkIePgDctw8aEUIFc2STxX8+cE= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Adam Ford , Martin Kepplinger , Paul Elder , Rui Miguel Silva , kernel@pengutronix.de, linux-imx@nxp.com Subject: [PATCH v2 6/8] media: imx: imx7-media-csi: Cleanup errors in imx7_csi_async_register() Date: Sun, 29 Jan 2023 04:34:27 +0200 Message-Id: <20230129023429.22467-7-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230129023429.22467-1-laurent.pinchart@ideasonboard.com> References: <20230129023429.22467-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org It's good practice for functions to perform error cleanup internally when they fail, in order to not leave the device in a half-initialized state. Move the async notifier cleanup from the probe error path to the imx7_csi_async_register(), and drop the v4l2_async_nf_unregister() call as there is no error path after the async notifier gets registered. Signed-off-by: Laurent Pinchart --- drivers/media/platform/nxp/imx7-media-csi.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c index 1adf5c3392d9..733e44700ff9 100644 --- a/drivers/media/platform/nxp/imx7-media-csi.c +++ b/drivers/media/platform/nxp/imx7-media-csi.c @@ -2177,7 +2177,7 @@ static int imx7_csi_async_register(struct imx7_csi *csi) ret = PTR_ERR(asd); /* OK if asd already exists */ if (ret != -EEXIST) - return ret; + goto error; } } @@ -2185,9 +2185,13 @@ static int imx7_csi_async_register(struct imx7_csi *csi) ret = v4l2_async_nf_register(&csi->v4l2_dev, &csi->notifier); if (ret) - return ret; + goto error; return 0; + +error: + v4l2_async_nf_cleanup(&csi->notifier); + return ret; } static void imx7_csi_media_cleanup(struct imx7_csi *csi) @@ -2329,13 +2333,10 @@ static int imx7_csi_probe(struct platform_device *pdev) ret = imx7_csi_async_register(csi); if (ret) - goto subdev_notifier_cleanup; + goto media_cleanup; return 0; -subdev_notifier_cleanup: - v4l2_async_nf_unregister(&csi->notifier); - v4l2_async_nf_cleanup(&csi->notifier); media_cleanup: imx7_csi_media_cleanup(csi);