From patchwork Wed Dec 9 09:05:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?RGVyZWsgW+aWueW+t+e+qV0=?= X-Patchwork-Id: 341097 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A742C4361B for ; Wed, 9 Dec 2020 09:07:13 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 82C8E23B7E for ; Wed, 9 Dec 2020 09:07:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 82C8E23B7E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=realtek.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id D9C3516C1; Wed, 9 Dec 2020 10:06:18 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D9C3516C1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1607504829; bh=mOwmnHWylGS4Qq6p5ZBplP3DwKaEUjCVxY02rieGejA=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=J+z0ZUp0opI+Xx3Nm0+ccQtodMNyPBMC2KtqV76NBt+K6oSCbwYhuqiNwaVe4TPZm OOmINVvrHspzltWOwnSg9bFnPa/KMXc4hm42Ko3eVxTyC6qcUuVozJep/WZhPgOZMK lxvGHAD2k+YonSA/BDiahM4ch4P7iNOG+1hIrZPw= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 200D2F801D8; Wed, 9 Dec 2020 10:06:18 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 723BEF8020D; Wed, 9 Dec 2020 10:06:16 +0100 (CET) Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A2486F800E1 for ; Wed, 9 Dec 2020 10:06:08 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A2486F800E1 Authenticated-By: X-SpamFilter-By: ArmorX SpamTrap 5.73 with qID 0B9960Ff8010685, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexmbs01.realtek.com.tw[172.21.6.36]) by rtits2.realtek.com.tw (8.15.2/2.70/5.88) with ESMTPS id 0B9960Ff8010685 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Wed, 9 Dec 2020 17:06:00 +0800 Received: from localhost.localdomain (172.22.238.213) by RTEXMBS01.realtek.com.tw (172.21.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Wed, 9 Dec 2020 17:05:59 +0800 From: To: , Subject: [PATCH] ASoC: rt1015: check the return value of regmap_read during i2c probe Date: Wed, 9 Dec 2020 17:05:49 +0800 Message-ID: <20201209090549.32325-1-derek.fang@realtek.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [172.22.238.213] X-ClientProxiedBy: RTEXMB06.realtek.com.tw (172.21.6.99) To RTEXMBS01.realtek.com.tw (172.21.6.36) Cc: oder_chiou@realtek.com, jack.yu@realtek.com, alsa-devel@alsa-project.org, lars@metafoo.de, "derek.fang" , albertchen@realtek.com, derek.fang@realtek.com, shumingf@realtek.com, flove@realtek.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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" From: "derek.fang" In some projects, the device ID register is not read correctly. This patch helps to verify the issue is caused from i2c host or client. Signed-off-by: derek.fang diff --git a/sound/soc/codecs/rt1015.c b/sound/soc/codecs/rt1015.c index ac4c9f43b338..32e6bcf763d1 100644 --- a/sound/soc/codecs/rt1015.c +++ b/sound/soc/codecs/rt1015.c @@ -1207,8 +1207,13 @@ static int rt1015_i2c_probe(struct i2c_client *i2c, rt1015->hw_config = (i2c->addr == 0x29) ? RT1015_HW_29 : RT1015_HW_28; - regmap_read(rt1015->regmap, RT1015_DEVICE_ID, &val); - if ((val != RT1015_DEVICE_ID_VAL) && (val != RT1015_DEVICE_ID_VAL2)) { + ret = regmap_read(rt1015->regmap, RT1015_DEVICE_ID, &val); + if (ret) { + dev_err(&i2c->dev, + "Failed to read device register: %d\n", ret); + return ret; + } else if ((val != RT1015_DEVICE_ID_VAL) && + (val != RT1015_DEVICE_ID_VAL2)) { dev_err(&i2c->dev, "Device with ID register %x is not rt1015\n", val); return -ENODEV;