Message ID | 20231109202830.4124591-7-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 q9csp690117vqs; Thu, 9 Nov 2023 12:31:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IGKNgs0ReylT41UM4vBl3y13CCKO/Y+EDf8Y/mCf0083BWw69gEuifJcJYMIlXCFputV9FM X-Received: by 2002:a17:902:d4c6:b0:1cc:339e:c228 with SMTP id o6-20020a170902d4c600b001cc339ec228mr7350156plg.58.1699561864861; 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=FInmzaEkCBHZGLITshVZ+3n5eeNtJ5FkxEhnBYWf4k5rXygTgvo/QUIjyj/BlWBXE8 r7K2/fZRFu9PoBwvklrLtku/U6yFAPVgSBTIW2puFQk4+YxOEDpf1SfYI82fDL4efH7v K1U+nL/5PJO5vJm1inTHHU51PAMl722uPGdFwOFudZ7RQQHyycOKUGbz4PSFf2p3CFNP 3gCH2zkWUEATo8d3Im44ExMQTQN2J0WDHI9vXCKqEPzm1VL/nZEp3logcRXDJJ78+WQt OACE9W8VK7k5H30rH5Lo4pocZiNB/lv/eSxI53WeMXhukQRxZskaynbvppN908+9K36t mABQ== 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=oO6rdAJLx7JwzX/kRd4me76Hwejgn6Uw/letA505Tgc=; fh=8tp/+1/f+q1lGX+PqS5vMqXs66KgtcKS4ISiy01MsWo=; b=PhNXlxsiZ5y0hKXRiDRdw5lGFR103m3xNMXQ2rP/VQ9eEhic1Lgy7wiQWOFmpwmbJh +u1cGE3apDGFVE1gsewRIPRW0IsSq7fvi4y9xFfI3jydkHRRITtaRJN0W6h+uC9UGExu TURS2bzLjn25Y7eRWO4J5Hd/7I1rtUGoZ3sUdaIZv4RNjQbqnaFrbwD3xBqb255BO1C7 opfnX/INizDn6nRgOQnViB+EScOeK7bLypTKZbGu12sj3nDskM6CJ7zIIzmJwdd/boH/ HRMc4D2xE197uHnGmO7H1F/poEqa17BXXpAcMO5TsbiM6LkJcT4FLA8gDGWe01BnIeAU iN8Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id n3-20020a170903110300b001cc1af09466si6202498plh.125.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 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id D621C8087DCE; Thu, 9 Nov 2023 12:30:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345245AbjKIU3j (ORCPT <rfc822;lhua1029@gmail.com> + 30 others); Thu, 9 Nov 2023 15:29:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345248AbjKIU3b (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 3DB654784 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 1r1BeH-000307-0E; Thu, 09 Nov 2023 21:29:09 +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-007rWn-TW; 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-00GGtj-K5; 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>, Chen-Yu Tsai <wens@csie.org>, Jernej Skrabec <jernej.skrabec@gmail.com>, Samuel Holland <samuel@sholland.org> Cc: linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH 06/12] bus: sun50i-de2: Convert to platform remove callback returning void Date: Thu, 9 Nov 2023 21:28:36 +0100 Message-ID: <20231109202830.4124591-7-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=1726; i=u.kleine-koenig@pengutronix.de; h=from:subject; bh=YjxQ9k2VhTNSjPuszXvrypquoQe61zCjR6hyAesl/x0=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlTUD1h/FL212JBtXnUYvTOt6e/oAiPyWOeMRVg MwOBzqtJD2JATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZU1A9QAKCRCPgPtYfRL+ TtAtB/40Cw1OEL2T46KLdtC6CPWjFjNclqSJ+qr/t4mj2hWDKwQtf0kTynpCe6dsTwfyifEPBfQ d3VgfUp1eO2NYm9OBdHXDl32gc0MDmOoNpdgDKlCc6aYawUN/noK27PmoPWdFuEcm1VyU9uMAuX sR5pS1cctbTPPozjbI4Y43ApHt0iatVbNW2jxyRqQW7Ac+Bi/tfW+R4g2VJqQ3O78mZ3dSY5MLt q7CyCWxnhD1PXANJFoeNMAgGd65yzDtNxJ66WOLbB/W5SkCO0WrqOoVNBIBUmsCU7nTUwhDZUVT hIhBabSoRtg8sz8beNoY1SfoJ4H6moejJnD+pPh8i+i+h+2g 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 (groat.vger.email [0.0.0.0]); Thu, 09 Nov 2023 12:30:29 -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 groat.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782119782100346675 X-GMAIL-MSGID: 1782119782100346675 |
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/sun50i-de2.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
Comments
On Thu, 9 Nov 2023 21:28:36 +0100 Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote: Hi, > 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: Andre Przywara <andre.przywara@arm.com> Cheers, Andre > --- > drivers/bus/sun50i-de2.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/drivers/bus/sun50i-de2.c b/drivers/bus/sun50i-de2.c > index 414f29cdedf0..3339311ce068 100644 > --- a/drivers/bus/sun50i-de2.c > +++ b/drivers/bus/sun50i-de2.c > @@ -24,10 +24,9 @@ static int sun50i_de2_bus_probe(struct platform_device *pdev) > return 0; > } > > -static int sun50i_de2_bus_remove(struct platform_device *pdev) > +static void sun50i_de2_bus_remove(struct platform_device *pdev) > { > sunxi_sram_release(&pdev->dev); > - return 0; > } > > static const struct of_device_id sun50i_de2_bus_of_match[] = { > @@ -37,7 +36,7 @@ static const struct of_device_id sun50i_de2_bus_of_match[] = { > > static struct platform_driver sun50i_de2_bus_driver = { > .probe = sun50i_de2_bus_probe, > - .remove = sun50i_de2_bus_remove, > + .remove_new = sun50i_de2_bus_remove, > .driver = { > .name = "sun50i-de2-bus", > .of_match_table = sun50i_de2_bus_of_match,
Dne četrtek, 09. november 2023 ob 21:28:36 CET je Uwe Kleine-König napisal(a): > 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: Jernej Skrabec <jernej.skrabec@gmail.com> Best regards, Jernej > --- > drivers/bus/sun50i-de2.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/drivers/bus/sun50i-de2.c b/drivers/bus/sun50i-de2.c > index 414f29cdedf0..3339311ce068 100644 > --- a/drivers/bus/sun50i-de2.c > +++ b/drivers/bus/sun50i-de2.c > @@ -24,10 +24,9 @@ static int sun50i_de2_bus_probe(struct platform_device *pdev) > return 0; > } > > -static int sun50i_de2_bus_remove(struct platform_device *pdev) > +static void sun50i_de2_bus_remove(struct platform_device *pdev) > { > sunxi_sram_release(&pdev->dev); > - return 0; > } > > static const struct of_device_id sun50i_de2_bus_of_match[] = { > @@ -37,7 +36,7 @@ static const struct of_device_id sun50i_de2_bus_of_match[] = { > > static struct platform_driver sun50i_de2_bus_driver = { > .probe = sun50i_de2_bus_probe, > - .remove = sun50i_de2_bus_remove, > + .remove_new = sun50i_de2_bus_remove, > .driver = { > .name = "sun50i-de2-bus", > .of_match_table = sun50i_de2_bus_of_match, >
diff --git a/drivers/bus/sun50i-de2.c b/drivers/bus/sun50i-de2.c index 414f29cdedf0..3339311ce068 100644 --- a/drivers/bus/sun50i-de2.c +++ b/drivers/bus/sun50i-de2.c @@ -24,10 +24,9 @@ static int sun50i_de2_bus_probe(struct platform_device *pdev) return 0; } -static int sun50i_de2_bus_remove(struct platform_device *pdev) +static void sun50i_de2_bus_remove(struct platform_device *pdev) { sunxi_sram_release(&pdev->dev); - return 0; } static const struct of_device_id sun50i_de2_bus_of_match[] = { @@ -37,7 +36,7 @@ static const struct of_device_id sun50i_de2_bus_of_match[] = { static struct platform_driver sun50i_de2_bus_driver = { .probe = sun50i_de2_bus_probe, - .remove = sun50i_de2_bus_remove, + .remove_new = sun50i_de2_bus_remove, .driver = { .name = "sun50i-de2-bus", .of_match_table = sun50i_de2_bus_of_match,