From patchwork Mon Nov 26 11:49:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 13210 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 41A7723FC6 for ; Mon, 26 Nov 2012 11:56:55 +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 EC14CA1967E for ; Mon, 26 Nov 2012 11:56:54 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id c10so4419020ieb.11 for ; Mon, 26 Nov 2012 03:56:54 -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=1zuKL84t77BKr8xWIX5W65UNZvmjEmDdsWYW+Dsrb8Y=; b=oreiY9B3Qa86FOlZpbcp5xFWecWMogvNpmlGfZB1xEUQaP2ZoN/hqLp6/Ce816mpwG iTdmW+sFqAglj2FlZ9zCbNMJVQgx/EWtGL9WOkLyK7dEJMa3mi7hqnMJzceUQwz+hlDB 6nfXu604bPoOFnNHe9Rii7TfLXxj66zvQ5KdZ38L2GFbsPj/nyOAvNQKwv0vzJlWvVKl N8kR+QEi2Ug7ZS/0H9kROX4FsimXyU9/Yd057QDkdw8U15H0wr+PTu+ROZtdE2f1Dil+ 76mn494qirohGxg+FTadss43q6CvTI5WSkkVcR0RST0FEYx3hBrAeEslDqU9uqp6BDSo sDww== Received: by 10.43.46.2 with SMTP id um2mr9460290icb.18.1353931014717; Mon, 26 Nov 2012 03:56:54 -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 n20csp245126igt; Mon, 26 Nov 2012 03:56:54 -0800 (PST) Received: by 10.68.239.232 with SMTP id vv8mr36813002pbc.53.1353931014252; Mon, 26 Nov 2012 03:56:54 -0800 (PST) Received: from mail-pb0-f52.google.com (mail-pb0-f52.google.com [209.85.160.52]) by mx.google.com with ESMTPS id wn5si19314330pbc.136.2012.11.26.03.56.54 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 26 Nov 2012 03:56:54 -0800 (PST) Received-SPF: neutral (google.com: 209.85.160.52 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.160.52; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.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-pb0-f52.google.com with SMTP id ro2so8891600pbb.39 for ; Mon, 26 Nov 2012 03:56:54 -0800 (PST) Received: by 10.68.143.129 with SMTP id se1mr37425384pbb.67.1353931014013; Mon, 26 Nov 2012 03:56:54 -0800 (PST) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id kb3sm8677482pbc.27.2012.11.26.03.56.50 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 26 Nov 2012 03:56:53 -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 12/14] ASoC: wm8978: Use devm_regmap_init_i2c() Date: Mon, 26 Nov 2012 17:19:45 +0530 Message-Id: <1353930587-12907-13-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: ALoCoQmKolJZIENyBTH/Bo86D/4shRzNndgFDJB2XnVpQmRrTerLThXjBozv3SP+Dwueq4kIDgmo devm_regmap_init_i2c() is device managed and makes error handling and code cleanup simpler. Signed-off-by: Sachin Kamat --- sound/soc/codecs/wm8978.c | 13 +++---------- 1 files changed, 3 insertions(+), 10 deletions(-) diff --git a/sound/soc/codecs/wm8978.c b/sound/soc/codecs/wm8978.c index 8c1dac9..ef46700 100644 --- a/sound/soc/codecs/wm8978.c +++ b/sound/soc/codecs/wm8978.c @@ -1046,7 +1046,7 @@ static __devinit int wm8978_i2c_probe(struct i2c_client *i2c, if (wm8978 == NULL) return -ENOMEM; - wm8978->regmap = regmap_init_i2c(i2c, &wm8978_regmap_config); + wm8978->regmap = devm_regmap_init_i2c(i2c, &wm8978_regmap_config); if (IS_ERR(wm8978->regmap)) { ret = PTR_ERR(wm8978->regmap); dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret); @@ -1059,29 +1059,22 @@ static __devinit int wm8978_i2c_probe(struct i2c_client *i2c, ret = regmap_write(wm8978->regmap, WM8978_RESET, 0); if (ret != 0) { dev_err(&i2c->dev, "Failed to issue reset: %d\n", ret); - goto err; + return ret; } ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm8978, &wm8978_dai, 1); if (ret != 0) { dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); - goto err; + return ret; } return 0; - -err: - regmap_exit(wm8978->regmap); - return ret; } static __devexit int wm8978_i2c_remove(struct i2c_client *client) { - struct wm8978_priv *wm8978 = i2c_get_clientdata(client); - snd_soc_unregister_codec(&client->dev); - regmap_exit(wm8978->regmap); return 0; }