ASoC: SOF: 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 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>
This commit is contained in:
Uwe Kleine-König 2023-10-09 17:59:45 +02:00 committed by Mark Brown
parent 163284402c
commit 52fee5c915
No known key found for this signature in database
GPG key ID: 24D68B725D5487D0
11 changed files with 11 additions and 15 deletions

View 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,

View 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,

View 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,

View 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,

View 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,

View 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",

View 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",

View 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);

View 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

View 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);

View 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