Skip to content

Commit b768fb6

Browse files
singhomeleeasus-leslieyu
authored andcommitted
mipi-panel: add i2c retry mechanism of rpi mcu driver.
Change-Id: I2679c5c83293a71f6e6732ac39cf5ae1c26d7449
1 parent e379ba9 commit b768fb6

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

drivers/misc/tinker_mcu.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static int string_to_byte(const char *source, unsigned char *destination, int si
6868

6969
static int send_cmds(struct i2c_client *client, const char *buf)
7070
{
71-
int ret, size = strlen(buf);
71+
int ret, size = strlen(buf), retry = 5;
7272
unsigned char byte_cmd[size/2];
7373

7474
if ((size%2) != 0) {
@@ -80,11 +80,19 @@ static int send_cmds(struct i2c_client *client, const char *buf)
8080

8181
string_to_byte(buf, byte_cmd, size);
8282

83+
while(retry-- > 0) {
8384
ret = i2c_master_send(client, byte_cmd, size/2);
8485
if (ret <= 0) {
85-
LOG_ERR("send command failed, ret = %d\n", ret);
86+
LOG_ERR("send command failed, ret = %d, retry again!\n", ret);
87+
} else
88+
break;
89+
}
90+
91+
if(ret <= 0) {
92+
LOG_ERR("send command failed\n");
8693
return ret!=0 ? ret : -ECOMM;
8794
}
95+
8896
msleep(20);
8997
return 0;
9098
}

0 commit comments

Comments
 (0)