Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933336AbbLOJLI (ORCPT ); Tue, 15 Dec 2015 04:11:08 -0500 Received: from eusmtp01.atmel.com ([212.144.249.243]:35351 "EHLO eusmtp01.atmel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932219AbbLOJLG (ORCPT ); Tue, 15 Dec 2015 04:11:06 -0500 Subject: Re: [PATCH] ASoC: Atmel: ClassD: unregister codec when error occurs To: Songjun Wu , References: <1449803257-27255-1-git-send-email-songjun.wu@atmel.com> CC: , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , , From: Nicolas Ferre Organization: atmel Message-ID: <566FD93F.60901@atmel.com> Date: Tue, 15 Dec 2015 10:11:27 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <1449803257-27255-1-git-send-email-songjun.wu@atmel.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.161.30.18] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1814 Lines: 67 Le 11/12/2015 04:07, Songjun Wu a ?crit : > Add code to unregister codec in probe function, > when the error occurs after the codec is registered. > > Signed-off-by: Songjun Wu Seems okay: Acked-by: Nicolas Ferre Thanks, > --- > > sound/soc/atmel/atmel-classd.c | 14 ++++++++++---- > 1 file changed, 10 insertions(+), 4 deletions(-) > > diff --git a/sound/soc/atmel/atmel-classd.c b/sound/soc/atmel/atmel-classd.c > index dca6141..6107de9 100644 > --- a/sound/soc/atmel/atmel-classd.c > +++ b/sound/soc/atmel/atmel-classd.c > @@ -640,8 +640,10 @@ static int atmel_classd_probe(struct platform_device *pdev) > > /* register sound card */ > card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL); > - if (!card) > - return -ENOMEM; > + if (!card) { > + ret = -ENOMEM; > + goto unregister_codec; > + } > > snd_soc_card_set_drvdata(card, dd); > platform_set_drvdata(pdev, card); > @@ -649,16 +651,20 @@ static int atmel_classd_probe(struct platform_device *pdev) > ret = atmel_classd_asoc_card_init(dev, card); > if (ret) { > dev_err(dev, "failed to init sound card\n"); > - return ret; > + goto unregister_codec; > } > > ret = devm_snd_soc_register_card(dev, card); > if (ret) { > dev_err(dev, "failed to register sound card: %d\n", ret); > - return ret; > + goto unregister_codec; > } > > return 0; > + > +unregister_codec: > + snd_soc_unregister_codec(dev); > + return ret; > } > > static int atmel_classd_remove(struct platform_device *pdev) > -- Nicolas Ferre -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/