net: ethernet: microchip: Convert to platform remove callback returning void
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Mon, 18 Sep 2023 20:42:05 +0000 (22:42 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 20 Sep 2023 08:06:39 +0000 (09:06 +0100)
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() is renamed to .remove().

Trivially convert these drivers 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>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/microchip/lan966x/lan966x_main.c
drivers/net/ethernet/microchip/sparx5/sparx5_main.c

index 0d6e79af241067720cbd097673e260c405f0b191..8e4101628fbd1595edbf9080c21c8de03d5ec7da 100644 (file)
@@ -1261,7 +1261,7 @@ cleanup_ports:
        return err;
 }
 
-static int lan966x_remove(struct platform_device *pdev)
+static void lan966x_remove(struct platform_device *pdev)
 {
        struct lan966x *lan966x = platform_get_drvdata(pdev);
 
@@ -1280,13 +1280,11 @@ static int lan966x_remove(struct platform_device *pdev)
        lan966x_ptp_deinit(lan966x);
 
        debugfs_remove_recursive(lan966x->debugfs_root);
-
-       return 0;
 }
 
 static struct platform_driver lan966x_driver = {
        .probe = lan966x_probe,
-       .remove = lan966x_remove,
+       .remove_new = lan966x_remove,
        .driver = {
                .name = "lan966x-switch",
                .of_match_table = lan966x_match,
index dc9af480bfea17351c32249c7de0310ceed7d22f..d1f7fc8b1b71ab68775f40ad592ebc8aa0e57211 100644 (file)
@@ -911,7 +911,7 @@ cleanup_pnode:
        return err;
 }
 
-static int mchp_sparx5_remove(struct platform_device *pdev)
+static void mchp_sparx5_remove(struct platform_device *pdev)
 {
        struct sparx5 *sparx5 = platform_get_drvdata(pdev);
 
@@ -931,8 +931,6 @@ static int mchp_sparx5_remove(struct platform_device *pdev)
        /* Unregister netdevs */
        sparx5_unregister_notifier_blocks(sparx5);
        destroy_workqueue(sparx5->mact_queue);
-
-       return 0;
 }
 
 static const struct of_device_id mchp_sparx5_match[] = {
@@ -943,7 +941,7 @@ MODULE_DEVICE_TABLE(of, mchp_sparx5_match);
 
 static struct platform_driver mchp_sparx5_driver = {
        .probe = mchp_sparx5_probe,
-       .remove = mchp_sparx5_remove,
+       .remove_new = mchp_sparx5_remove,
        .driver = {
                .name = "sparx5-switch",
                .of_match_table = mchp_sparx5_match,