wifi: mt76: Convert to platform remove callback returning void
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Fri, 17 Nov 2023 09:31:03 +0000 (10:31 +0100)
committerFelix Fietkau <nbd@nbd.name>
Thu, 7 Dec 2023 17:50:22 +0000 (18:50 +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() will be renamed to .remove().

Trivially convert the three mt76 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>
Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7603/soc.c
drivers/net/wireless/mediatek/mt76/mt7615/soc.c
drivers/net/wireless/mediatek/mt76/mt7915/soc.c

index ba927033bbe8c316d63d2d7a982e056f8300ae91..ec02148a7f1f74857b455e683103a607cfeeb2f4 100644 (file)
@@ -52,15 +52,12 @@ error:
        return ret;
 }
 
-static int
-mt76_wmac_remove(struct platform_device *pdev)
+static void mt76_wmac_remove(struct platform_device *pdev)
 {
        struct mt76_dev *mdev = platform_get_drvdata(pdev);
        struct mt7603_dev *dev = container_of(mdev, struct mt7603_dev, mt76);
 
        mt7603_unregister_device(dev);
-
-       return 0;
 }
 
 static const struct of_device_id of_wmac_match[] = {
@@ -74,7 +71,7 @@ MODULE_FIRMWARE(MT7628_FIRMWARE_E2);
 
 struct platform_driver mt76_wmac_driver = {
        .probe          = mt76_wmac_probe,
-       .remove         = mt76_wmac_remove,
+       .remove_new     = mt76_wmac_remove,
        .driver = {
                .name = "mt76_wmac",
                .of_match_table = of_wmac_match,
index f13d1b41874268da84839270084f7b7f2d0d4eb5..12e3e4a91d2748e9fbf267bf82801fce834e792c 100644 (file)
@@ -45,13 +45,11 @@ static int mt7622_wmac_probe(struct platform_device *pdev)
        return mt7615_mmio_probe(&pdev->dev, mem_base, irq, mt7615e_reg_map);
 }
 
-static int mt7622_wmac_remove(struct platform_device *pdev)
+static void mt7622_wmac_remove(struct platform_device *pdev)
 {
        struct mt7615_dev *dev = platform_get_drvdata(pdev);
 
        mt7615_unregister_device(dev);
-
-       return 0;
 }
 
 static const struct of_device_id mt7622_wmac_of_match[] = {
@@ -65,7 +63,7 @@ struct platform_driver mt7622_wmac_driver = {
                .of_match_table = mt7622_wmac_of_match,
        },
        .probe = mt7622_wmac_probe,
-       .remove = mt7622_wmac_remove,
+       .remove_new = mt7622_wmac_remove,
 };
 
 MODULE_FIRMWARE(MT7622_FIRMWARE_N9);
index 06e3d9db996c14198f98201f24bdf1974c5b7b32..8b4809703efcf67f4dc26bc53da41d738110c278 100644 (file)
@@ -1282,13 +1282,11 @@ free_device:
        return ret;
 }
 
-static int mt798x_wmac_remove(struct platform_device *pdev)
+static void mt798x_wmac_remove(struct platform_device *pdev)
 {
        struct mt7915_dev *dev = platform_get_drvdata(pdev);
 
        mt7915_unregister_device(dev);
-
-       return 0;
 }
 
 static const struct of_device_id mt798x_wmac_of_match[] = {
@@ -1305,7 +1303,7 @@ struct platform_driver mt798x_wmac_driver = {
                .of_match_table = mt798x_wmac_of_match,
        },
        .probe = mt798x_wmac_probe,
-       .remove = mt798x_wmac_remove,
+       .remove_new = mt798x_wmac_remove,
 };
 
 MODULE_FIRMWARE(MT7986_FIRMWARE_WA);