[PATCH] ASoC: amd: acp: Fix error handling in .remove()

Uwe Kleine-König u.kleine-koenig at pengutronix.de
Wed Jun 22 08:17:39 CEST 2022


Even in the presence of problems (here: rn_acp_deinit() might fail), it's
important to unregister all resources acquired during .probe() because
even if .remove() returns an error code, the device is removed.

As .remove() is only called after .probe() returned success, platdata
must be valid, so the first check in .remove() can just be dropped.

This is a preparation for making platform remove callbacks return void.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig at pengutronix.de>
---
 sound/soc/amd/acp/acp-renoir.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/sound/soc/amd/acp/acp-renoir.c b/sound/soc/amd/acp/acp-renoir.c
index 75c9229ece97..8375c00ff4c3 100644
--- a/sound/soc/amd/acp/acp-renoir.c
+++ b/sound/soc/amd/acp/acp-renoir.c
@@ -307,16 +307,10 @@ static int renoir_audio_remove(struct platform_device *pdev)
 	int ret;
 
 	chip = dev_get_platdata(&pdev->dev);
-	if (!chip || !chip->base) {
-		dev_err(&pdev->dev, "ACP chip data is NULL\n");
-		return -ENODEV;
-	}
 
 	ret = rn_acp_deinit(chip->base);
-	if (ret) {
-		dev_err(&pdev->dev, "ACP de-init Failed\n");
-		return -EINVAL;
-	}
+	if (ret)
+		dev_err(&pdev->dev, "ACP de-init Failed (%pe)\n", ERR_PTR(ret));
 
 	acp_platform_unregister(dev);
 	return 0;

base-commit: f2906aa863381afb0015a9eb7fefad885d4e5a56
-- 
2.36.1



More information about the Alsa-devel mailing list