From: Gene Chen <gene.chen.richtek@gmail.com>
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 [thread overview]
Message-ID: <20210517173314.140912-9-gene.chen.richtek@gmail.com> (raw)
In-Reply-To: <20210517173314.140912-1-gene.chen.richtek@gmail.com>
From: Gene Chen <gene_chen@richtek.com>
Fix flow which is used to check ic exist.
Signed-off-by: Gene Chen <gene_chen@richtek.com>
Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>
---
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
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-05-17 17:37 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-17 17:33 [PATCH v8 0/10] mfd: mt6360: Merge different sub-devices I2C read/write Gene Chen
2021-05-17 17:33 ` [PATCH v8 01/10] mfd: mt6360: Rearrange include file Gene Chen
2021-05-17 17:33 ` [PATCH v8 02/10] mfd: mt6360: Remove redundant brackets around raw numbers Gene Chen
2021-05-17 17:33 ` [PATCH v8 03/10] mfd: mt6360: Indicate sub-dev compatible name by using "-" Gene Chen
2021-05-17 17:33 ` [PATCH v8 04/10] mfd: mt6360: Combine mt6360 pmic/ldo resources into mt6360 regulator resources Gene Chen
2021-06-09 9:48 ` Fei Shao
2021-05-17 17:33 ` [PATCH v8 05/10] mfd: mt6360: Rename mt6360_pmu_data by mt6360_ddata Gene Chen
2021-05-17 17:33 ` [PATCH v8 06/10] mfd: mt6360: Rename mt6360_pmu by mt6360 Gene Chen
2021-05-17 17:33 ` [PATCH v8 07/10] mfd: mt6360: Remove handle_post_irq callback function Gene Chen
2021-05-17 17:33 ` Gene Chen [this message]
2021-06-09 10:02 ` [PATCH v8 08/10] mfd: mt6360: Fix flow which is used to check ic exist Fei Shao
2021-06-09 10:21 ` Fei Shao
2021-05-17 17:33 ` [PATCH v8 09/10] mfd: mt6360: Merge header file into driver and remove unuse register define Gene Chen
2021-05-17 17:33 ` [PATCH v8 10/10] mfd: mt6360: Merge different sub-devices I2C read/write Gene Chen
2021-05-19 14:56 ` [PATCH v8 0/10] " Lee Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210517173314.140912-9-gene.chen.richtek@gmail.com \
--to=gene.chen.richtek@gmail.com \
--cc=Wilma.Wu@mediatek.com \
--cc=cy_huang@richtek.com \
--cc=gene_chen@richtek.com \
--cc=lee.jones@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=shufan_lee@richtek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).