From patchwork Mon Nov 26 11:49:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 13209 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 1744B23FC6 for ; Mon, 26 Nov 2012 11:56:52 +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 C04EAA19675 for ; Mon, 26 Nov 2012 11:56:51 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id c10so4419020ieb.11 for ; Mon, 26 Nov 2012 03:56:51 -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=mT4yyo5dZh1QKkmMp1t6JhvWCTkze38VhLieVSvr4RQ=; b=F7wXQZ77SJu69t0S8xRo7vRKqeYMu+EDNe/SC1UhG2Np/xAWOOMyicr9HEFUbIDkbj uBF9+poq82AZn0qCj26yQLszmIhz7HOKglbbI2eLRxvOfBAdZF4HnHxY4N9/cRCQ5/8s wXlB+vaXJJ5zCDlt8FR9L+eOJWdY8v+2PUs3o2Jq07ljRgwQ6sKLwlOkviup8KMe941I Q4//qnkf12VuEJyYDmV0MWnky1/qzU+5py9ZV134DSWJwm1itftv0VJ8dOjZrbCfpqX+ 8hsxWpUT4i23pvcliqdvrM/+dtg1zzslcqaj1eptOYjrZtB1+08xB9ZO1UqtDQ4YwT26 76tA== Received: by 10.50.161.169 with SMTP id xt9mr13169628igb.62.1353931011577; Mon, 26 Nov 2012 03:56:51 -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 n20csp245120igt; Mon, 26 Nov 2012 03:56:51 -0800 (PST) Received: by 10.68.192.66 with SMTP id he2mr36646003pbc.112.1353931010814; Mon, 26 Nov 2012 03:56:50 -0800 (PST) Received: from mail-pb0-f47.google.com (mail-pb0-f47.google.com [209.85.160.47]) by mx.google.com with ESMTPS id ux7si19314947pbc.132.2012.11.26.03.56.50 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 26 Nov 2012 03:56:50 -0800 (PST) Received-SPF: neutral (google.com: 209.85.160.47 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.160.47; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.47 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-pb0-f47.google.com with SMTP id un1so6089263pbc.34 for ; Mon, 26 Nov 2012 03:56:50 -0800 (PST) Received: by 10.69.1.73 with SMTP id be9mr37371547pbd.116.1353931010569; Mon, 26 Nov 2012 03:56:50 -0800 (PST) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id kb3sm8677482pbc.27.2012.11.26.03.56.47 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 26 Nov 2012 03:56:49 -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 11/14] ASoC: wm8962: Use devm_regmap_init_i2c() Date: Mon, 26 Nov 2012 17:19:44 +0530 Message-Id: <1353930587-12907-12-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: ALoCoQkNe4xqfVkvkvZNwydrsVyUaUAklb0Bd07w0oWDZKpa+q2gwXCHopt9GtvmwshwyJbwKeLf devm_regmap_init_i2c() is device managed and makes error handling and code cleanup simpler. Signed-off-by: Sachin Kamat --- sound/soc/codecs/wm8962.c | 17 ++++++----------- 1 files changed, 6 insertions(+), 11 deletions(-) diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c index 285a9ef..8fd38cb 100644 --- a/sound/soc/codecs/wm8962.c +++ b/sound/soc/codecs/wm8962.c @@ -3624,7 +3624,7 @@ static __devinit int wm8962_i2c_probe(struct i2c_client *i2c, return ret; } - wm8962->regmap = regmap_init_i2c(i2c, &wm8962_regmap); + wm8962->regmap = devm_regmap_init_i2c(i2c, &wm8962_regmap); if (IS_ERR(wm8962->regmap)) { ret = PTR_ERR(wm8962->regmap); dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret); @@ -3641,20 +3641,20 @@ static __devinit int wm8962_i2c_probe(struct i2c_client *i2c, ret = regmap_read(wm8962->regmap, WM8962_SOFTWARE_RESET, ®); if (ret < 0) { dev_err(&i2c->dev, "Failed to read ID register\n"); - goto err_regmap; + goto err_enable; } if (reg != 0x6243) { dev_err(&i2c->dev, "Device is not a WM8962, ID %x != 0x6243\n", reg); ret = -EINVAL; - goto err_regmap; + goto err_enable; } ret = regmap_read(wm8962->regmap, WM8962_RIGHT_INPUT_VOLUME, ®); if (ret < 0) { dev_err(&i2c->dev, "Failed to read device revision: %d\n", ret); - goto err_regmap; + goto err_enable; } dev_info(&i2c->dev, "customer id %x revision %c\n", @@ -3667,7 +3667,7 @@ static __devinit int wm8962_i2c_probe(struct i2c_client *i2c, ret = wm8962_reset(wm8962); if (ret < 0) { dev_err(&i2c->dev, "Failed to issue reset\n"); - goto err_regmap; + goto err_enable; } if (pdata && pdata->in4_dc_measure) { @@ -3686,15 +3686,13 @@ static __devinit int wm8962_i2c_probe(struct i2c_client *i2c, ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm8962, &wm8962_dai, 1); if (ret < 0) - goto err_regmap; + goto err_enable; /* The drivers should power up as needed */ regulator_bulk_disable(ARRAY_SIZE(wm8962->supplies), wm8962->supplies); return 0; -err_regmap: - regmap_exit(wm8962->regmap); err_enable: regulator_bulk_disable(ARRAY_SIZE(wm8962->supplies), wm8962->supplies); err: @@ -3703,10 +3701,7 @@ err: static __devexit int wm8962_i2c_remove(struct i2c_client *client) { - struct wm8962_priv *wm8962 = dev_get_drvdata(&client->dev); - snd_soc_unregister_codec(&client->dev); - regmap_exit(wm8962->regmap); return 0; }