From patchwork Thu Jun 16 00:58:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 9179729 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 875726075D for ; Thu, 16 Jun 2016 00:58:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D3FE27DA4 for ; Thu, 16 Jun 2016 00:58:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 51E1427F07; Thu, 16 Jun 2016 00:58:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F41827DA4 for ; Thu, 16 Jun 2016 00:58:44 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id BE2FC265802; Thu, 16 Jun 2016 02:58:42 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 7BA3F265745; Thu, 16 Jun 2016 02:58:35 +0200 (CEST) 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 D3DC92657B0; Thu, 16 Jun 2016 02:58:32 +0200 (CEST) Received: from mail-pf0-f196.google.com (mail-pf0-f196.google.com [209.85.192.196]) by alsa0.perex.cz (Postfix) with ESMTP id 1D2882656F5 for ; Thu, 16 Jun 2016 02:58:27 +0200 (CEST) Received: by mail-pf0-f196.google.com with SMTP id c74so2742669pfb.0 for ; Wed, 15 Jun 2016 17:58:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ingics-com.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:cc:date:mime-version :content-transfer-encoding; bh=o848qCR2aVDrGUUukjSazRf0w7sLVx1rqKUVTLfCMKc=; b=ichJ4J1jgtJnOg27x+sI/4Uz86jwFWDfv0V6S/OfsREIaGkhofHpWIENakW5A/SBTJ tn0tnukWv1Skc8Au97l9meH5+DRs0MdSgvcMD1a/KOoaoC/ggOzyyuLszl2GoPAN/e9n EIHPnFYuf7t0RvjuRKXaH7yxrfCc6rqYO54AzSeqmpSr2Jbi8GEpbukZhUBA2wHRGqUS mJp79VMD7AIuyEQu6wCUOi6Tg669CEGQ345IuntAaIp8JDwz3WjdAxlUSp1OP59Zkcyk Aeug0seLTQ6VxsWVMYO4Kim53FK/MvYt/F8Pq2jYXB8KtgyVVywaCtSYfPbcY4bRkkSZ d09Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:mime-version :content-transfer-encoding; bh=o848qCR2aVDrGUUukjSazRf0w7sLVx1rqKUVTLfCMKc=; b=bchKBoIk3plroPElITpOADo2TCFtbVuZi/IOKCRZsoJHpnFS0rCtrc3SNy2XTNUPCJ siz3vYd3TXf4Sx5nL6iD+YzX2bydEi0fiJx2KjaOAccXcc3OtgPQVYcfPB+5ZVyuXibA ofCjEyWMSGIkgT/KqQbsDwzP6j+eFWHeEuqvxxbQN1pfqqlFL/SORrYYT42RgWmgJfM6 J/NyL0jrCChwjd6d6wHFev2vFkTWDNBD4ifX0qCk3lUY70JI1BRUoWfYLAbOb28WoUA8 45fDSAJJQsiSht9Av7qwrf/OYnOvnQYklVfrVvf8ibxclggO2noHrh+HZMF8duVwFVje 4Gbg== X-Gm-Message-State: ALyK8tKEj+Up/4BlyfaUvLBfpk42JxoJ16PC1WJR48GSyH8OU+TvWAfNnXrTqRMuZMv4Jg== X-Received: by 10.98.196.18 with SMTP id y18mr1804636pff.163.1466038705512; Wed, 15 Jun 2016 17:58:25 -0700 (PDT) Received: from [192.168.1.168] (118-167-5-165.dynamic.hinet.net. [118.167.5.165]) by smtp.gmail.com with ESMTPSA id 4sm45522643pav.33.2016.06.15.17.58.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Jun 2016 17:58:23 -0700 (PDT) Message-ID: <1466038700.8790.1.camel@ingics.com> From: Axel Lin To: Mark Brown Date: Thu, 16 Jun 2016 08:58:20 +0800 X-Mailer: Evolution 3.16.5-1ubuntu3.1 Mime-Version: 1.0 Cc: Oder Chiou , Bard Liao , alsa-devel@alsa-project.org, Liam Girdwood Subject: [alsa-devel] [PATCH] ASoC: rt5514-spi: Convert to use devm_* API 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Use devm_* API to simplify the code. This patch also fixes the return value in probe error paths. Signed-off-by: Axel Lin --- sound/soc/codecs/rt5514-spi.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/sound/soc/codecs/rt5514-spi.c b/sound/soc/codecs/rt5514-spi.c index 8a9382e..e1b326d 100644 --- a/sound/soc/codecs/rt5514-spi.c +++ b/sound/soc/codecs/rt5514-spi.c @@ -409,33 +409,21 @@ static int rt5514_spi_probe(struct spi_device *spi) rt5514_spi = spi; - ret = snd_soc_register_platform(&spi->dev, &rt5514_spi_platform); + ret = devm_snd_soc_register_platform(&spi->dev, &rt5514_spi_platform); if (ret < 0) { dev_err(&spi->dev, "Failed to register platform.\n"); - goto err_plat; + return ret; } - ret = snd_soc_register_component(&spi->dev, &rt5514_spi_dai_component, - &rt5514_spi_dai, 1); + ret = devm_snd_soc_register_component(&spi->dev, + &rt5514_spi_dai_component, + &rt5514_spi_dai, 1); if (ret < 0) { dev_err(&spi->dev, "Failed to register component.\n"); - goto err_comp; + return ret; } return 0; -err_comp: - snd_soc_unregister_platform(&spi->dev); -err_plat: - - return 0; -} - -static int rt5514_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_component(&spi->dev); - snd_soc_unregister_platform(&spi->dev); - - return 0; } static const struct of_device_id rt5514_of_match[] = { @@ -450,7 +438,6 @@ static struct spi_driver rt5514_spi_driver = { .of_match_table = of_match_ptr(rt5514_of_match), }, .probe = rt5514_spi_probe, - .remove = rt5514_spi_remove, }; module_spi_driver(rt5514_spi_driver);