]> git.ipfire.org Git - thirdparty/openwrt.git/blob
d19338e7df9dfdfc29500b9f6207a110d0bd2191
[thirdparty/openwrt.git] /
1 From d48a5472b8f2b29800bb25913f9403765005f1bc Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= <u.kleine-koenig@pengutronix.de>
3 Date: Mon, 18 Sep 2023 21:19:14 +0200
4 Subject: [PATCH] net: dsa: realtek: Convert to platform remove callback
5 returning void
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 The .remove() callback for a platform driver returns an int which makes
11 many driver authors wrongly assume it's possible to do error handling by
12 returning an error code. However the value returned is ignored (apart
13 from emitting a warning) and this typically results in resource leaks.
14 To improve here there is a quest to make the remove callback return
15 void. In the first step of this quest all drivers are converted to
16 .remove_new() which already returns void. Eventually after all drivers
17 are converted, .remove_new() is renamed to .remove().
18
19 Trivially convert this driver from always returning zero in the remove
20 callback to the void returning variant.
21
22 Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
23 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
24 Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
25 Reviewed-by: Alvin Šipraga <alsi@bang-olufsen.dk>
26 Signed-off-by: David S. Miller <davem@davemloft.net>
27 Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
28 ---
29 drivers/net/dsa/realtek/realtek-smi.c | 8 +++-----
30 1 file changed, 3 insertions(+), 5 deletions(-)
31
32 --- a/drivers/net/dsa/realtek/realtek-smi.c
33 +++ b/drivers/net/dsa/realtek/realtek-smi.c
34 @@ -506,12 +506,12 @@ static int realtek_smi_probe(struct plat
35 return 0;
36 }
37
38 -static int realtek_smi_remove(struct platform_device *pdev)
39 +static void realtek_smi_remove(struct platform_device *pdev)
40 {
41 struct realtek_priv *priv = platform_get_drvdata(pdev);
42
43 if (!priv)
44 - return 0;
45 + return;
46
47 dsa_unregister_switch(priv->ds);
48 if (priv->slave_mii_bus)
49 @@ -520,8 +520,6 @@ static int realtek_smi_remove(struct pla
50 /* leave the device reset asserted */
51 if (priv->reset)
52 gpiod_set_value(priv->reset, 1);
53 -
54 - return 0;
55 }
56
57 static void realtek_smi_shutdown(struct platform_device *pdev)
58 @@ -559,7 +557,7 @@ static struct platform_driver realtek_sm
59 .of_match_table = realtek_smi_of_match,
60 },
61 .probe = realtek_smi_probe,
62 - .remove = realtek_smi_remove,
63 + .remove_new = realtek_smi_remove,
64 .shutdown = realtek_smi_shutdown,
65 };
66 module_platform_driver(realtek_smi_driver);