Message ID | 20231109202830.4124591-6-u.kleine-koenig@pengutronix.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp690114vqs; Thu, 9 Nov 2023 12:31:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IH+QOewInMJgRCTevPvmc2UZ+rZuvr2N+fo8cbbKX/43/TwlVwYc/ks14RZUrRsNCtlM2Uc X-Received: by 2002:a17:90b:3e88:b0:282:e109:109 with SMTP id rj8-20020a17090b3e8800b00282e1090109mr2773559pjb.47.1699561864615; Thu, 09 Nov 2023 12:31:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699561864; cv=none; d=google.com; s=arc-20160816; b=Xa4DJi6HktcZasC0+57xensJcIXzheMDEmcHMhZhfteBsz5sftFoSPRQy5qljoRNEd 68dVj8PYXBg8LvCd5uQ0JjY3g9BkeuTfyyf5xxKTAujM+ONOCkRy2whqXY+8OiEvPwOq jYXcK+zgc5OkN7vKSFXjROs39PNiWd3w8Xrb3m2b4eE78igpZm8RZZVP2m6PJB3YPMF+ AWvPWrWbhr8FbVTlhlDRAAapvuabrbBJRjisrqJzqPbosJV81SgKPoFmvPSzBBSPGiBr daoPNJHaflITpKwsM360io1/oIT4ZdhA/nDAE/WoR/B37gr+kXaHRc3iRJm8/ZUwEtKY AbFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=jpaEre6aJymCf/x/a9rJ/2Qn+RoDQNTUwP8/qSDeEOI=; fh=+9wDHzWq5n76PyTIFijHLV2IhFuso0zco2bmhDePn78=; b=T2jcNGuXgMOxvZ1eYYOYVyu0Msa9Z6lqDwQyRGs9/A1wjnkleC3McV2G8thInTqsH3 O3maGzD3bQOqlRSGEdX0gZzrVT17YgtLa6pJKRq89dNGvIJcMHvK7GkHzYDY2IKqBJp7 DF9MzEEWcbvcXTVPu7azdeaG0XrJSCA390bXfpW/O8V+2G9U6I3TN7tCu4+RkpqqPN2s Le/rWAsJOyioTTe8o9B4aciPixNAPU9/g3UQ5yjUgiha9JTMLNa1r8Fs9uTS+8wYDvCz Unk6MAw1/IeTPWm1k3rFUVewM6YnK2rWBJAeAaeQJPjvUD9R5EMtp1q4QqATDmBzIhmr 8rDg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id v12-20020a17090a898c00b002802da109fasi2330357pjn.165.2023.11.09.12.31.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 12:31:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 9ABAF806500B; Thu, 9 Nov 2023 12:30:13 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345256AbjKIU3n (ORCPT <rfc822;lhua1029@gmail.com> + 30 others); Thu, 9 Nov 2023 15:29:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345195AbjKIU3b (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 9 Nov 2023 15:29: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 935BE4787 for <linux-kernel@vger.kernel.org>; Thu, 9 Nov 2023 12:29:19 -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 <ukl@pengutronix.de>) id 1r1BeE-0002zu-E0; Thu, 09 Nov 2023 21:29:06 +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 <ukl@pengutronix.de>) id 1r1BeD-007rWk-LU; Thu, 09 Nov 2023 21:29:05 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from <ukl@pengutronix.de>) id 1r1BeD-00GGtf-C6; Thu, 09 Nov 2023 21:29:05 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= <u.kleine-koenig@pengutronix.de> To: Arnd Bergmann <arnd@arndb.de>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Liu Ying <victor.liu@nxp.com>, Geert Uytterhoeven <geert+renesas@glider.be>, Luis Chamberlain <mcgrof@kernel.org>, Nick Alcock <nick.alcock@oracle.com>, Rob Herring <robh@kernel.org> Cc: linux-kernel@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH 05/12] bus: simple-pm-bus: Convert to platform remove callback returning void Date: Thu, 9 Nov 2023 21:28:35 +0100 Message-ID: <20231109202830.4124591-6-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.42.0.586.gbc5204569f7d.dirty In-Reply-To: <20231109202830.4124591-1-u.kleine-koenig@pengutronix.de> References: <20231109202830.4124591-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Developer-Signature: v=1; a=openpgp-sha256; l=1896; i=u.kleine-koenig@pengutronix.de; h=from:subject; bh=Ox2UR96mQUBphpPQCu2afHS3QOH3355cCf293Z7ZMuU=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlTUD0TmHACrZZ3AsH1FRI415x4vDLXTNjGwR+W w452ENjBoCJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZU1A9AAKCRCPgPtYfRL+ TrRtB/sGslx73P03TonkbUftTqrJqMOyxQ4WC5pr+hCbarcjoCMF5U2yhaWGSQ1Ro0wgBDiveYk 0eI6j6BC9b4c+kIOs7vBwqPH2W2ms2L3A7kP6nZUAgxCJykdiCusTROwBKsVcIGIXCmUC9fjLRO dLr2vSJaM+I7TXkxaW7U2B7UxV0Cg+z5PrUXuQbkZXxC2RK5CDNYrxSO0z3i/D1nEV+qxAjzQiz oemf3SUqAMXVNqRpWG0k7NhhZVQZ28EO4HZskEZ9cim12E8/UYIbcEuszQ8X4rAUWNH8lkc1FWq DjTR6eFHVMmHFFsMxzSy6WRbZICUa8R8L710UnTCc7VGqs35 X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 Content-Transfer-Encoding: 8bit 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-kernel@vger.kernel.org Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 09 Nov 2023 12:30:13 -0800 (PST) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782119781486874627 X-GMAIL-MSGID: 1782119781486874627 |
Series |
bus: Convert to platform remove callback returning void
|
|
Commit Message
Uwe Kleine-König
Nov. 9, 2023, 8:28 p.m. UTC
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 <u.kleine-koenig@pengutronix.de>
---
drivers/bus/simple-pm-bus.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
Comments
On Thu, Nov 9, 2023 at 9:29 PM Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote: > 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 <u.kleine-koenig@pengutronix.de> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Gr{oetje,eeting}s, Geert
diff --git a/drivers/bus/simple-pm-bus.c b/drivers/bus/simple-pm-bus.c index aafcc481de91..50870c827889 100644 --- a/drivers/bus/simple-pm-bus.c +++ b/drivers/bus/simple-pm-bus.c @@ -74,17 +74,16 @@ static int simple_pm_bus_probe(struct platform_device *pdev) return 0; } -static int simple_pm_bus_remove(struct platform_device *pdev) +static void simple_pm_bus_remove(struct platform_device *pdev) { const void *data = of_device_get_match_data(&pdev->dev); if (pdev->driver_override || data) - return 0; + return; dev_dbg(&pdev->dev, "%s\n", __func__); pm_runtime_disable(&pdev->dev); - return 0; } static int simple_pm_bus_runtime_suspend(struct device *dev) @@ -129,7 +128,7 @@ MODULE_DEVICE_TABLE(of, simple_pm_bus_of_match); static struct platform_driver simple_pm_bus_driver = { .probe = simple_pm_bus_probe, - .remove = simple_pm_bus_remove, + .remove_new = simple_pm_bus_remove, .driver = { .name = "simple-pm-bus", .of_match_table = simple_pm_bus_of_match,