From patchwork Fri Apr 4 03:04:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 3935541 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 77A39BFF02 for ; Fri, 4 Apr 2014 03:05:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 852A220374 for ; Fri, 4 Apr 2014 03:05:00 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 1910F202A1 for ; Fri, 4 Apr 2014 03:04:59 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 63028265738; Fri, 4 Apr 2014 05:04:57 +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 CC058265728; Fri, 4 Apr 2014 05:04:51 +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 75D0D265728; Fri, 4 Apr 2014 05:04:50 +0200 (CEST) Received: from mail-pa0-f43.google.com (mail-pa0-f43.google.com [209.85.220.43]) by alsa0.perex.cz (Postfix) with ESMTP id 42D0D26572A for ; Fri, 4 Apr 2014 05:04:42 +0200 (CEST) Received: by mail-pa0-f43.google.com with SMTP id bj1so2780326pad.16 for ; Thu, 03 Apr 2014 20:04:40 -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=8QLTKsZeIFVAtaDCgAuutiTCaknSmRGcVUd5K+G+uso=; b=X+GN+em5M9EXYlutNgd4ADFTIHkNcDtyPROiE5Nt4/SU09h9x8PZiddF+LcgeTe7VH wEWXMJIDYbOEuhutLdszyZ/xzdFP9TY6QTMmOhLcPZIjAhIBWiYNl4nIYrpBW2MoedQn 4aJmZ1YfMNAQwB+GozIw+5RVuABJBEIQJC0aYfebzLtpyC6p2jJQj/xgTMq5HIPx0UjK IihZkdtyhEAmyOq5dG4TrVKm2WtpNEXZXqfFqkB5R0XZZDhEMXZWtjQekFYgZpZU/YUd aUtbczJtOoRV5+s7o885MHBNj7kiLm/mj6PjgBmkZmORTRVpqvJCkOhXdH2abJj2Tiw0 V5xw== X-Gm-Message-State: ALoCoQnIsLz1FoHcjhJ2HU9d0L4WdEH3bEwshef4o2gb8l3xeAP01nPiMqkHhnB6wHJLx9AyRb2L X-Received: by 10.66.190.138 with SMTP id gq10mr11943521pac.108.1396580680719; Thu, 03 Apr 2014 20:04:40 -0700 (PDT) Received: from [192.168.0.102] (218-164-138-19.dynamic.hinet.net. [218.164.138.19]) by mx.google.com with ESMTPSA id et3sm14314036pbc.52.2014.04.03.20.04.37 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 03 Apr 2014 20:04:39 -0700 (PDT) Message-ID: <1396580675.9690.0.camel@phoenix> From: Axel Lin To: Mark Brown Date: Fri, 04 Apr 2014 11:04:35 +0800 X-Mailer: Evolution 3.8.4-0ubuntu1 Mime-Version: 1.0 Cc: Brian Austin , alsa-devel@alsa-project.org, Liam Girdwood , Paul Handrigan , Nicolin Chen Subject: [alsa-devel] [PATCH v2] ASoC: cs42xx8: Check return value of regmap_read and report correct chipid value 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 Fix checking return value of regmap_read(). Also fix reporting the chip_id value. CS42XX8_CHIPID_CHIP_ID_MASK is 0xF0, so the chip_id value is (val & CS42XX8_CHIPID_CHIP_ID_MASK) >> 4). Signed-off-by: Axel Lin Acked-by: Paul Handrigan Acked-by: Brian Austin Acked-by: Nicolin Chen --- sound/soc/codecs/cs42xx8.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/sound/soc/codecs/cs42xx8.c b/sound/soc/codecs/cs42xx8.c index 082299a..8502032 100644 --- a/sound/soc/codecs/cs42xx8.c +++ b/sound/soc/codecs/cs42xx8.c @@ -495,17 +495,16 @@ int cs42xx8_probe(struct device *dev, struct regmap *regmap) regcache_cache_bypass(cs42xx8->regmap, true); /* Validate the chip ID */ - regmap_read(cs42xx8->regmap, CS42XX8_CHIPID, &val); - if (val < 0) { - dev_err(dev, "failed to get device ID: %x", val); - ret = -EINVAL; + ret = regmap_read(cs42xx8->regmap, CS42XX8_CHIPID, &val); + if (ret < 0) { + dev_err(dev, "failed to get device ID, ret = %d", ret); goto err_enable; } /* The top four bits of the chip ID should be 0000 */ - if ((val & CS42XX8_CHIPID_CHIP_ID_MASK) != 0x00) { + if (((val & CS42XX8_CHIPID_CHIP_ID_MASK) >> 4) != 0x00) { dev_err(dev, "unmatched chip ID: %d\n", - val & CS42XX8_CHIPID_CHIP_ID_MASK); + (val & CS42XX8_CHIPID_CHIP_ID_MASK) >> 4); ret = -EINVAL; goto err_enable; }