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

ASoC: simple-card-utils: Make simple_util_remove() return 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.

simple_util_remove() returned zero unconditionally. Make it return void
instead and convert all users to struct platform_device::remove_new().

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Herve Codina <herve.codina@bootlin.com>
Link: https://lore.kernel.org/r/20231013221945.1489203-13-u.kleine-koenig@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Uwe Kleine-König and committed by
Mark Brown
393df6f3 6b02f5a6

+7 -9
+1 -1
include/sound/simple_card_utils.h
··· 188 188 char *prefix); 189 189 int simple_util_init_priv(struct simple_util_priv *priv, 190 190 struct link_info *li); 191 - int simple_util_remove(struct platform_device *pdev); 191 + void simple_util_remove(struct platform_device *pdev); 192 192 193 193 int graph_util_card_probe(struct snd_soc_card *card); 194 194 int graph_util_is_ports0(struct device_node *port);
+1 -1
sound/soc/generic/audio-graph-card.c
··· 644 644 .of_match_table = graph_of_match, 645 645 }, 646 646 .probe = graph_probe, 647 - .remove = simple_util_remove, 647 + .remove_new = simple_util_remove, 648 648 }; 649 649 module_platform_driver(graph_card); 650 650
+1 -1
sound/soc/generic/audio-graph-card2-custom-sample.c
··· 176 176 .of_match_table = custom_of_match, 177 177 }, 178 178 .probe = custom_probe, 179 - .remove = simple_util_remove, 179 + .remove_new = simple_util_remove, 180 180 }; 181 181 module_platform_driver(custom_card); 182 182
+1 -1
sound/soc/generic/audio-graph-card2.c
··· 1224 1224 .of_match_table = graph_of_match, 1225 1225 }, 1226 1226 .probe = graph_probe, 1227 - .remove = simple_util_remove, 1227 + .remove_new = simple_util_remove, 1228 1228 }; 1229 1229 module_platform_driver(graph_card); 1230 1230
+1 -3
sound/soc/generic/simple-card-utils.c
··· 958 958 } 959 959 EXPORT_SYMBOL_GPL(simple_util_init_priv); 960 960 961 - int simple_util_remove(struct platform_device *pdev) 961 + void simple_util_remove(struct platform_device *pdev) 962 962 { 963 963 struct snd_soc_card *card = platform_get_drvdata(pdev); 964 964 965 965 simple_util_clean_reference(card); 966 - 967 - return 0; 968 966 } 969 967 EXPORT_SYMBOL_GPL(simple_util_remove); 970 968
+1 -1
sound/soc/generic/simple-card.c
··· 827 827 .of_match_table = simple_of_match, 828 828 }, 829 829 .probe = simple_probe, 830 - .remove = simple_util_remove, 830 + .remove_new = simple_util_remove, 831 831 }; 832 832 833 833 module_platform_driver(simple_card);
+1 -1
sound/soc/tegra/tegra_audio_graph_card.c
··· 248 248 .of_match_table = graph_of_tegra_match, 249 249 }, 250 250 .probe = tegra_audio_graph_probe, 251 - .remove = simple_util_remove, 251 + .remove_new = simple_util_remove, 252 252 }; 253 253 module_platform_driver(tegra_audio_graph_card); 254 254