Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2222294pxa; Mon, 17 Aug 2020 04:30:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzB/umJRg6AoYL1nTWmzMajD3c4LwTfhwogjQbhqJI/9Eb7oDGahbU9r+Iu7pTpePdy3EM2 X-Received: by 2002:a17:906:bcc4:: with SMTP id lw4mr14064968ejb.361.1597663839752; Mon, 17 Aug 2020 04:30:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597663839; cv=none; d=google.com; s=arc-20160816; b=Smdp1/gcg9f0EGYBdOVihTwDauGjuyu6Gy9uDRbWFHabfzpZgl0eLXaWH0IMCRltr9 hfZGblrnOJMdPlSN+/YYTApGCzNS3c93/PiKOFUgcgL0lHlhnerUfWp2fWij6UiUAcTG 3Qgpw7XYGowJArAYZU5zuRRubpo4ZgZ36gDUea65W4Af7Z1/Hjf8cgtBGZHyBN6V9p/m C2ib/rYtqTKlaG8k8mDqTFck1MlX6/ZNhlsIBY1ar22gGk83EN9Vzbd2HoHyh2k0cdYd 7UIg3m48orjPcm15dS6I8k1L51dfnhRI6rR5RteFRxJzCNgjUIrHHC7cu++phbadHvIe 8jdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=sPIOzSYU2pA/shBWLkg3uMxU0iGcVrzwOJmIFEIBLoQ=; b=h9NF2shX8QChL+AfkxRatd1UBD7Pi5rrC0NakgYGGT+nbWUDmnwy3XATI6ZpKAAira VHifQ59ntrZpZ4VhtS1xKuBcFOOB0TNmJz0IhZQqiarFg9QprOsz2jByRS2DBQ6r29ut Bc10heO2rxI82EWr2Jyox8+kcR/Xd8EKMMWPyegoTVs5HlQ7csfw6YlUXjWeeTSkj7El fWmydDadQ9RfjK16rPAG63dYHq6Ge018hfriHLbCIr/0mThz2qxc65QuIJyQ6GN/kWIN cUziIjj76JTTbk53+HtsXbH5zGHoxWu7U9wyXcDw92jEXwS9UjMTJGtceNEnHgy0UKo6 C4tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WF0M9K4q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n2si11653554edi.15.2020.08.17.04.30.17; Mon, 17 Aug 2020 04:30:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WF0M9K4q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728144AbgHQKtg (ORCPT + 99 others); Mon, 17 Aug 2020 06:49:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728021AbgHQKtE (ORCPT ); Mon, 17 Aug 2020 06:49:04 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB195C061342 for ; Mon, 17 Aug 2020 03:49:03 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id l60so7628223pjb.3 for ; Mon, 17 Aug 2020 03:49:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sPIOzSYU2pA/shBWLkg3uMxU0iGcVrzwOJmIFEIBLoQ=; b=WF0M9K4qZfloylecr5h6eHHhbZo4v4jnG3xWzd31FIRUdUPiqziOo30YtVMKjdVbnO WLm5UgWvlu/Cq4lQOx7z55R/76JyjUrlA+OuKLmnkpSSf5DgdqZNiDnLYEf+FbLVjcDu m+TuUEk2aIA2hKBtGsq/ICSaeAd6D9x1XwVzLpdbiXHLfAPpM6xbFyuwM0EggAIWFyUy aM0Vi6lGYnpQvbKsJ89330vL4etCKZMzQvNTtzuQmW2gRpm9WdVomF2vQlPt54OGBeEu ysqEfPUO/owx2GGru54j9vQmxmhY8bFbWxqIipvO3hFoGU8V2zrxBAdv8tZ9Fu/UtOJe 1Hmg== 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:in-reply-to :references; bh=sPIOzSYU2pA/shBWLkg3uMxU0iGcVrzwOJmIFEIBLoQ=; b=TsT5cXulRjHtpt7WEm6avV2MrUMicLqpBfqaihE4Y+prEgyN1iBkj8sKPjwduNaJ68 pSdCBMFhAI645IdAxwbr3jo/u+SJwKB0lgw5xbufnI0KMmPFDQ/9+CZsDjcw2DB6raOc OM1SO6uuUCB+9NZ/NjxFwgxnFE7viGNBECLRCIPW9LkiDRevc34ZToXhJw2gxHwazQa0 XKn1Wv7aNGGs6Zx4UcxuFinhMY3Lagun3l7JOk2h2BMhBp2MDnow+L/yFkbRX5HRp797 FrjCd0O25EnjQAUpSlCmAfrQROcnw1Khgs221VZ/b5T7IG2pndiKTfHpijEA5qIczSek Dylg== X-Gm-Message-State: AOAM531GUK1c1X4Fzm5hzCllkn43EXN/TMvwpNms+UYKUPgbY9pD7h5G OuR6dUJc3rRnFz32V/JOZGA= X-Received: by 2002:a17:90a:cb08:: with SMTP id z8mr12003882pjt.41.1597661343516; Mon, 17 Aug 2020 03:49:03 -0700 (PDT) Received: from localhost.localdomain ([2402:7500:577:c217:67e6:a40c:a3bf:1945]) by smtp.gmail.com with ESMTPSA id k12sm16976528pjp.38.2020.08.17.03.49.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Aug 2020 03:49:03 -0700 (PDT) From: Gene Chen To: lee.jones@linaro.org, matthias.bgg@gmail.com Cc: linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, gene_chen@richtek.com, benjamin.chao@mediatek.com, shufan_lee@richtek.com, cy_huang@richtek.com Subject: [PATCH v4 8/9] mfd: mt6360: Fix flow which is used to check ic exist Date: Mon, 17 Aug 2020 18:47:56 +0800 Message-Id: <1597661277-27862-9-git-send-email-gene.chen.richtek@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1597661277-27862-1-git-send-email-gene.chen.richtek@gmail.com> References: <1597661277-27862-1-git-send-email-gene.chen.richtek@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gene Chen Fix flow which is used to check ic exist. Signed-off-by: Gene Chen --- drivers/mfd/mt6360-core.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/drivers/mfd/mt6360-core.c b/drivers/mfd/mt6360-core.c index 2356d99..677c974 100644 --- a/drivers/mfd/mt6360-core.c +++ b/drivers/mfd/mt6360-core.c @@ -293,6 +293,25 @@ static const struct mfd_cell mt6360_devs[] = { NULL, 0, 0, "mediatek,mt6360-tcpc"), }; +static int mt6360_check_vendor_info(struct mt6360_ddata *ddata) +{ + u32 info; + int ret; + + ret = regmap_read(ddata->regmap, MT6360_PMU_DEV_INFO, &info); + if (ret < 0) + return ret; + + if ((info & CHIP_VEN_MASK) != CHIP_VEN_MT6360) { + dev_err(&client->dev, "Device not supported\n"); + return -ENODEV; + } + + ddata->chip_rev = info & CHIP_REV_MASK; + + return 0; +} + static const unsigned short mt6360_slave_addr[MT6360_SLAVE_MAX] = { MT6360_PMU_SLAVEID, MT6360_PMIC_SLAVEID, @@ -303,7 +322,6 @@ static const unsigned short mt6360_slave_addr[MT6360_SLAVE_MAX] = { static int mt6360_probe(struct i2c_client *client) { struct mt6360_ddata *ddata; - unsigned int reg_data; int i, ret; ddata = devm_kzalloc(&client->dev, sizeof(*ddata), GFP_KERNEL); @@ -319,17 +337,9 @@ static int mt6360_probe(struct i2c_client *client) return PTR_ERR(ddata->regmap); } - ret = regmap_read(ddata->regmap, MT6360_PMU_DEV_INFO, ®_data); - if (ret) { - dev_err(&client->dev, "Device not found\n"); + ret = mt6360_check_vendor_info(ddata); + if (ret) return ret; - } - - ddata->chip_rev = reg_data & CHIP_REV_MASK; - if (ddata->chip_rev != CHIP_VEN_MT6360) { - dev_err(&client->dev, "Device not supported\n"); - return -ENODEV; - } ret = devm_regmap_add_irq_chip(&client->dev, ddata->regmap, client->irq, 0, 0, &mt6360_irq_chip, -- 2.7.4