Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

wifi: wlcore: Convert to platform remove callback returning void

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 (mostly) ignored
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.

wlcore_remove() returned zero unconditionally. With that converted to
return void instead, the wl12xx and wl18xx driver can be converted to
.remove_new trivially.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230912171249.755901-1-u.kleine-koenig@pengutronix.de

authored by

Uwe Kleine-König and committed by
Kalle Valo
f0092801 c3564280

+7 -9
+3 -3
drivers/net/wireless/ti/wl12xx/main.c
··· 1919 1919 return ret; 1920 1920 } 1921 1921 1922 - static int wl12xx_remove(struct platform_device *pdev) 1922 + static void wl12xx_remove(struct platform_device *pdev) 1923 1923 { 1924 1924 struct wl1271 *wl = platform_get_drvdata(pdev); 1925 1925 struct wl12xx_priv *priv; ··· 1928 1928 1929 1929 kfree(priv->rx_mem_addr); 1930 1930 1931 - return wlcore_remove(pdev); 1931 + wlcore_remove(pdev); 1932 1932 } 1933 1933 1934 1934 static const struct platform_device_id wl12xx_id_table[] = { ··· 1939 1939 1940 1940 static struct platform_driver wl12xx_driver = { 1941 1941 .probe = wl12xx_probe, 1942 - .remove = wl12xx_remove, 1942 + .remove_new = wl12xx_remove, 1943 1943 .id_table = wl12xx_id_table, 1944 1944 .driver = { 1945 1945 .name = "wl12xx_driver",
+1 -1
drivers/net/wireless/ti/wl18xx/main.c
··· 2033 2033 2034 2034 static struct platform_driver wl18xx_driver = { 2035 2035 .probe = wl18xx_probe, 2036 - .remove = wlcore_remove, 2036 + .remove_new = wlcore_remove, 2037 2037 .id_table = wl18xx_id_table, 2038 2038 .driver = { 2039 2039 .name = "wl18xx_driver",
+2 -4
drivers/net/wireless/ti/wlcore/main.c
··· 6737 6737 } 6738 6738 EXPORT_SYMBOL_GPL(wlcore_probe); 6739 6739 6740 - int wlcore_remove(struct platform_device *pdev) 6740 + void wlcore_remove(struct platform_device *pdev) 6741 6741 { 6742 6742 struct wlcore_platdev_data *pdev_data = dev_get_platdata(&pdev->dev); 6743 6743 struct wl1271 *wl = platform_get_drvdata(pdev); ··· 6752 6752 if (pdev_data->family && pdev_data->family->nvs_name) 6753 6753 wait_for_completion(&wl->nvs_loading_complete); 6754 6754 if (!wl->initialized) 6755 - return 0; 6755 + return; 6756 6756 6757 6757 if (wl->wakeirq >= 0) { 6758 6758 dev_pm_clear_wake_irq(wl->dev); ··· 6772 6772 6773 6773 free_irq(wl->irq, wl); 6774 6774 wlcore_free_hw(wl); 6775 - 6776 - return 0; 6777 6775 } 6778 6776 EXPORT_SYMBOL_GPL(wlcore_remove); 6779 6777
+1 -1
drivers/net/wireless/ti/wlcore/wlcore.h
··· 497 497 }; 498 498 499 499 int wlcore_probe(struct wl1271 *wl, struct platform_device *pdev); 500 - int wlcore_remove(struct platform_device *pdev); 500 + void wlcore_remove(struct platform_device *pdev); 501 501 struct ieee80211_hw *wlcore_alloc_hw(size_t priv_size, u32 aggr_buf_size, 502 502 u32 mbox_size); 503 503 int wlcore_free_hw(struct wl1271 *wl);