From patchwork Mon Feb 17 12:16:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 3662921 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 16A309F2EC for ; Mon, 17 Feb 2014 12:17:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4317B201DE for ; Mon, 17 Feb 2014 12:17:54 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 1C25620171 for ; Mon, 17 Feb 2014 12:17:53 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 10355264FDF; Mon, 17 Feb 2014 13:17:50 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 15F6A2625EE; Mon, 17 Feb 2014 13:16:57 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id C4517261B19; Mon, 17 Feb 2014 13:16:54 +0100 (CET) Received: from smtp-out-011.synserver.de (smtp-out-234.synserver.de [212.40.185.234]) by alsa0.perex.cz (Postfix) with ESMTP id D3624261A8E for ; Mon, 17 Feb 2014 13:16:47 +0100 (CET) Received: (qmail 31060 invoked by uid 0); 17 Feb 2014 12:16:45 -0000 X-SynServer-TrustedSrc: 1 X-SynServer-AuthUser: lars@metafoo.de X-SynServer-PPID: 30863 Received: from p4fe60ad2.dip0.t-ipconnect.de (HELO lars-adi-laptop.analog.com) [79.230.10.210] by 217.119.54.77 with SMTP; 17 Feb 2014 12:16:44 -0000 From: Lars-Peter Clausen To: Mark Brown , Liam Girdwood Date: Mon, 17 Feb 2014 13:16:55 +0100 Message-Id: <1392639416-11293-3-git-send-email-lars@metafoo.de> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1392639416-11293-1-git-send-email-lars@metafoo.de> References: <1392639416-11293-1-git-send-email-lars@metafoo.de> Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen Subject: [alsa-devel] [PATCH 3/4] ASoC: adav80x: Use devm_kzalloc() X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Use devm_kzalloc() to allocate the device state struct. Saves use from having to free it manually on the error path and in the remove callback. Now that the adav80x_bus_probe() function is only a call to snd_soc_unregister_codec() also inline that. Signed-off-by: Lars-Peter Clausen --- sound/soc/codecs/adav80x.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/sound/soc/codecs/adav80x.c b/sound/soc/codecs/adav80x.c index f78b27a..a4bd051 100644 --- a/sound/soc/codecs/adav80x.c +++ b/sound/soc/codecs/adav80x.c @@ -872,27 +872,15 @@ static int adav80x_bus_probe(struct device *dev, struct regmap *regmap) if (IS_ERR(regmap)) return PTR_ERR(regmap); - adav80x = kzalloc(sizeof(*adav80x), GFP_KERNEL); + adav80x = devm_kzalloc(dev, sizeof(*adav80x), GFP_KERNEL); if (!adav80x) return -ENOMEM; - dev_set_drvdata(dev, adav80x); adav80x->regmap = regmap; - ret = snd_soc_register_codec(dev, &adav80x_codec_driver, + return snd_soc_register_codec(dev, &adav80x_codec_driver, adav80x_dais, ARRAY_SIZE(adav80x_dais)); - if (ret) - kfree(adav80x); - - return ret; -} - -static int adav80x_bus_remove(struct device *dev) -{ - snd_soc_unregister_codec(dev); - kfree(dev_get_drvdata(dev)); - return 0; } #if defined(CONFIG_SPI_MASTER) @@ -923,7 +911,8 @@ static int adav80x_spi_probe(struct spi_device *spi) static int adav80x_spi_remove(struct spi_device *spi) { - return adav80x_bus_remove(&spi->dev); + snd_soc_unregister_codec(dev); + return 0; } static struct spi_driver adav80x_spi_driver = { @@ -965,7 +954,8 @@ static int adav80x_i2c_probe(struct i2c_client *client, static int adav80x_i2c_remove(struct i2c_client *client) { - return adav80x_bus_remove(&client->dev); + snd_soc_unregister_codec(dev); + return 0; } static struct i2c_driver adav80x_i2c_driver = {