diff options
| author | Shantanu Jain <shjain@codeaurora.org> | 2013-09-27 12:00:39 +0530 |
|---|---|---|
| committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2016-09-13 01:46:56 -0700 |
| commit | 431c5aa98af520cfaa8dfe97b20bfe86aef8f54e (patch) | |
| tree | 3891aec1f168b51f0dda426690ca107e7b2e74e5 /drivers/input | |
| parent | 5741a475814052f96be4c9d10bf4960a9d529af9 (diff) | |
input: touchscreen: Clean code for i2c_read and i2c_write
Use standard initializer code in gtp_i2c_read and
gtp_i2c_write functions for Goodix touchscreen driver.
Change-Id: Id954be61a0b4596339a659928fb630c5c5538a9a
Signed-off-by: Shantanu Jain <shjain@codeaurora.org>
Signed-off-by: Sudhakar Manapati <smanap@codeaurora.org>
Diffstat (limited to 'drivers/input')
| -rw-r--r-- | drivers/input/touchscreen/gt9xx/gt9xx.c | 62 |
1 files changed, 33 insertions, 29 deletions
diff --git a/drivers/input/touchscreen/gt9xx/gt9xx.c b/drivers/input/touchscreen/gt9xx/gt9xx.c index b8bdbd7fd7fd..76250b87204d 100644 --- a/drivers/input/touchscreen/gt9xx/gt9xx.c +++ b/drivers/input/touchscreen/gt9xx/gt9xx.c @@ -134,27 +134,30 @@ Output: int gtp_i2c_read(struct i2c_client *client, u8 *buf, int len) { struct goodix_ts_data *ts = i2c_get_clientdata(client); - struct i2c_msg msgs[2]; int ret = -EIO; - int retries = 0; - - msgs[0].flags = !I2C_M_RD; - msgs[0].addr = client->addr; - msgs[0].len = GTP_ADDR_LENGTH; - msgs[0].buf = &buf[0]; - - msgs[1].flags = I2C_M_RD; - msgs[1].addr = client->addr; - msgs[1].len = len - GTP_ADDR_LENGTH; - msgs[1].buf = &buf[GTP_ADDR_LENGTH]; - - while (retries < 5) { + u8 retries; + struct i2c_msg msgs[2] = { + { + .flags = !I2C_M_RD, + .addr = client->addr, + .len = GTP_ADDR_LENGTH, + .buf = &buf[0], + }, + { + .flags = I2C_M_RD, + .addr = client->addr, + .len = len - GTP_ADDR_LENGTH, + .buf = &buf[GTP_ADDR_LENGTH], + }, + }; + + for (retries = 0; retries < 5; retries++) { ret = i2c_transfer(client->adapter, msgs, 2); if (ret == 2) break; - retries++; + dev_err(&client->dev, "I2C retry: %d\n", retries + 1); } - if (retries >= 5) { + if (retries == 5) { #if GTP_SLIDE_WAKEUP /* reset chip would quit doze mode */ if (doze_status == DOZE_ENABLED) @@ -164,7 +167,7 @@ int gtp_i2c_read(struct i2c_client *client, u8 *buf, int len) gtp_reset_guitar(ts, 10); else dev_warn(&client->dev, - "<GTP> gtp_reset_guitar exit init_done=%d:\n", + "gtp_reset_guitar exit init_done=%d:\n", init_done); } return ret; @@ -185,22 +188,22 @@ Output: int gtp_i2c_write(struct i2c_client *client, u8 *buf, int len) { struct goodix_ts_data *ts = i2c_get_clientdata(client); - struct i2c_msg msg; int ret = -EIO; - int retries = 0; - - msg.flags = !I2C_M_RD; - msg.addr = client->addr; - msg.len = len; - msg.buf = buf; - - while (retries < 5) { + u8 retries; + struct i2c_msg msg = { + .flags = !I2C_M_RD, + .addr = client->addr, + .len = len, + .buf = buf, + }; + + for (retries = 0; retries < 5; retries++) { ret = i2c_transfer(client->adapter, &msg, 1); if (ret == 1) break; - retries++; + dev_err(&client->dev, "I2C retry: %d\n", retries + 1); } - if ((retries >= 5)) { + if ((retries == 5)) { #if GTP_SLIDE_WAKEUP if (doze_status == DOZE_ENABLED) return ret; @@ -209,11 +212,12 @@ int gtp_i2c_write(struct i2c_client *client, u8 *buf, int len) gtp_reset_guitar(ts, 10); else dev_warn(&client->dev, - "<GTP> gtp_reset_guitar exit init_done=%d:\n", + "gtp_reset_guitar exit init_done=%d:\n", init_done); } return ret; } + /******************************************************* Function: i2c read twice, compare the results |
