From patchwork Fri Oct 13 01:21:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 10003357 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 70140602BF for ; Fri, 13 Oct 2017 01:21:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6163A28738 for ; Fri, 13 Oct 2017 01:21:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5652328F32; Fri, 13 Oct 2017 01:21:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5583D28738 for ; Fri, 13 Oct 2017 01:21:30 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 62D30266FBF; Fri, 13 Oct 2017 03:21:28 +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 B66B4267030; Fri, 13 Oct 2017 03:21:26 +0200 (CEST) Received: from mail-pf0-f194.google.com (mail-pf0-f194.google.com [209.85.192.194]) by alsa0.perex.cz (Postfix) with ESMTP id 6FE2B266FAD for ; Fri, 13 Oct 2017 03:21:23 +0200 (CEST) Received: by mail-pf0-f194.google.com with SMTP id p87so7504791pfj.3 for ; Thu, 12 Oct 2017 18:21:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ingics-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=JNGeI9SuzuAVbMwjYJ64bHHFRU+3cAlGAbCV2iPDxWs=; b=RhyQOLQfMqbz2MRNJSUpLLWUjlwsxBJYL71m8rAx5LdZuw9hn5ExgxpqG/wxoBsgtb 9vHJ3KGN+tJ3mwcI6nmsLKD+cgxp2KwDNJF9+DIxWHLdXjRUO2C8zr3AWDrYRC++ADBT oIEfKmtqQynEnDedbBhhfy44Pob8LXwhVTXPMxs0uGaaMKLpfvV1mfZeOtzHVUC5KgxR Xzg8BGteFFJoPs7bI+OZC8UjlNQ7sME8zXwEgXsmysPycQ+DlbTgKtnZVYj6nDNtD98D 9jfUNzNkeKTGU6fN6tWH/BfI2j5kRdnjAiS1CyafH8nAiGKo8oRWVpsYJ7xuTQC1GBvb HCPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=JNGeI9SuzuAVbMwjYJ64bHHFRU+3cAlGAbCV2iPDxWs=; b=OLy/hljKwenrDWhNTsbp3gqEf/rlL3Mn6T/lGXnbrMolCfA329+T19YAwPKfCdRozs 4YHBiqostyCwxEyNB9IWuxkjkSLO5Gkwg7aLiebTTbNKOEfx5BX9pC5RzEC636Ku9RsM hy2KCeL4iHdgSnTuPXHVgsiBTF6x4shOilkmAWc/V0h8n/Mn762LeqX9bCzcJR6ZWTYd JrkRVvCh2Tr333X0MOYj4X8La7YRejYnbsqUzwbTnRNgrGN+jy+aLQFoqht0SCeWeqK4 aOCVnpZqAd+/dgUe2+/ykwOjfk6LrY9EWx3pq2h7EY21NmRw/O1CpOLCwECwD+qf8dAz 2y1g== X-Gm-Message-State: AMCzsaXkML/Hj1gwGkwD70oNGosVUeSnIfuFMTZkJALWki6VJ9ynvDrF xSFvsP26ADqJxmpMk7H1lmeMQQ== X-Google-Smtp-Source: AOwi7QAEA5o3LsIMfDUlt4fxs2QKdkDJ5BQs1qf8YLeYmzUrexL4ubqFV8MnSt0RV8Ha492MIvX3hA== X-Received: by 10.98.89.219 with SMTP id k88mr3643937pfj.229.1507857681641; Thu, 12 Oct 2017 18:21:21 -0700 (PDT) Received: from localhost.localdomain ([36.239.240.7]) by smtp.gmail.com with ESMTPSA id i11sm6759592pgc.88.2017.10.12.18.21.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Oct 2017 18:21:20 -0700 (PDT) From: Axel Lin To: Mark Brown Date: Fri, 13 Oct 2017 09:21:01 +0800 Message-Id: <20171013012101.17715-1-axel.lin@ingics.com> X-Mailer: git-send-email 2.11.0 Cc: Anish Kumar , alsa-devel@alsa-project.org, Axel Lin , Liam Girdwood Subject: [alsa-devel] [PATCH] ASoC: max98925: Return proper error if revision mismatch 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Return proper error instead of 0 if the revision does not match. Signed-off-by: Axel Lin --- sound/soc/codecs/max98925.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/sound/soc/codecs/max98925.c b/sound/soc/codecs/max98925.c index 327eaa25c9bd..921f95fc396d 100644 --- a/sound/soc/codecs/max98925.c +++ b/sound/soc/codecs/max98925.c @@ -579,7 +579,7 @@ static int max98925_i2c_probe(struct i2c_client *i2c, ret = PTR_ERR(max98925->regmap); dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret); - goto err_out; + return ret; } if (!of_property_read_u32(i2c->dev.of_node, "vmon-slot-no", &value)) { @@ -596,16 +596,20 @@ static int max98925_i2c_probe(struct i2c_client *i2c, } max98925->i_slot = value; } - ret = regmap_read(max98925->regmap, - MAX98925_REV_VERSION, ®); - if ((ret < 0) || - ((reg != MAX98925_VERSION) && - (reg != MAX98925_VERSION1))) { - dev_err(&i2c->dev, - "device initialization error (%d 0x%02X)\n", + + ret = regmap_read(max98925->regmap, MAX98925_REV_VERSION, ®); + if (ret < 0) { + dev_err(&i2c->dev, "Read revision failed\n"); + return ret; + } + + if ((reg != MAX98925_VERSION) && (reg != MAX98925_VERSION1)) { + ret = -ENODEV; + dev_err(&i2c->dev, "Invalid revision (%d 0x%02X)\n", ret, reg); - goto err_out; + return ret; } + dev_info(&i2c->dev, "device version 0x%02X\n", reg); ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_max98925, @@ -613,7 +617,6 @@ static int max98925_i2c_probe(struct i2c_client *i2c, if (ret < 0) dev_err(&i2c->dev, "Failed to register codec: %d\n", ret); -err_out: return ret; }