misc: rk803: add retry while reading device id.

Signed-off-by: Sach Lin <sach.lin@rock-chips.com>
Change-Id: I07f5813f0ded6f1bf69a44820746de63faffe90f
This commit is contained in:
Sach Lin
2022-12-14 18:43:58 +08:00
committed by Tao Huang
parent e0cfc605b3
commit 0ea23cba57
+28 -14
View File
@@ -207,6 +207,7 @@ rk803_probe(struct i2c_client *client, const struct i2c_device_id *id)
struct regmap *regmap;
struct regmap_config regmap_config = { };
int ret;
int cnt = 3;
rk803 = devm_kzalloc(dev, sizeof(*rk803), GFP_KERNEL);
if (!rk803)
@@ -222,22 +223,35 @@ rk803_probe(struct i2c_client *client, const struct i2c_device_id *id)
rk803_power_on(rk803);
/* check chip id */
msb = i2c_smbus_read_byte_data(client, RK803_CHIPID1);
if (msb < 0) {
dev_err(dev, "failed to read the chip1 id at 0x%x\n",
RK803_CHIPID1);
ret = -EPROBE_DEFER;
goto error;
}
lsb = i2c_smbus_read_byte_data(client, RK803_CHIPID2);
if (lsb < 0) {
dev_err(dev, "failed to read the chip2 id at 0x%x\n",
RK803_CHIPID2);
ret = lsb;
goto error;
while (cnt--) {
if (ret)
usleep_range(1000, 2000);
/* check chip id */
msb = i2c_smbus_read_byte_data(client, RK803_CHIPID1);
if (msb < 0) {
dev_err(dev, "failed to read the chip1 id at 0x%x\n",
RK803_CHIPID1);
ret = -ENODEV;
continue;
}
lsb = i2c_smbus_read_byte_data(client, RK803_CHIPID2);
if (lsb < 0) {
dev_err(dev, "failed to read the chip2 id at 0x%x\n",
RK803_CHIPID2);
ret = -ENODEV;
continue;
}
ret = 0;
break;
}
if (ret)
return ret;
chipid = ((msb << 8) | lsb);
dev_info(dev, "chip id: 0x%x\n", (unsigned int)chipid);