net: ethernet: ibm: Convert to platform remove callback returning void
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Mon, 18 Sep 2023 20:41:56 +0000 (22:41 +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/ibm/ehea/ehea_main.c
drivers/net/ethernet/ibm/emac/core.c
drivers/net/ethernet/ibm/emac/mal.c
drivers/net/ethernet/ibm/emac/rgmii.c
drivers/net/ethernet/ibm/emac/tah.c
drivers/net/ethernet/ibm/emac/zmii.c

index 0a56e97..251dedd 100644 (file)
@@ -90,7 +90,7 @@ static struct ehea_bcmc_reg_array ehea_bcmc_regs;
 
 static int ehea_probe_adapter(struct platform_device *dev);
 
-static int ehea_remove(struct platform_device *dev);
+static void ehea_remove(struct platform_device *dev);
 
 static const struct of_device_id ehea_module_device_table[] = {
        {
@@ -121,7 +121,7 @@ static struct platform_driver ehea_driver = {
                .of_match_table = ehea_device_table,
        },
        .probe = ehea_probe_adapter,
-       .remove = ehea_remove,
+       .remove_new = ehea_remove,
 };
 
 void ehea_dump(void *adr, int len, char *msg)
@@ -3471,7 +3471,7 @@ out:
        return ret;
 }
 
-static int ehea_remove(struct platform_device *dev)
+static void ehea_remove(struct platform_device *dev)
 {
        struct ehea_adapter *adapter = platform_get_drvdata(dev);
        int i;
@@ -3492,8 +3492,6 @@ static int ehea_remove(struct platform_device *dev)
        list_del(&adapter->list);
 
        ehea_update_firmware_handles();
-
-       return 0;
 }
 
 static int check_module_parm(void)
index 0c314bf..e6e47b1 100644 (file)
@@ -3253,7 +3253,7 @@ static int emac_probe(struct platform_device *ofdev)
        return err;
 }
 
-static int emac_remove(struct platform_device *ofdev)
+static void emac_remove(struct platform_device *ofdev)
 {
        struct emac_instance *dev = platform_get_drvdata(ofdev);
 
@@ -3290,8 +3290,6 @@ static int emac_remove(struct platform_device *ofdev)
                irq_dispose_mapping(dev->emac_irq);
 
        free_netdev(dev->ndev);
-
-       return 0;
 }
 
 /* XXX Features in here should be replaced by properties... */
@@ -3319,7 +3317,7 @@ static struct platform_driver emac_driver = {
                .of_match_table = emac_match,
        },
        .probe = emac_probe,
-       .remove = emac_remove,
+       .remove_new = emac_remove,
 };
 
 static void __init emac_make_bootlist(void)
index c3236b5..462646d 100644 (file)
@@ -711,7 +711,7 @@ static int mal_probe(struct platform_device *ofdev)
        return err;
 }
 
-static int mal_remove(struct platform_device *ofdev)
+static void mal_remove(struct platform_device *ofdev)
 {
        struct mal_instance *mal = platform_get_drvdata(ofdev);
 
@@ -740,8 +740,6 @@ static int mal_remove(struct platform_device *ofdev)
                           NUM_RX_BUFF * mal->num_rx_chans), mal->bd_virt,
                          mal->bd_dma);
        kfree(mal);
-
-       return 0;
 }
 
 static const struct of_device_id mal_platform_match[] =
@@ -770,7 +768,7 @@ static struct platform_driver mal_of_driver = {
                .of_match_table = mal_platform_match,
        },
        .probe = mal_probe,
-       .remove = mal_remove,
+       .remove_new = mal_remove,
 };
 
 int __init mal_init(void)
index fd437f9..e1712fd 100644 (file)
@@ -273,7 +273,7 @@ static int rgmii_probe(struct platform_device *ofdev)
        return rc;
 }
 
-static int rgmii_remove(struct platform_device *ofdev)
+static void rgmii_remove(struct platform_device *ofdev)
 {
        struct rgmii_instance *dev = platform_get_drvdata(ofdev);
 
@@ -281,8 +281,6 @@ static int rgmii_remove(struct platform_device *ofdev)
 
        iounmap(dev->base);
        kfree(dev);
-
-       return 0;
 }
 
 static const struct of_device_id rgmii_match[] =
@@ -302,7 +300,7 @@ static struct platform_driver rgmii_driver = {
                .of_match_table = rgmii_match,
        },
        .probe = rgmii_probe,
-       .remove = rgmii_remove,
+       .remove_new = rgmii_remove,
 };
 
 int __init rgmii_init(void)
index aae9a88..fa34882 100644 (file)
@@ -130,7 +130,7 @@ static int tah_probe(struct platform_device *ofdev)
        return rc;
 }
 
-static int tah_remove(struct platform_device *ofdev)
+static void tah_remove(struct platform_device *ofdev)
 {
        struct tah_instance *dev = platform_get_drvdata(ofdev);
 
@@ -138,8 +138,6 @@ static int tah_remove(struct platform_device *ofdev)
 
        iounmap(dev->base);
        kfree(dev);
-
-       return 0;
 }
 
 static const struct of_device_id tah_match[] =
@@ -160,7 +158,7 @@ static struct platform_driver tah_driver = {
                .of_match_table = tah_match,
        },
        .probe = tah_probe,
-       .remove = tah_remove,
+       .remove_new = tah_remove,
 };
 
 int __init tah_init(void)
index 6337388..26e86cd 100644 (file)
@@ -278,7 +278,7 @@ static int zmii_probe(struct platform_device *ofdev)
        return rc;
 }
 
-static int zmii_remove(struct platform_device *ofdev)
+static void zmii_remove(struct platform_device *ofdev)
 {
        struct zmii_instance *dev = platform_get_drvdata(ofdev);
 
@@ -286,8 +286,6 @@ static int zmii_remove(struct platform_device *ofdev)
 
        iounmap(dev->base);
        kfree(dev);
-
-       return 0;
 }
 
 static const struct of_device_id zmii_match[] =
@@ -308,7 +306,7 @@ static struct platform_driver zmii_driver = {
                .of_match_table = zmii_match,
        },
        .probe = zmii_probe,
-       .remove = zmii_remove,
+       .remove_new = zmii_remove,
 };
 
 int __init zmii_init(void)