From patchwork Thu Jun 25 13:41:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 6675211 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4E0DA9F399 for ; Thu, 25 Jun 2015 13:42:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 70864206E8 for ; Thu, 25 Jun 2015 13:42:15 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 2D20E20630 for ; Thu, 25 Jun 2015 13:42:14 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id BA47D2605BD; Thu, 25 Jun 2015 15:42:12 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 78C90260593; Thu, 25 Jun 2015 15:42:04 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 8264B2605AE; Thu, 25 Jun 2015 15:42:03 +0200 (CEST) Received: from mail-pa0-f49.google.com (mail-pa0-f49.google.com [209.85.220.49]) by alsa0.perex.cz (Postfix) with ESMTP id 36B80260577 for ; Thu, 25 Jun 2015 15:41:53 +0200 (CEST) Received: by pabvl15 with SMTP id vl15so50280815pab.1 for ; Thu, 25 Jun 2015 06:41:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:content-type :mime-version:content-transfer-encoding; bh=nd6xR2k8bJTcq+ihVb5mM1OTItmYfdwTWC7C90GccSA=; b=Lah8VqguKlEJBIizPq/pWKswY/RwEs+EnnEnzfelB+XBk71S6kjM9x6C2WbErlrC0X Dk7vT1w+DpkHY1SGL9hQHv/T3BqyUOvQPcSwcdEwYM9/uQfczlKzOtCkH2PFKJj/XX9m oSWpaZdi/SiUeVsggLFLqliL0gW9zOqNjma9T/HYNV23EgXWQRIT5IPsP6s/qZXOAVau je3zDMttSy9oAChRD4rZULziSclFhdY5pxoRA6dpPAEhAsyk2ln0t0gQHKPc5s7cwes9 mwmenBoz4oJaDwo1hhiXGbwgnEgHg4EGeET9ALN069BY0rRcMGQ0sEd6ZQ4EJHr9WSO9 neWw== X-Gm-Message-State: ALoCoQlLlCVb0RTmrkp2XwWa7ZYOgIayHAbWlfFglDJmF8GXLck5mKLX0jmQ/X3xgA8W4JRjvUrc X-Received: by 10.66.192.1 with SMTP id hc1mr91150833pac.38.1435239709194; Thu, 25 Jun 2015 06:41:49 -0700 (PDT) Received: from phoenix.local (36-239-240-88.dynamic-ip.hinet.net. [36.239.240.88]) by mx.google.com with ESMTPSA id ja1sm30133797pbc.51.2015.06.25.06.41.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jun 2015 06:41:47 -0700 (PDT) Message-ID: <1435239703.22170.1.camel@ingics.com> From: Axel Lin To: Mark Brown Date: Thu, 25 Jun 2015 21:41:43 +0800 X-Mailer: Evolution 3.12.10-0ubuntu1~14.10.1 Mime-Version: 1.0 Cc: Brian Austin , alsa-devel@alsa-project.org, Liam Girdwood , Paul Handrigan Subject: [alsa-devel] [PATCH 1/2] ASoC: cs42xx8: Move the code checking *regmap argument earlier X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Slightly improve the readability by moving the code checking *regmap argument earlier. Also move the assignment of of_id close to the place testing it. Signed-off-by: Axel Lin --- sound/soc/codecs/cs42xx8.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/sound/soc/codecs/cs42xx8.c b/sound/soc/codecs/cs42xx8.c index e1d4686..ab39514 100644 --- a/sound/soc/codecs/cs42xx8.c +++ b/sound/soc/codecs/cs42xx8.c @@ -435,16 +435,24 @@ EXPORT_SYMBOL_GPL(cs42xx8_of_match); int cs42xx8_probe(struct device *dev, struct regmap *regmap) { - const struct of_device_id *of_id = of_match_device(cs42xx8_of_match, dev); + const struct of_device_id *of_id; struct cs42xx8_priv *cs42xx8; int ret, val, i; + if (IS_ERR(regmap)) { + ret = PTR_ERR(regmap); + dev_err(dev, "failed to allocate regmap: %d\n", ret); + return ret; + } + cs42xx8 = devm_kzalloc(dev, sizeof(*cs42xx8), GFP_KERNEL); if (cs42xx8 == NULL) return -ENOMEM; + cs42xx8->regmap = regmap; dev_set_drvdata(dev, cs42xx8); + of_id = of_match_device(cs42xx8_of_match, dev); if (of_id) cs42xx8->drvdata = of_id->data; @@ -482,13 +490,6 @@ int cs42xx8_probe(struct device *dev, struct regmap *regmap) /* Make sure hardware reset done */ msleep(5); - cs42xx8->regmap = regmap; - if (IS_ERR(cs42xx8->regmap)) { - ret = PTR_ERR(cs42xx8->regmap); - dev_err(dev, "failed to allocate regmap: %d\n", ret); - goto err_enable; - } - /* * We haven't marked the chip revision as volatile due to * sharing a register with the right input volume; explicitly