From patchwork Fri Jun 3 21:07:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 12869411 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 3BECBC43334 for ; Fri, 3 Jun 2022 21:09:38 +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=Hn9kEnnG6lnCtjWRylxUP/1zeoyLydJADBPPFiIkM18=; b=oXw1o3yD0Mjx87 Sza5qPU0vO5WGm9GnZ5nhppHJZV84XZOlKRSE6J2BlTSXb65t4/7mHLCNW87a7WLRexhqi6dZCLqj +6uo0E9rRVkDZP+GKTAIWii8f+T2Ph8fxy6ScE8ReAqzeQPGakRzHLJ05LYzX6TiLPfev1P+zlRkd 3ADdm1uKu04G6T8rRE4XFsP3wYNiUgS3pNAxy0USz5c+5qZjE/h8fh8Bb+CeUpJi141BUiJJ96+jg jelfyoCDyLVoe0hy6pAIMG4+rhARhDUrTcFt7KO8NbyFj15CJ7lbrm9x5u1PXG3PD9jbEqBVG5Nqd FfY4x7u8puGNcV9JYaGg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nxEXz-008hsD-Jp; Fri, 03 Jun 2022 21:09:31 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nxEWr-008h1Z-FD for linux-amlogic@lists.infradead.org; Fri, 03 Jun 2022 21:08:22 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nxEWe-0003rQ-M1; Fri, 03 Jun 2022 23:08:08 +0200 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1nxEWd-006HqT-NF; Fri, 03 Jun 2022 23:08:06 +0200 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1nxEWb-00E1Hi-D0; Fri, 03 Jun 2022 23:08:05 +0200 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Liang Yang , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Neil Armstrong , Kevin Hilman Cc: kernel@pengutronix.de, Jerome Brunet , Martin Blumenstingl , linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org Subject: [PATCH 11/14] mtd: rawnand: meson: Don't skip cleanup after mtd_device_unregister() failed Date: Fri, 3 Jun 2022 23:07:55 +0200 Message-Id: <20220603210758.148493-12-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220603210758.148493-1-u.kleine-koenig@pengutronix.de> References: <20220603210758.148493-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2079; i=uwe@kleine-koenig.org; h=from:subject; bh=RARxTiaUJYu4OZ6zHphWegS1/d3oBvCOapegjJ7Xz2w=; b=owEBbQGS/pANAwAKAcH8FHityuwJAcsmYgBimnfok3XZnM8xPmeh6eqHGnVxhDUlHH6mjDHSnMtj XzhjYlWJATMEAAEKAB0WIQR+cioWkBis/z50pAvB/BR4rcrsCQUCYpp36AAKCRDB/BR4rcrsCR0fB/ 0XtpF397Uz0TI5bccMu6LPI+SY3xLErkAzy0oq/qVB0J5MexcIdYbctHySiybN1IFKvlbgrQ5cupk6 /iaHpfoOmhZNe4gKrjbocltz+mXgT3dn9PpT6NpXq9cuu/BgQ1ie0+ePFymUHBOKmEevSFLL681zvk cMvB5sdiQwojrFzUNQPK2rU/Paveuencs0tKWbOUSX74Gw+QcDtMJQUT67ZQCVuFCZ9+RWrYcWdcl7 J0cg9UgAZ/S/DWHHzIjABKtzbEZ0dp6906yCsINCp+wRhPu0EPRWBZQRpJIuSWw+qR7RVpml+lVjKh gor07c5W15prWMTew+AfkLn/qAwXj7 X-Developer-Key: i=uwe@kleine-koenig.org; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-amlogic@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220603_140821_536780_CBAC7058 X-CRM114-Status: GOOD ( 13.97 ) X-BeenThere: linux-amlogic@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-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org If mtd_device_unregister() fails (which it doesn't when used correctly), the resources bound by the nand chip should be freed anyhow as returning an error value doesn't prevent the device getting unbound. Instead use WARN_ON on the return value similar to how other drivers do it. Then meson_nfc_nand_chip_cleanup() returns 0 unconditionally and can be changed to return void which allows further simplification in the remove callback. This is a preparation for making platform remove callbacks return void. Signed-off-by: Uwe Kleine-König --- drivers/mtd/nand/raw/meson_nand.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c index ac3be92872d0..748e115b0bb7 100644 --- a/drivers/mtd/nand/raw/meson_nand.c +++ b/drivers/mtd/nand/raw/meson_nand.c @@ -1293,26 +1293,21 @@ meson_nfc_nand_chip_init(struct device *dev, return 0; } -static int meson_nfc_nand_chip_cleanup(struct meson_nfc *nfc) +static void meson_nfc_nand_chip_cleanup(struct meson_nfc *nfc) { struct meson_nfc_nand_chip *meson_chip; struct mtd_info *mtd; - int ret; while (!list_empty(&nfc->chips)) { meson_chip = list_first_entry(&nfc->chips, struct meson_nfc_nand_chip, node); mtd = nand_to_mtd(&meson_chip->nand); - ret = mtd_device_unregister(mtd); - if (ret) - return ret; + WARN_ON(mtd_device_unregister(mtd)); meson_nfc_free_buffer(&meson_chip->nand); nand_cleanup(&meson_chip->nand); list_del(&meson_chip->node); } - - return 0; } static int meson_nfc_nand_chips_init(struct device *dev, @@ -1445,11 +1440,8 @@ static int meson_nfc_probe(struct platform_device *pdev) static int meson_nfc_remove(struct platform_device *pdev) { struct meson_nfc *nfc = platform_get_drvdata(pdev); - int ret; - ret = meson_nfc_nand_chip_cleanup(nfc); - if (ret) - return ret; + meson_nfc_nand_chip_cleanup(nfc); meson_nfc_disable_clk(nfc);