diff options
author | Daniel Kurtz <djkurtz@chromium.org> | 2012-06-28 09:08:11 -0400 |
---|---|---|
committer | Henrik Rydberg <rydberg@euromail.se> | 2012-06-29 09:58:03 -0400 |
commit | 771733e348e3df5b6283ab3b97d28577452bf09f (patch) | |
tree | dcdcc637e61aa21a8a345bfb3b4797a1bc6e81c1 /drivers/input | |
parent | 794eb67e76118108af5280ace2be8ae4983a6a81 (diff) |
Input: atmel_mxt_ts - return errors from i2c layer
The i2c layer can report a variety of errors, including -ENXIO for an i2c
NAK. Instead of treating them all as -EIO, pass the actual i2c layer
error up to the caller.
However, still report as -EIO the unlikely case that a transaction was
partially completed, and no error message was returned from i2c_*().
Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/touchscreen/atmel_mxt_ts.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index ee37b0b0e0e4..a68b2279e8df 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c | |||
@@ -396,6 +396,7 @@ static int __mxt_read_reg(struct i2c_client *client, | |||
396 | { | 396 | { |
397 | struct i2c_msg xfer[2]; | 397 | struct i2c_msg xfer[2]; |
398 | u8 buf[2]; | 398 | u8 buf[2]; |
399 | int ret; | ||
399 | 400 | ||
400 | buf[0] = reg & 0xff; | 401 | buf[0] = reg & 0xff; |
401 | buf[1] = (reg >> 8) & 0xff; | 402 | buf[1] = (reg >> 8) & 0xff; |
@@ -412,12 +413,17 @@ static int __mxt_read_reg(struct i2c_client *client, | |||
412 | xfer[1].len = len; | 413 | xfer[1].len = len; |
413 | xfer[1].buf = val; | 414 | xfer[1].buf = val; |
414 | 415 | ||
415 | if (i2c_transfer(client->adapter, xfer, 2) != 2) { | 416 | ret = i2c_transfer(client->adapter, xfer, 2); |
416 | dev_err(&client->dev, "%s: i2c transfer failed\n", __func__); | 417 | if (ret == 2) { |
417 | return -EIO; | 418 | ret = 0; |
419 | } else { | ||
420 | if (ret >= 0) | ||
421 | ret = -EIO; | ||
422 | dev_err(&client->dev, "%s: i2c transfer failed (%d)\n", | ||
423 | __func__, ret); | ||
418 | } | 424 | } |
419 | 425 | ||
420 | return 0; | 426 | return ret; |
421 | } | 427 | } |
422 | 428 | ||
423 | static int mxt_read_reg(struct i2c_client *client, u16 reg, u8 *val) | 429 | static int mxt_read_reg(struct i2c_client *client, u16 reg, u8 *val) |
@@ -428,17 +434,23 @@ static int mxt_read_reg(struct i2c_client *client, u16 reg, u8 *val) | |||
428 | static int mxt_write_reg(struct i2c_client *client, u16 reg, u8 val) | 434 | static int mxt_write_reg(struct i2c_client *client, u16 reg, u8 val) |
429 | { | 435 | { |
430 | u8 buf[3]; | 436 | u8 buf[3]; |
437 | int ret; | ||
431 | 438 | ||
432 | buf[0] = reg & 0xff; | 439 | buf[0] = reg & 0xff; |
433 | buf[1] = (reg >> 8) & 0xff; | 440 | buf[1] = (reg >> 8) & 0xff; |
434 | buf[2] = val; | 441 | buf[2] = val; |
435 | 442 | ||
436 | if (i2c_master_send(client, buf, 3) != 3) { | 443 | ret = i2c_master_send(client, buf, 3); |
437 | dev_err(&client->dev, "%s: i2c send failed\n", __func__); | 444 | if (ret == 3) { |
438 | return -EIO; | 445 | ret = 0; |
446 | } else { | ||
447 | if (ret >= 0) | ||
448 | ret = -EIO; | ||
449 | dev_err(&client->dev, "%s: i2c send failed (%d)\n", | ||
450 | __func__, ret); | ||
439 | } | 451 | } |
440 | 452 | ||
441 | return 0; | 453 | return ret; |
442 | } | 454 | } |
443 | 455 | ||
444 | static int mxt_read_object_table(struct i2c_client *client, | 456 | static int mxt_read_object_table(struct i2c_client *client, |