Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp463669pxa; Tue, 4 Aug 2020 09:37:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRo9oIIsrgzvhtiQ/PRhO0Y3KPbyVJl29kwG4pZWT8a64LZAsPzJ9fh1kH15iOIxDB9eBc X-Received: by 2002:a50:8a62:: with SMTP id i89mr21545882edi.324.1596559046201; Tue, 04 Aug 2020 09:37:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596559046; cv=none; d=google.com; s=arc-20160816; b=w3BnNJXm5tVBMnYkpzPXxsDZeIxRXs+yby8UFV3+HS7guSm7rH8FENyX1zptZFYnv4 PFrvRcwOpdNt7yzIy5Hey8j80yXinhoDK0csVIuuHEql/n4BjA8/WoRlDYQgxV3QmesW 1qrXjR0ci62kxzOWOfA9DCle8OhFNaRWA9YekE3T98suMbICRQRWTpBkAVOO5V0ihE2g QBE9d8KM9QltXxfMnPPx5rtUoi+yOacv+9Hyc7cLmbAoXAv/FO62BVGgn2MefX4IaJoh 51jB7QONmIsYiXi2SoYXiBDHXAnssD+cz69q7QIniYg4eEWNexTQqZsJSp/nsLJ9ZRiC m8ng== 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=aI1pK1TrOTJnU6NW7i6yEf4Kbk4mPjpQFNG8pg1E8nN6BhJYY0YsWxkkNZn2OZdgn1 Z7+cXUD7Y60T12DjN86lNtTwMzrCIr98HqfN3IL04P0/d97U3nNRTL+ot2yg2wO4rxmF 5nsP6M09qkbaOeumL7NpUj9aOEsIfdiyTwz8o1XlC7SW32TVzK/ACfaIaJ1coVkkibB/ HLW5y90ovA8h6QDd7R/kY2C3q1XdCnyVtHVleEWZqasUPQvzIO7gqOO+thatC1PgXqex unH7UZCT3AxmrJ9MPNxPwN1RCHMSVqbE+reGO+n+77+r/FIC+22WvdYrwjcvX0uxPI0C ooyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="dofzX/8j"; 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 gr23si12345782ejb.132.2020.08.04.09.37.03; Tue, 04 Aug 2020 09:37:26 -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="dofzX/8j"; 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 S1729916AbgHDQdv (ORCPT + 99 others); Tue, 4 Aug 2020 12:33:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729994AbgHDQdf (ORCPT ); Tue, 4 Aug 2020 12:33:35 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F17AFC06174A for ; Tue, 4 Aug 2020 09:33:34 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id w17so23307636ply.11 for ; Tue, 04 Aug 2020 09:33:34 -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=dofzX/8j/y3zd4rnbPgoEyOo3X9xNcwVZZOSj+XtCWmEnMDc7DnG5c62WqfRz08+8M ZwrABnFgyTjIp9Fn7Fi0LdCW5ECjAbimZzTF6qvTScJRyicb/QbwyCPvBoGlbd3VZHCE KAsN0OuG+a4DA5yiPiegy6IS+oVaBvkOS0x/bPcCoUx56OyXz81hZiCvt3Tm9HxWViCB IsBriMgCt0CbCp4F4ugZknYc0mwrb0EqMLKnb2mwR45KsKDzl/5ZHpIQHFc/378MglJu xc1VbACdkmqqtk8BKMaHZNdap4K1k6QKGgGIhhIDjdGcydcufAXupIEFV4fcgMk+E9BS 6XAA== 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=rwb4do7M8d2MpXtaCz+Stk3QeZv8btRfTaO9FBlEmgeT5sQLog0XhxAW1Ksimt1/uY CQq9iyMDnmyl+7gAl4QHfpUCu9gJGQxz04L+zWKfYlr+r5dq48RPrHNky5vC0BDiBLx/ nyaBf/Bo/76+g7hBLYZG1H+nzAzWgYfqe7iteAj9QNzvW2kVwnbHlXX1pXTBgdMeRbfH 5jz7v81jF9GA/DNuSC6vpbv0xtu4I3tLhcJY47IZDaaO8CHkKFo+1p3VwNOoqLGB+vVC aHjgqhufZc6HAI8mTTfz8LLGuY+K1qa8kU4Z121nMGnlbbmWPNPN+GnH1miuU6zZ2B98 AvSw== X-Gm-Message-State: AOAM530TyM5z6hSL4/hUlr97vAKvPvdduhIDjc2Ktk6Jo5GO1C2md/0L QRHokHhThJRWK7cCN56nUww= X-Received: by 2002:a17:902:9a94:: with SMTP id w20mr21094155plp.59.1596558814544; Tue, 04 Aug 2020 09:33:34 -0700 (PDT) Received: from localhost.localdomain ([123.110.251.138]) by smtp.gmail.com with ESMTPSA id m16sm657253pjz.47.2020.08.04.09.33.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Aug 2020 09:33:34 -0700 (PDT) From: Gene Chen To: lee.jones@linaro.org, matthias.bgg@gmail.com, rafael@kernel.org Cc: broonie@kernel.org, gregkh@linuxfoundation.org, 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 8/9] mfd: mt6360: Fix flow which is used to check ic exist Date: Wed, 5 Aug 2020 00:33:01 +0800 Message-Id: <1596558782-3415-10-git-send-email-gene.chen.richtek@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1596558782-3415-1-git-send-email-gene.chen.richtek@gmail.com> References: <1596558782-3415-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