From patchwork Fri Dec 7 11:02:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 13414 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 7EC1923E2C for ; Fri, 7 Dec 2012 11:09:23 +0000 (UTC) Received: from mail-ie0-f176.google.com (mail-ie0-f176.google.com [209.85.223.176]) by fiordland.canonical.com (Postfix) with ESMTP id 2B9F4A19387 for ; Fri, 7 Dec 2012 11:09:23 +0000 (UTC) Received: by mail-ie0-f176.google.com with SMTP id 13so841674iea.21 for ; Fri, 07 Dec 2012 03:09:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=Yzv8n+Lr0ITfb1HMBfc9zkpD+O1pyoF/ZgOlB6MOZ2g=; b=WlWPuXAWTsoaYDUdfxOoZ+8+ofAD1yKpJIIEF6rKiaoxeIDPMVXusPY2MkbAKdO1Sp Hcjnh1RU637P13LZgWScY8JfLjVqEA7+Jih6Z/uA3Cu894wQPWoEJ1UCsNQw/GMxSY5s /mhdvP0c7zG3b5Ij0VlFZiy0gDLjiu23LphZjbu9GdwcnO1pb1SE8TQyJ/FuCTk87Ptj 82rv5y7VK7L+19QCPozeAFXaJx106VRjaCvq/15RzGP5RCjWTB5DdkMX4YLbCKTdwLA4 7w93pQflyI7yt8DGgWtTFoXQZY8jqCruOoLAhML51peMgZuTQ+s+YZYrhd+8HFY8z766 5Ulg== Received: by 10.50.173.34 with SMTP id bh2mr4520970igc.70.1354878562405; Fri, 07 Dec 2012 03:09:22 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp467446igt; Fri, 7 Dec 2012 03:09:21 -0800 (PST) Received: by 10.68.244.135 with SMTP id xg7mr14741814pbc.87.1354878561384; Fri, 07 Dec 2012 03:09:21 -0800 (PST) Received: from mail-pa0-f52.google.com (mail-pa0-f52.google.com [209.85.220.52]) by mx.google.com with ESMTPS id bf10si14842110pab.195.2012.12.07.03.09.20 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 07 Dec 2012 03:09:21 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.52 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.220.52; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.52 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) smtp.mail=sachin.kamat@linaro.org Received: by mail-pa0-f52.google.com with SMTP id fb1so377041pad.11 for ; Fri, 07 Dec 2012 03:09:20 -0800 (PST) Received: by 10.66.75.66 with SMTP id a2mr8045214paw.65.1354878560779; Fri, 07 Dec 2012 03:09:20 -0800 (PST) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id uq5sm6528025pbc.56.2012.12.07.03.09.16 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 07 Dec 2012 03:09:20 -0800 (PST) From: Sachin Kamat To: alsa-devel@alsa-project.org Cc: lrg@ti.com, broonie@opensource.wolfsonmicro.com, perex@perex.cz, tiwai@suse.de, sachin.kamat@linaro.org, patches@linaro.org, Peter Ujfalusi Subject: [PATCH 1/1] ASoC: tpa6130a2: Use devm_* APIs Date: Fri, 7 Dec 2012 16:32:26 +0530 Message-Id: <1354878146-28222-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQk0HXiJSlxalL29ck1meq12hkExKhocGQSKk4UM3xQZeaqYwVx48V0TujK1fBGb59U/9xfK Converted to use devm_gpio_request and devm_regulator_get APIs. These are device managed and make error handling and cleanup a bit simpler. Cc: Peter Ujfalusi Signed-off-by: Sachin Kamat --- Compile tested on for-next branch of following tree: git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git --- sound/soc/codecs/tpa6130a2.c | 23 ++++++----------------- 1 files changed, 6 insertions(+), 17 deletions(-) diff --git a/sound/soc/codecs/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c index 565ff39..ec78073 100644 --- a/sound/soc/codecs/tpa6130a2.c +++ b/sound/soc/codecs/tpa6130a2.c @@ -398,7 +398,8 @@ static int __devinit tpa6130a2_probe(struct i2c_client *client, TPA6130A2_MUTE_L; if (data->power_gpio >= 0) { - ret = gpio_request(data->power_gpio, "tpa6130a2 enable"); + ret = devm_gpio_request(dev, data->power_gpio, + "tpa6130a2 enable"); if (ret < 0) { dev_err(dev, "Failed to request power GPIO (%d)\n", data->power_gpio); @@ -419,16 +420,16 @@ static int __devinit tpa6130a2_probe(struct i2c_client *client, break; } - data->supply = regulator_get(dev, regulator); + data->supply = devm_regulator_get(dev, regulator); if (IS_ERR(data->supply)) { ret = PTR_ERR(data->supply); dev_err(dev, "Failed to request supply: %d\n", ret); - goto err_regulator; + goto err_gpio; } ret = tpa6130a2_power(1); if (ret != 0) - goto err_power; + goto err_gpio; /* Read version */ @@ -440,15 +441,10 @@ static int __devinit tpa6130a2_probe(struct i2c_client *client, /* Disable the chip */ ret = tpa6130a2_power(0); if (ret != 0) - goto err_power; + goto err_gpio; return 0; -err_power: - regulator_put(data->supply); -err_regulator: - if (data->power_gpio >= 0) - gpio_free(data->power_gpio); err_gpio: tpa6130a2_client = NULL; @@ -457,14 +453,7 @@ err_gpio: static int __devexit tpa6130a2_remove(struct i2c_client *client) { - struct tpa6130a2_data *data = i2c_get_clientdata(client); - tpa6130a2_power(0); - - if (data->power_gpio >= 0) - gpio_free(data->power_gpio); - - regulator_put(data->supply); tpa6130a2_client = NULL; return 0;