From patchwork Wed Nov 28 09:13:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 13263 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 A34442425B for ; Wed, 28 Nov 2012 09:20:25 +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 3EF58A19E07 for ; Wed, 28 Nov 2012 09:20:25 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id c10so7839088ieb.11 for ; Wed, 28 Nov 2012 01:20:24 -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=7zI2QpuUk/mlApc1VyegWJzUfiebiPsOBqpJZH1iVUk=; b=lFktc2UtNuMivcuZ/8bD0S7s5XUe3p5VOGEoyfs+R4nxlu3pYONraw16YDVWUga0aF iMzIW4wls8YSDjKe5ZN2T9H6UzPDfPDdb5P1Q2r5ycelba5NCuKqJPcTmDSeoqULytPB lcM56Hfp0EVUasm29t2z5VEZjXgVC5m3MxZNayL9Lt6Socbmf0MnVg9Etk+4w22RrMUU HcREVO8ZDuzUB/d3LYMLZLY7AfjmXuu1d8e273215OGFVu0f9fTnB78qj/Mjwa44g3DX nXgHKpx9KC+E521BQW39Fx6xyqDmLvSkEiDAi/clhhd7T5hmHpchlPQxSGyHwxfTbhIs COYg== Received: by 10.50.187.197 with SMTP id fu5mr18118008igc.70.1354094424680; Wed, 28 Nov 2012 01:20:24 -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 n20csp614624igt; Wed, 28 Nov 2012 01:20:24 -0800 (PST) Received: by 10.66.90.101 with SMTP id bv5mr50487767pab.42.1354094423737; Wed, 28 Nov 2012 01:20:23 -0800 (PST) Received: from mail-da0-f42.google.com (mail-da0-f42.google.com [209.85.210.42]) by mx.google.com with ESMTPS id t9si27707156paz.316.2012.11.28.01.20.22 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 28 Nov 2012 01:20:23 -0800 (PST) Received-SPF: neutral (google.com: 209.85.210.42 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.210.42; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.42 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-da0-f42.google.com with SMTP id z17so5805937dal.29 for ; Wed, 28 Nov 2012 01:20:22 -0800 (PST) Received: by 10.68.234.36 with SMTP id ub4mr56738042pbc.68.1354094422908; Wed, 28 Nov 2012 01:20:22 -0800 (PST) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id gq10sm12159607pbc.54.2012.11.28.01.20.19 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 28 Nov 2012 01:20:22 -0800 (PST) From: Sachin Kamat To: alsa-devel@alsa-project.org Cc: patches@opensource.wolfsonmicro.com, broonie@opensource.wolfsonmicro.com, lrg@ti.com, tiwai@suse.de, sachin.kamat@linaro.org, patches@linaro.org Subject: [PATCH 1/1] ASoC: wm9090: Use devm_regmap_init_i2c() Date: Wed, 28 Nov 2012 14:43:52 +0530 Message-Id: <1354094032-1701-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQlVTYfTSAlA56+zq2zNotRmadrRnutQy0FisxIjtbWijDIk1tPPp20Sm02SbpTLJcCa2Nda devm_regmap_init_i2c() is device managed and makes error handling and code cleanup simpler. Signed-off-by: Sachin Kamat --- sound/soc/codecs/wm9090.c | 20 ++++++-------------- 1 files changed, 6 insertions(+), 14 deletions(-) diff --git a/sound/soc/codecs/wm9090.c b/sound/soc/codecs/wm9090.c index c7ddc56..bb55a70 100644 --- a/sound/soc/codecs/wm9090.c +++ b/sound/soc/codecs/wm9090.c @@ -628,7 +628,7 @@ static int wm9090_i2c_probe(struct i2c_client *i2c, return -ENOMEM; } - wm9090->regmap = regmap_init_i2c(i2c, &wm9090_regmap); + wm9090->regmap = devm_regmap_init_i2c(i2c, &wm9090_regmap); if (IS_ERR(wm9090->regmap)) { ret = PTR_ERR(wm9090->regmap); dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret); @@ -637,16 +637,16 @@ static int wm9090_i2c_probe(struct i2c_client *i2c, ret = regmap_read(wm9090->regmap, WM9090_SOFTWARE_RESET, ®); if (ret < 0) - goto err; + return ret; + if (reg != 0x9093) { dev_err(&i2c->dev, "Device is not a WM9090, ID=%x\n", reg); - ret = -ENODEV; - goto err; + return -ENODEV; } ret = regmap_write(wm9090->regmap, WM9090_SOFTWARE_RESET, 0); if (ret < 0) - goto err; + return ret; if (i2c->dev.platform_data) memcpy(&wm9090->pdata, i2c->dev.platform_data, @@ -658,23 +658,15 @@ static int wm9090_i2c_probe(struct i2c_client *i2c, &soc_codec_dev_wm9090, NULL, 0); if (ret != 0) { dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); - goto err; + return ret; } return 0; - -err: - regmap_exit(wm9090->regmap); - return ret; } static int __devexit wm9090_i2c_remove(struct i2c_client *i2c) { - struct wm9090_priv *wm9090 = i2c_get_clientdata(i2c); - snd_soc_unregister_codec(&i2c->dev); - regmap_exit(wm9090->regmap); - return 0; }