From patchwork Fri Nov 17 09:16:58 2023 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: 13458564 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 C87D7C5AD4C for ; Fri, 17 Nov 2023 09:17:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234605AbjKQJRb (ORCPT ); Fri, 17 Nov 2023 04:17:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229927AbjKQJRb (ORCPT ); Fri, 17 Nov 2023 04:17:31 -0500 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6552D4D for ; Fri, 17 Nov 2023 01:17:27 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r3uyP-0007gP-QB; Fri, 17 Nov 2023 10:17:13 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r3uyP-009e6A-CX; Fri, 17 Nov 2023 10:17:13 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1r3uyP-002yJb-3L; Fri, 17 Nov 2023 10:17:13 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Cc: Siddharth Vadapalli , Ravi Gunasekaran , Roger Quadros , Simon Horman , Yunsheng Lin , Stanislav Fomichev , Marek Majtyka , Rob Herring , Mugunthan V N , linux-omap@vger.kernel.org, netdev@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH 2/7] net: ethernet: ti: cpsw: Don't error out in .remove() Date: Fri, 17 Nov 2023 10:16:58 +0100 Message-ID: <20231117091655.872426-3-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.42.0.586.gbc5204569f7d.dirty In-Reply-To: <20231117091655.872426-1-u.kleine-koenig@pengutronix.de> References: <20231117091655.872426-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1891; i=u.kleine-koenig@pengutronix.de; h=from:subject; bh=mRlxVGBjOW+sHBqJcFFxN2V+8op/8Ztc44BTgG2kkTc=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlVy+JX7JX54FLhK+Ph4PRFjYhrozP75HV5r1Hh eI54zRdHrCJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZVcviQAKCRCPgPtYfRL+ TukvCAClEeHXl2S3JJqY2Bxwz4qdVHZrIaNBphbJm/tByatOnJypsqbGilBmtS8u4DOJ+9JdsST /40Lod7dQZ432LRW1PomY92egZ5iSekSFW+KE12uA1lhufDdNlc/fZNoHbnaa7t3v6cpV2n1OUc T1Qe5rWHW1XM5Ak6pT7CsxFKqZKX8mZykXfcqriVvKO8hgJjTLkybTWZQwMccbuPDy5oNYxK0Da ipSgmSTQ225CTGdMswUGhsAZjspi9R0T22vUikLBqY/vyxx6+fzrc+wV6xBfGYEETdRVNWJMQJo jgwiZUGJGJl6mMSy4Sh8UJAcq7Z04ffRmlWOK5XeEGrrK5ex X-Developer-Key: i=u.kleine-koenig@pengutronix.de; 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-omap@vger.kernel.org To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Returning early from .remove() with an error code still results in the driver unbinding the device. So the driver core ignores the returned error code and the resources that were not freed are never catched up. In combination with devm this also often results in use-after-free bugs. If runtime resume fails, it's still important to free all resources, so don't return with an error code, but emit an error message and continue freeing acquired stuff. This prepares changing cpsw_remove() to return void. Fixes: 8a0b6dc958fd ("drivers: net: cpsw: fix wrong regs access in cpsw_remove") Signed-off-by: Uwe Kleine-König --- drivers/net/ethernet/ti/cpsw.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index ca4d4548f85e..db5a2ba8a6d4 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -1727,16 +1727,24 @@ static int cpsw_remove(struct platform_device *pdev) struct cpsw_common *cpsw = platform_get_drvdata(pdev); int i, ret; - ret = pm_runtime_resume_and_get(&pdev->dev); + ret = pm_runtime_get_sync(&pdev->dev); if (ret < 0) - return ret; + /* There is no need to do something about that. The important + * thing is to not exit early, but do all cleanup that doesn't + * require register access. + */ + dev_err(&pdev->dev, "runtime resume failed (%pe)\n", + ERR_PTR(ret)); for (i = 0; i < cpsw->data.slaves; i++) if (cpsw->slaves[i].ndev) unregister_netdev(cpsw->slaves[i].ndev); - cpts_release(cpsw->cpts); - cpdma_ctlr_destroy(cpsw->dma); + if (ret >= 0) { + cpts_release(cpsw->cpts); + cpdma_ctlr_destroy(cpsw->dma); + } + cpsw_remove_dt(pdev); pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); From patchwork Fri Nov 17 09:16:59 2023 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: 13458562 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 C9EEEC072A2 for ; Fri, 17 Nov 2023 09:17:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230264AbjKQJR3 (ORCPT ); Fri, 17 Nov 2023 04:17:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229927AbjKQJR2 (ORCPT ); Fri, 17 Nov 2023 04:17:28 -0500 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65B67D4F for ; Fri, 17 Nov 2023 01:17:25 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r3uyQ-0007gT-3E; Fri, 17 Nov 2023 10:17:14 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r3uyP-009e6D-Je; Fri, 17 Nov 2023 10:17:13 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1r3uyP-002yJf-AC; Fri, 17 Nov 2023 10:17:13 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Cc: Siddharth Vadapalli , Ravi Gunasekaran , Roger Quadros , Alexei Starovoitov , Marek Majtyka , Gerhard Engleder , Rob Herring , Yunsheng Lin , Ilias Apalodimas , linux-omap@vger.kernel.org, netdev@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH 3/7] net: ethernet: ti: cpsw-new: Don't error out in .remove() Date: Fri, 17 Nov 2023 10:16:59 +0100 Message-ID: <20231117091655.872426-4-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.42.0.586.gbc5204569f7d.dirty In-Reply-To: <20231117091655.872426-1-u.kleine-koenig@pengutronix.de> References: <20231117091655.872426-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1910; i=u.kleine-koenig@pengutronix.de; h=from:subject; bh=pRqqeKcdhQwzz3WqDYFX15m8Wmx7j6+SSxzjpB2PRHA=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlVy+L5i60+g5zCFQoR9XpwdVxPzWS+SXuTSSRr /z0vzxzteGJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZVcviwAKCRCPgPtYfRL+ TupxB/44enSu4ws7zGlfVg6j+hGHF9PYcDHYkCgI3BqHLGROmcy13aQSxslOviwXJLo0y4t1b7G MlzxL95ycnY4mlQptJiZ1+ahqS1/iO4aoZw1d2OiLFly8dUWiw6FcIM435EWjKCoDjUjx5oam7e cCFty+Zc7wxIM1con2yuwanbB0+lB3GoqIF7TwUEn5k3lRxcrclmc6ECPBd5Eio4GBtW7x1w5d+ hVIs7knzwXHyRDDdD6frYUYncPr3nZSSb6p2LhNTQXQuRSmMxwbDV9scRwdsJ9GB0nfIRjc+Svb PF3kQDLWMoItthCIMaer1+UUwaZ8+V+2mNMnvIrBRZ0kusXm X-Developer-Key: i=u.kleine-koenig@pengutronix.de; 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-omap@vger.kernel.org To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Returning early from .remove() with an error code still results in the driver unbinding the device. So the driver core ignores the returned error code and the resources that were not freed are never catched up. In combination with devm this also often results in use-after-free bugs. If runtime resume fails, it's still important to free all resources, so don't return with an error code, but emit an error message and continue freeing acquired stuff. This prepares changing cpsw_remove() to return void. Fixes: ed3525eda4c4 ("net: ethernet: ti: introduce cpsw switchdev based driver part 1 - dual-emac") Signed-off-by: Uwe Kleine-König Acked-by: Ilias Apalodimas --- drivers/net/ethernet/ti/cpsw_new.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/ti/cpsw_new.c b/drivers/net/ethernet/ti/cpsw_new.c index 0e4f526b1753..a6ce409f563c 100644 --- a/drivers/net/ethernet/ti/cpsw_new.c +++ b/drivers/net/ethernet/ti/cpsw_new.c @@ -2042,16 +2042,24 @@ static int cpsw_remove(struct platform_device *pdev) struct cpsw_common *cpsw = platform_get_drvdata(pdev); int ret; - ret = pm_runtime_resume_and_get(&pdev->dev); + ret = pm_runtime_get_sync(&pdev->dev); if (ret < 0) - return ret; + /* There is no need to do something about that. The important + * thing is to not exit early, but do all cleanup that doesn't + * requrie register access. + */ + dev_err(&pdev->dev, "runtime resume failed (%pe)\n", + ERR_PTR(ret)); cpsw_unregister_notifiers(cpsw); cpsw_unregister_devlink(cpsw); cpsw_unregister_ports(cpsw); - cpts_release(cpsw->cpts); - cpdma_ctlr_destroy(cpsw->dma); + if (ret >= 0) { + cpts_release(cpsw->cpts); + cpdma_ctlr_destroy(cpsw->dma); + } + cpsw_remove_dt(cpsw); pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); From patchwork Fri Nov 17 09:17:01 2023 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: 13458563 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 AB941C54FB9 for ; Fri, 17 Nov 2023 09:17:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231461AbjKQJRa (ORCPT ); Fri, 17 Nov 2023 04:17:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229927AbjKQJR3 (ORCPT ); Fri, 17 Nov 2023 04:17:29 -0500 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A958AD4D for ; Fri, 17 Nov 2023 01:17:26 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r3uyQ-0007go-Cg; Fri, 17 Nov 2023 10:17:14 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r3uyP-009e6K-VG; Fri, 17 Nov 2023 10:17:13 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1r3uyP-002yJm-Lp; Fri, 17 Nov 2023 10:17:13 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Cc: Siddharth Vadapalli , Ravi Gunasekaran , Roger Quadros , Kumar Kartikeya Dwivedi , Stanislav Fomichev , Jesse Brandeburg , Rob Herring , Marek Majtyka , Yunsheng Lin , linux-omap@vger.kernel.org, netdev@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH 5/7] net: ethernet: ti: cpsw: Convert to platform remove callback returning void Date: Fri, 17 Nov 2023 10:17:01 +0100 Message-ID: <20231117091655.872426-6-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.42.0.586.gbc5204569f7d.dirty In-Reply-To: <20231117091655.872426-1-u.kleine-koenig@pengutronix.de> References: <20231117091655.872426-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1796; i=u.kleine-koenig@pengutronix.de; h=from:subject; bh=AFKDccbj7KVdxjjm+VYAVvkLNk+QVUxW4yHwNz8tuIk=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlVy+NZdmjkLIHdK9BlhoRLimmKKlCp9u4QgTvO U4IA9g8McKJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZVcvjQAKCRCPgPtYfRL+ TmzTCACjfDNtDbr7jWf/bK3FdYpzjXe3NGiGaYQkDmMiHeJklBWV5YfyXhySfGfDwfn6/kByk1L FsQTyBkgjhWqg3litFcmmp2v4bZ6zhuHKBPK1d91jIDRynghs1FLRjb0VZVO9niobQ4IRnJiIe8 797ndA1BXRrIXtUSXbnvXL0xDCqTh53aonpd+xEunoRcZrH2cDCTh3R3Kpj/yUGxq9rcWU9/n0O 1TieUdd3ytdNoXiGdx+VBfJb8ufNNnU8rCyRvq2LJaD9k8aG3jE2r4+bnowNfi5A5mz5xAvf6mE RHBAwkv+zKVE2+scpU+923PrB7RPKSgVg+nI8tQZ4/iv8xhb X-Developer-Key: i=u.kleine-koenig@pengutronix.de; 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-omap@vger.kernel.org To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new(), which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove(). Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König Reviewed-by: Roger Quadros --- drivers/net/ethernet/ti/cpsw.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index db5a2ba8a6d4..ed29a76420f8 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -1722,7 +1722,7 @@ static int cpsw_probe(struct platform_device *pdev) return ret; } -static int cpsw_remove(struct platform_device *pdev) +static void cpsw_remove(struct platform_device *pdev) { struct cpsw_common *cpsw = platform_get_drvdata(pdev); int i, ret; @@ -1748,7 +1748,6 @@ static int cpsw_remove(struct platform_device *pdev) cpsw_remove_dt(pdev); pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); - return 0; } #ifdef CONFIG_PM_SLEEP @@ -1803,7 +1802,7 @@ static struct platform_driver cpsw_driver = { .of_match_table = cpsw_of_mtable, }, .probe = cpsw_probe, - .remove = cpsw_remove, + .remove_new = cpsw_remove, }; module_platform_driver(cpsw_driver); From patchwork Fri Nov 17 09:17:02 2023 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: 13458565 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 53067C072A2 for ; Fri, 17 Nov 2023 09:17:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235036AbjKQJRd (ORCPT ); Fri, 17 Nov 2023 04:17:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229927AbjKQJRd (ORCPT ); Fri, 17 Nov 2023 04:17:33 -0500 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 676F0D52 for ; Fri, 17 Nov 2023 01:17:29 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r3uyQ-0007h4-QU; Fri, 17 Nov 2023 10:17:14 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r3uyQ-009e6N-5q; Fri, 17 Nov 2023 10:17:14 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1r3uyP-002yJr-Sc; Fri, 17 Nov 2023 10:17:13 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Cc: Siddharth Vadapalli , Ravi Gunasekaran , Roger Quadros , Alexander Duyck , Jesse Brandeburg , Yunsheng Lin , Marek Majtyka , Rob Herring , linux-omap@vger.kernel.org, netdev@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH 6/7] net: ethernet: ti: cpsw-new: Convert to platform remove callback returning void Date: Fri, 17 Nov 2023 10:17:02 +0100 Message-ID: <20231117091655.872426-7-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.42.0.586.gbc5204569f7d.dirty In-Reply-To: <20231117091655.872426-1-u.kleine-koenig@pengutronix.de> References: <20231117091655.872426-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1849; i=u.kleine-koenig@pengutronix.de; h=from:subject; bh=okHKw25VgeWUFYd2avv49A8Ij4U9Ek22DOHwr9QInRk=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlVy+O5ufeBrybGQ4s7etDKUNLrzfUTroyU7BIJ Q4jDiTBQjmJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZVcvjgAKCRCPgPtYfRL+ TioUB/9Eq9iqGQQqxO6fiyfaAtVw3VnJaTfd8xxeA1755kDQYDpapiyDmxLZ7tXAoaN+/bhG70V hSHv5bbmTMhLHi4zsn/tv+OCjEQ8ZkrIhvCTMqOh3i6gQIjztb96NDuIKNFzL76OXr2yR+Rhbj7 3eCKKP9//kXnNod+6Pno1ZFwS/e2bzHBkHnZcZDQvxajTCbgBWwu6ZWGrISxu+h4+pXk/DO8/qM 2fiBCoQNxQPBgAY5bWygbAOay5YzzyvKPoGB+r5aYQNkey8mcF6S6GpEaBdB6iSV/ctJ0LlKB9L bM8EeF0L3xTLJh6efd6Bpksx7rSp8LBIODlG7tk91GvqZuNf X-Developer-Key: i=u.kleine-koenig@pengutronix.de; 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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-omap@vger.kernel.org To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new(), which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove(). Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König Reviewed-by: Roger Quadros --- drivers/net/ethernet/ti/cpsw_new.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/ti/cpsw_new.c b/drivers/net/ethernet/ti/cpsw_new.c index a6ce409f563c..dae8d0203021 100644 --- a/drivers/net/ethernet/ti/cpsw_new.c +++ b/drivers/net/ethernet/ti/cpsw_new.c @@ -2037,7 +2037,7 @@ static int cpsw_probe(struct platform_device *pdev) return ret; } -static int cpsw_remove(struct platform_device *pdev) +static void cpsw_remove(struct platform_device *pdev) { struct cpsw_common *cpsw = platform_get_drvdata(pdev); int ret; @@ -2063,7 +2063,6 @@ static int cpsw_remove(struct platform_device *pdev) cpsw_remove_dt(cpsw); pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); - return 0; } static int __maybe_unused cpsw_suspend(struct device *dev) @@ -2124,7 +2123,7 @@ static struct platform_driver cpsw_driver = { .of_match_table = cpsw_of_mtable, }, .probe = cpsw_probe, - .remove = cpsw_remove, + .remove_new = cpsw_remove, }; module_platform_driver(cpsw_driver);