mirror of https://gitee.com/openkylin/linux.git
ASoC: Atmel: ClassD: unregister codec when error occurs
Add code to unregister codec in probe function, when the error occurs after the codec is registered. Signed-off-by: Songjun Wu <songjun.wu@atmel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
8005c49d9a
commit
32e69bad8e
|
@ -636,8 +636,10 @@ static int atmel_classd_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
/* register sound card */
|
/* register sound card */
|
||||||
card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
|
card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
|
||||||
if (!card)
|
if (!card) {
|
||||||
return -ENOMEM;
|
ret = -ENOMEM;
|
||||||
|
goto unregister_codec;
|
||||||
|
}
|
||||||
|
|
||||||
snd_soc_card_set_drvdata(card, dd);
|
snd_soc_card_set_drvdata(card, dd);
|
||||||
platform_set_drvdata(pdev, card);
|
platform_set_drvdata(pdev, card);
|
||||||
|
@ -645,16 +647,20 @@ static int atmel_classd_probe(struct platform_device *pdev)
|
||||||
ret = atmel_classd_asoc_card_init(dev, card);
|
ret = atmel_classd_asoc_card_init(dev, card);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(dev, "failed to init sound card\n");
|
dev_err(dev, "failed to init sound card\n");
|
||||||
return ret;
|
goto unregister_codec;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = devm_snd_soc_register_card(dev, card);
|
ret = devm_snd_soc_register_card(dev, card);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(dev, "failed to register sound card: %d\n", ret);
|
dev_err(dev, "failed to register sound card: %d\n", ret);
|
||||||
return ret;
|
goto unregister_codec;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
unregister_codec:
|
||||||
|
snd_soc_unregister_codec(dev);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int atmel_classd_remove(struct platform_device *pdev)
|
static int atmel_classd_remove(struct platform_device *pdev)
|
||||||
|
|
Loading…
Reference in New Issue