Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp785026pxj; Tue, 18 May 2021 14:10:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqE8zMMmYss0sID3sWF328OpJ7P02K2m8MlDdsftOSL47ojptJSHrhraw37CGS6hwMIaq7 X-Received: by 2002:a05:6402:2786:: with SMTP id b6mr9633064ede.20.1621372259659; Tue, 18 May 2021 14:10:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621372259; cv=none; d=google.com; s=arc-20160816; b=M9sYe4wXuvhfch8KZM0wb3nf4IIkGy/cyCUTnVS0UsgB2KAYtTxtcSkK0i/bydSWZ4 lXFQYXtwwRX7NgJlbmWMmP+j91CYTsEVl/tJZceVjmKtUeND9sDzE2H+0UDKUyVr7MJt cegY6+e5xIGmLylzYUJUth0HbZbhkuDeF/brYzKuPtKU8LXQEfKSLamQbkc4vF1Y/bRi n/nK+hqeGiVVOe6VfLAZxAWT/VLHghaE1rDE55hXwuqiQ5UtDsUjkGknhdYetukpS6iD pf0lA0FtdTmEnReJXVY1rsFzUMb8yXjFSZrGr3Tg5sn8cB/9X2qizWtVkKv68vDUKBAq 8BGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+SGZLC9XHUt+lZzTU9RZd8JyaaWpbIPUIXZL+8shzcs=; b=tglMPACurdGF6eA8xFCW/sYVkANguBsFKFy4mxZvQNnBXSoclxmx619JB8qVNZKNhb 1SLM0Svb8k/hUYYA4/l47M2gwVf6C6DzyFK+DHXJRjz7ksLRxatGKg84lZlELe7UFBAV QRTuP01lAdvKTFjHPAvDSKooBMW+1MhbEU0DcAXs/jENl2/W9nkf+BZLMPruIBsZ60JK 6wvmg894+nbFNFrh7cgPsGgh3413bffY2hoqxqDdQg1qQHyiS+POsp4FHJL5BdU3prwD fPR2wsyhg3x3tP4zFHzM03WfqwtqMNVa5cZU3iU4/yp7ulRhb9heRYrGeLnW1mcT/ahu trqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kAa3R3VM; 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 p13si18038351edt.516.2021.05.18.14.10.36; Tue, 18 May 2021 14:10:59 -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=kAa3R3VM; 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 S243013AbhEQRfH (ORCPT + 99 others); Mon, 17 May 2021 13:35:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243095AbhEQRfD (ORCPT ); Mon, 17 May 2021 13:35:03 -0400 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96691C061573 for ; Mon, 17 May 2021 10:33:46 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id t193so5145623pgb.4 for ; Mon, 17 May 2021 10:33:46 -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 :mime-version:content-transfer-encoding; bh=+SGZLC9XHUt+lZzTU9RZd8JyaaWpbIPUIXZL+8shzcs=; b=kAa3R3VMavzYayCAWbgzmaYp4JMxpY+hSNqopUhEBzFXEHoaFAkofW0qq+74+L+Fn+ 0SCsuMU5FF+ao9/cA9QlnaIMXX+l1lvOEeLQR2RegcYvdaxuaZhVwZy5ka27cfU8MRrw MlivrWclkjQmDQcr0GStDYySsJPyIbIVRe1Xb9tEq/gUln9aSYEf1TgOFlSrRKXzl2D4 +nRmhqzLIymGpxCCpdc4Hr80XCgcuOFjWz96crFnecuDcd04NZExEjig/7rHqTgznSZz dLSObErCpCrZ4OCI8/L29mOBnmzVPa9Ko8EnTSQaMW4OPTtVctuB89hb0row/NwoNmqe 5K7g== 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:mime-version:content-transfer-encoding; bh=+SGZLC9XHUt+lZzTU9RZd8JyaaWpbIPUIXZL+8shzcs=; b=ZKy9WK+DGdvWw+8fdj9WkV4HyxwfEspYPzFu0bJAB/EjlTaG8cjCoiZAmwB+DBCKbH CQ1OBh0OSjaxaeaHXA8IzpcKmRZbxVafMi4J/Vwmh3U8WjEM6cyXSc/s1jFgPqa8qzcG XoygapnDFHrvFrdislQYPhjhL3+hOiWnuWN3l9RbuaP442GgFrSzb0bv9+HwdLutr+pU E3FXQUdN/eV/dQM98QIpZihfyUIwn26HuyxaH54yrd3gnfcuzlv1omgGhezZ+ff/sTii mNbynvzlJQo95bEqpki8KXXJZgvzAQIGn0+n+9HhlbjlUgxDlqZqfoI6lHl6Ld/vUJsR DW0A== X-Gm-Message-State: AOAM533aBzDL/nDbhjCbAEaR8WAw2Q0xrpgDKNPzmbaKJbamDZhqASeI DPDPyyRIbYKuGtmQ0V4uymUoxoDLbUQ= X-Received: by 2002:a65:5248:: with SMTP id q8mr651292pgp.176.1621272826253; Mon, 17 May 2021 10:33:46 -0700 (PDT) Received: from localhost.localdomain ([2402:7500:47e:c24d:6c72:a52:2c8:7df1]) by smtp.gmail.com with ESMTPSA id c12sm10358296pfr.154.2021.05.17.10.33.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 May 2021 10:33:46 -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, Wilma.Wu@mediatek.com, shufan_lee@richtek.com, cy_huang@richtek.com Subject: [PATCH v8 08/10] mfd: mt6360: Fix flow which is used to check ic exist Date: Tue, 18 May 2021 01:33:12 +0800 Message-Id: <20210517173314.140912-9-gene.chen.richtek@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210517173314.140912-1-gene.chen.richtek@gmail.com> References: <20210517173314.140912-1-gene.chen.richtek@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Acked-for-MFD-by: Lee Jones --- 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 50a170065a98..cdd99770f94a 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(ddata->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.25.1