From patchwork Thu Jul 16 19:22:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 6810681 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A13A7C05AC for ; Thu, 16 Jul 2015 19:24:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7F3B42060A for ; Thu, 16 Jul 2015 19:24:44 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id C7AD82068D for ; Thu, 16 Jul 2015 19:24:42 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id EC0282666C6; Thu, 16 Jul 2015 21:24:41 +0200 (CEST) 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, RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 732DD2665F8; Thu, 16 Jul 2015 21:23:11 +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 2EAC22605B0; Thu, 16 Jul 2015 21:23:08 +0200 (CEST) Received: from smtp-out-036.synserver.de (smtp-out-036.synserver.de [212.40.185.36]) by alsa0.perex.cz (Postfix) with ESMTP id F1DC42605BD for ; Thu, 16 Jul 2015 21:22:58 +0200 (CEST) Received: (qmail 31257 invoked by uid 0); 16 Jul 2015 19:22:58 -0000 X-SynServer-TrustedSrc: 1 X-SynServer-AuthUser: lars@metafoo.de X-SynServer-PPID: 31047 Received: from p5b39d344.dip0.t-ipconnect.de (HELO lars-laptop.localdomain) [91.57.211.68] by 217.119.54.87 with SMTP; 16 Jul 2015 19:22:58 -0000 From: Lars-Peter Clausen To: Mark Brown , Liam Girdwood Date: Thu, 16 Jul 2015 21:22:51 +0200 Message-Id: <1437074572-3831-3-git-send-email-lars@metafoo.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1437074572-3831-1-git-send-email-lars@metafoo.de> References: <1437074572-3831-1-git-send-email-lars@metafoo.de> Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen Subject: [alsa-devel] [PATCH 3/4] ASoC: max9768: Use managed gpio request 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 Makes the code a bit shorter and simpler. Signed-off-by: Lars-Peter Clausen --- sound/soc/codecs/max9768.c | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/sound/soc/codecs/max9768.c b/sound/soc/codecs/max9768.c index f987497..381ff8a 100644 --- a/sound/soc/codecs/max9768.c +++ b/sound/soc/codecs/max9768.c @@ -183,11 +183,13 @@ static int max9768_i2c_probe(struct i2c_client *client, if (pdata) { /* Mute on powerup to avoid clicks */ - err = gpio_request_one(pdata->mute_gpio, GPIOF_INIT_HIGH, "MAX9768 Mute"); + err = devm_gpio_request_one(&client->dev, pdata->mute_gpio, + GPIOF_INIT_HIGH, "MAX9768 Mute"); max9768->mute_gpio = err ?: pdata->mute_gpio; /* Activate chip by releasing shutdown, enables I2C */ - err = gpio_request_one(pdata->shdn_gpio, GPIOF_INIT_HIGH, "MAX9768 Shutdown"); + err = devm_gpio_request_one(&client->dev, pdata->shdn_gpio, + GPIOF_INIT_HIGH, "MAX9768 Shutdown"); max9768->shdn_gpio = err ?: pdata->shdn_gpio; max9768->flags = pdata->flags; @@ -199,37 +201,17 @@ static int max9768_i2c_probe(struct i2c_client *client, i2c_set_clientdata(client, max9768); max9768->regmap = devm_regmap_init_i2c(client, &max9768_i2c_regmap_config); - if (IS_ERR(max9768->regmap)) { - err = PTR_ERR(max9768->regmap); - goto err_gpio_free; - } - - err = snd_soc_register_codec(&client->dev, &max9768_codec_driver, NULL, 0); - if (err) - goto err_gpio_free; - - return 0; + if (IS_ERR(max9768->regmap)) + return PTR_ERR(max9768->regmap); - err_gpio_free: - if (gpio_is_valid(max9768->shdn_gpio)) - gpio_free(max9768->shdn_gpio); - if (gpio_is_valid(max9768->mute_gpio)) - gpio_free(max9768->mute_gpio); - - return err; + return snd_soc_register_codec(&client->dev, &max9768_codec_driver, + NULL, 0); } static int max9768_i2c_remove(struct i2c_client *client) { - struct max9768 *max9768 = i2c_get_clientdata(client); - snd_soc_unregister_codec(&client->dev); - if (gpio_is_valid(max9768->shdn_gpio)) - gpio_free(max9768->shdn_gpio); - if (gpio_is_valid(max9768->mute_gpio)) - gpio_free(max9768->mute_gpio); - return 0; }