From patchwork Mon Nov 26 11:49:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 13212 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 0B12423FC6 for ; Mon, 26 Nov 2012 11:57:02 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 977DBA1968A for ; Mon, 26 Nov 2012 11:57:01 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id c10so4419020ieb.11 for ; Mon, 26 Nov 2012 03:57:01 -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:in-reply-to:references :x-gm-message-state; bh=X+AqIGg8nNgt+Ne2voa7AR/078rTd22uXLUswnkswhA=; b=cYzsErQdd0lZY6cx0AafzoF/jPo8JOkqh1I7AK9CobkQlD23GdCcUVjjqHnGf0paLB n6iWlRdUW08qcYbCOyTgqvUIBbMxuCGK4pQQkJAIz115INH4rso+3YVGkQJZfUenBpVG shjl44RsXUrLSj04njmqJsM3H4MKe8JMskJzFy+6KtQmqC517tR5S3nnbaU5JoupwhPr UqiVKHjO4NldB3qTlgzSal8BbG7JSfpi6h7Zbb781JdLIJcSXw5yekLQ5+cc6paFrMs9 duvePwa+i1mhsbIy42Mu9Yn/OYKDO9r4r1DXYNUuOZQrB72RWjljWcRoR+2mjofaNCn1 8ysg== Received: by 10.50.42.168 with SMTP id p8mr10704278igl.57.1353931021377; Mon, 26 Nov 2012 03:57:01 -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 n20csp245134igt; Mon, 26 Nov 2012 03:57:01 -0800 (PST) Received: by 10.66.85.195 with SMTP id j3mr32372523paz.1.1353931020857; Mon, 26 Nov 2012 03:57:00 -0800 (PST) Received: from mail-pa0-f51.google.com (mail-pa0-f51.google.com [209.85.220.51]) by mx.google.com with ESMTPS id gk10si19289871pbc.236.2012.11.26.03.57.00 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 26 Nov 2012 03:57:00 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.51 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.220.51; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.51 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-f51.google.com with SMTP id fb11so5022507pad.24 for ; Mon, 26 Nov 2012 03:57:00 -0800 (PST) Received: by 10.68.243.70 with SMTP id ww6mr37270394pbc.108.1353931020557; Mon, 26 Nov 2012 03:57:00 -0800 (PST) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id kb3sm8677482pbc.27.2012.11.26.03.56.57 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 26 Nov 2012 03:57:00 -0800 (PST) From: Sachin Kamat To: alsa-devel@alsa-project.org Cc: broonie@opensource.wolfsonmicro.com, lrg@ti.com, tiwai@suse.de, sachin.kamat@linaro.org, patches@linaro.org Subject: [PATCH 14/14] ASoC: wm9081: Use devm_regmap_init_i2c() Date: Mon, 26 Nov 2012 17:19:47 +0530 Message-Id: <1353930587-12907-15-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1353930587-12907-1-git-send-email-sachin.kamat@linaro.org> References: <1353930587-12907-1-git-send-email-sachin.kamat@linaro.org> X-Gm-Message-State: ALoCoQmgsft0j25b67Rdot9xzawL0ixj7tAP6iJW10Hg4fipccinukpSTXUaGQbBLZTg85x7wKet devm_regmap_init_i2c() is device managed and makes error handling and code cleanup simpler. Signed-off-by: Sachin Kamat --- sound/soc/codecs/wm9081.c | 22 ++++++---------------- 1 files changed, 6 insertions(+), 16 deletions(-) diff --git a/sound/soc/codecs/wm9081.c b/sound/soc/codecs/wm9081.c index 2de74e1..860144e 100644 --- a/sound/soc/codecs/wm9081.c +++ b/sound/soc/codecs/wm9081.c @@ -1341,28 +1341,27 @@ static __devinit int wm9081_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, wm9081); - wm9081->regmap = regmap_init_i2c(i2c, &wm9081_regmap); + wm9081->regmap = devm_regmap_init_i2c(i2c, &wm9081_regmap); if (IS_ERR(wm9081->regmap)) { ret = PTR_ERR(wm9081->regmap); dev_err(&i2c->dev, "regmap_init() failed: %d\n", ret); - goto err; + return ret; } ret = regmap_read(wm9081->regmap, WM9081_SOFTWARE_RESET, ®); if (ret != 0) { dev_err(&i2c->dev, "Failed to read chip ID: %d\n", ret); - goto err_regmap; + return ret; } if (reg != 0x9081) { dev_err(&i2c->dev, "Device is not a WM9081: ID=0x%x\n", reg); - ret = -EINVAL; - goto err_regmap; + return -EINVAL; } ret = wm9081_reset(wm9081->regmap); if (ret < 0) { dev_err(&i2c->dev, "Failed to issue reset\n"); - goto err_regmap; + return ret; } if (dev_get_platdata(&i2c->dev)) @@ -1382,23 +1381,14 @@ static __devinit int wm9081_i2c_probe(struct i2c_client *i2c, ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm9081, &wm9081_dai, 1); if (ret < 0) - goto err_regmap; + return ret; return 0; - -err_regmap: - regmap_exit(wm9081->regmap); -err: - - return ret; } static __devexit int wm9081_i2c_remove(struct i2c_client *client) { - struct wm9081_priv *wm9081 = i2c_get_clientdata(client); - snd_soc_unregister_codec(&client->dev); - regmap_exit(wm9081->regmap); return 0; }