From ed3b53e7ffe91c32a1277de435e3fcb3ad5e852a Mon Sep 17 00:00:00 2001 From: Stephan Gerhold Date: Thu, 23 Jul 2020 20:38:58 +0200 Subject: ASoC: qcom: Use devm for resource management Simplify the machine drivers for newer SoCs a bit by using the devm_* function calls that automatically release the resources when the driver is removed or when probing fails. Signed-off-by: Stephan Gerhold Tested-by: Srinivas Kandagatla Reviewed-by: Srinivas Kandagatla Cc: Srinivas Kandagatla Link: https://lore.kernel.org/r/20200723183904.321040-2-stephan@gerhold.net Signed-off-by: Mark Brown --- sound/soc/qcom/apq8096.c | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) (limited to 'sound/soc/qcom/apq8096.c') diff --git a/sound/soc/qcom/apq8096.c b/sound/soc/qcom/apq8096.c index 6b5a381cf9b6..253549600c5a 100644 --- a/sound/soc/qcom/apq8096.c +++ b/sound/soc/qcom/apq8096.c @@ -109,7 +109,7 @@ static int apq8096_platform_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; int ret; - card = kzalloc(sizeof(*card), GFP_KERNEL); + card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL); if (!card) return -ENOMEM; @@ -117,31 +117,10 @@ static int apq8096_platform_probe(struct platform_device *pdev) dev_set_drvdata(dev, card); ret = qcom_snd_parse_of(card); if (ret) - goto err; + return ret; apq8096_add_be_ops(card); - ret = snd_soc_register_card(card); - if (ret) - goto err_card_register; - - return 0; - -err_card_register: - kfree(card->dai_link); -err: - kfree(card); - return ret; -} - -static int apq8096_platform_remove(struct platform_device *pdev) -{ - struct snd_soc_card *card = dev_get_drvdata(&pdev->dev); - - snd_soc_unregister_card(card); - kfree(card->dai_link); - kfree(card); - - return 0; + return devm_snd_soc_register_card(dev, card); } static const struct of_device_id msm_snd_apq8096_dt_match[] = { @@ -153,7 +132,6 @@ MODULE_DEVICE_TABLE(of, msm_snd_apq8096_dt_match); static struct platform_driver msm_snd_apq8096_driver = { .probe = apq8096_platform_probe, - .remove = apq8096_platform_remove, .driver = { .name = "msm-snd-apq8096", .of_match_table = msm_snd_apq8096_dt_match, -- cgit v1.2.3