]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
ASoC: SOF: Convert to platform remove callback returning void
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Mon, 9 Oct 2023 15:59:45 +0000 (17:59 +0200)
committerMark Brown <broonie@kernel.org>
Tue, 10 Oct 2023 18:21:04 +0000 (19:21 +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().

The SOF platform drivers all use either sof_of_remove() or
sof_acpi_remove() which both return zero unconditionally. Change these
functions to return void and the drivers to use .remove_new(). There is
no semantical change.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20231009155945.285537-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/imx/imx8.c
sound/soc/sof/imx/imx8m.c
sound/soc/sof/imx/imx8ulp.c
sound/soc/sof/intel/bdw.c
sound/soc/sof/intel/byt.c
sound/soc/sof/mediatek/mt8186/mt8186.c
sound/soc/sof/mediatek/mt8195/mt8195.c
sound/soc/sof/sof-acpi-dev.c
sound/soc/sof/sof-acpi-dev.h
sound/soc/sof/sof-of-dev.c
sound/soc/sof/sof-of-dev.h

index 65a7041cbab9d75b14ab4adbf4195bb39cb9574c..e375f29b21d186c99dc46a025073a9313e27bab0 100644 (file)
@@ -650,7 +650,7 @@ MODULE_DEVICE_TABLE(of, sof_of_imx8_ids);
 /* DT driver definition */
 static struct platform_driver snd_sof_of_imx8_driver = {
        .probe = sof_of_probe,
-       .remove = sof_of_remove,
+       .remove_new = sof_of_remove,
        .driver = {
                .name = "sof-audio-of-imx8",
                .pm = &sof_of_pm,
index 9d58dda8f079d1028a2212c0c84a0792505ba880..198a9cd740197e80c4b34cb1103652374033f29e 100644 (file)
@@ -495,7 +495,7 @@ MODULE_DEVICE_TABLE(of, sof_of_imx8m_ids);
 /* DT driver definition */
 static struct platform_driver snd_sof_of_imx8m_driver = {
        .probe = sof_of_probe,
-       .remove = sof_of_remove,
+       .remove_new = sof_of_remove,
        .driver = {
                .name = "sof-audio-of-imx8m",
                .pm = &sof_of_pm,
index 2673c1d4ddea16f543511374aff0a3c3f84c798b..c0460196501420dec7e92bf5934a2266d29b5c3e 100644 (file)
@@ -502,7 +502,7 @@ MODULE_DEVICE_TABLE(of, sof_of_imx8ulp_ids);
 /* DT driver definition */
 static struct platform_driver snd_sof_of_imx8ulp_driver = {
        .probe = sof_of_probe,
-       .remove = sof_of_remove,
+       .remove_new = sof_of_remove,
        .driver = {
                .name = "sof-audio-of-imx8ulp",
                .pm = &sof_of_pm,
index 511fce8e0e198be8cbb8d7a56713cb4e43c35bb7..e30ca086f3f8d5e49d1c4e1a53deed2ff8d288be 100644 (file)
@@ -684,7 +684,7 @@ static int sof_broadwell_probe(struct platform_device *pdev)
 /* acpi_driver definition */
 static struct platform_driver snd_sof_acpi_intel_bdw_driver = {
        .probe = sof_broadwell_probe,
-       .remove = sof_acpi_remove,
+       .remove_new = sof_acpi_remove,
        .driver = {
                .name = "sof-audio-acpi-intel-bdw",
                .pm = &sof_acpi_pm,
index a976dc91d2ec69178e5cde3c0920e044290d3e14..82ab4b0fabf3f11c2bc0464206a61091a905d21f 100644 (file)
@@ -467,7 +467,7 @@ static int sof_baytrail_probe(struct platform_device *pdev)
 /* acpi_driver definition */
 static struct platform_driver snd_sof_acpi_intel_byt_driver = {
        .probe = sof_baytrail_probe,
-       .remove = sof_acpi_remove,
+       .remove_new = sof_acpi_remove,
        .driver = {
                .name = "sof-audio-acpi-intel-byt",
                .pm = &sof_acpi_pm,
index 811081d9a05cd9d2f6ea03f4cdc8fb657519b8bc..3717fdeae3a62e668f81fe5f7b6c375a5fc6b95d 100644 (file)
@@ -707,7 +707,7 @@ MODULE_DEVICE_TABLE(of, sof_of_mt8186_ids);
 /* DT driver definition */
 static struct platform_driver snd_sof_of_mt8186_driver = {
        .probe = sof_of_probe,
-       .remove = sof_of_remove,
+       .remove_new = sof_of_remove,
        .shutdown = sof_of_shutdown,
        .driver = {
        .name = "sof-audio-of-mt8186",
index 21d4434dd729e0b2b1b74906725f2ff28af550ad..b873e1534dd0d38396882f955fe6eb20f5e228d3 100644 (file)
@@ -660,7 +660,7 @@ MODULE_DEVICE_TABLE(of, sof_of_mt8195_ids);
 /* DT driver definition */
 static struct platform_driver snd_sof_of_mt8195_driver = {
        .probe = sof_of_probe,
-       .remove = sof_of_remove,
+       .remove_new = sof_of_remove,
        .shutdown = sof_of_shutdown,
        .driver = {
        .name = "sof-audio-of-mt8195",
index 5c4e5ab31abff77dedffc60f8b685dfd7561b62e..84a4a0a3318e0eb20db539ff0dd69424fa15846e 100644 (file)
@@ -95,7 +95,7 @@ int sof_acpi_probe(struct platform_device *pdev, const struct sof_dev_desc *desc
 }
 EXPORT_SYMBOL_NS(sof_acpi_probe, SND_SOC_SOF_ACPI_DEV);
 
-int sof_acpi_remove(struct platform_device *pdev)
+void sof_acpi_remove(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
 
@@ -104,8 +104,6 @@ int sof_acpi_remove(struct platform_device *pdev)
 
        /* call sof helper for DSP hardware remove */
        snd_sof_device_remove(dev);
-
-       return 0;
 }
 EXPORT_SYMBOL_NS(sof_acpi_remove, SND_SOC_SOF_ACPI_DEV);
 
index 5c2b558d2ace350b56e3b9255439e79cfa4d6bff..9bf8f75ceaaed93f2169191a0f8fd8be606e3ba1 100644 (file)
@@ -11,6 +11,6 @@
 
 extern const struct dev_pm_ops sof_acpi_pm;
 int sof_acpi_probe(struct platform_device *pdev, const struct sof_dev_desc *desc);
-int sof_acpi_remove(struct platform_device *pdev);
+void sof_acpi_remove(struct platform_device *pdev);
 
 #endif
index b0e8bd06f78ae5a2275a529be1c984dc9c268c69..c6be8a91e74b053b59436957cb080963f9647cff 100644 (file)
@@ -84,14 +84,12 @@ int sof_of_probe(struct platform_device *pdev)
 }
 EXPORT_SYMBOL(sof_of_probe);
 
-int sof_of_remove(struct platform_device *pdev)
+void sof_of_remove(struct platform_device *pdev)
 {
        pm_runtime_disable(&pdev->dev);
 
        /* call sof helper for DSP hardware remove */
        snd_sof_device_remove(&pdev->dev);
-
-       return 0;
 }
 EXPORT_SYMBOL(sof_of_remove);
 
index 2948b3a0d9fef918ffd4e7d393dbc166b8bbfad1..b6cc70595f3bf174682e70b0ea3f5fc958f2545b 100644 (file)
@@ -19,7 +19,7 @@ struct snd_sof_of_mach {
 extern const struct dev_pm_ops sof_of_pm;
 
 int sof_of_probe(struct platform_device *pdev);
-int sof_of_remove(struct platform_device *pdev);
+void sof_of_remove(struct platform_device *pdev);
 void sof_of_shutdown(struct platform_device *pdev);
 
 #endif