diff options
author | Wolfram Sang <wsa@the-dreams.de> | 2015-01-07 06:24:10 -0500 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2015-03-13 10:10:52 -0400 |
commit | a7405844da1c8064500f0741cc8876c7f887dd85 (patch) | |
tree | fdb356c0cf63eb5bb57c930e39f7f53e1912ffd6 | |
parent | b7f625840267b18ef1011cba0085bb7e237d76f7 (diff) |
i2c: at91: make use of the new infrastructure for quirks
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Tested-By: Ludovic Desroches <ludovic.desroches@atmel.com>
-rw-r--r-- | drivers/i2c/busses/i2c-at91.c | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c index 636fd2efad88..b3a70e8fc653 100644 --- a/drivers/i2c/busses/i2c-at91.c +++ b/drivers/i2c/busses/i2c-at91.c | |||
@@ -487,30 +487,10 @@ static int at91_twi_xfer(struct i2c_adapter *adap, struct i2c_msg *msg, int num) | |||
487 | if (ret < 0) | 487 | if (ret < 0) |
488 | goto out; | 488 | goto out; |
489 | 489 | ||
490 | /* | 490 | if (num == 2) { |
491 | * The hardware can handle at most two messages concatenated by a | ||
492 | * repeated start via it's internal address feature. | ||
493 | */ | ||
494 | if (num > 2) { | ||
495 | dev_err(dev->dev, | ||
496 | "cannot handle more than two concatenated messages.\n"); | ||
497 | ret = 0; | ||
498 | goto out; | ||
499 | } else if (num == 2) { | ||
500 | int internal_address = 0; | 491 | int internal_address = 0; |
501 | int i; | 492 | int i; |
502 | 493 | ||
503 | if (msg->flags & I2C_M_RD) { | ||
504 | dev_err(dev->dev, "first transfer must be write.\n"); | ||
505 | ret = -EINVAL; | ||
506 | goto out; | ||
507 | } | ||
508 | if (msg->len > 3) { | ||
509 | dev_err(dev->dev, "first message size must be <= 3.\n"); | ||
510 | ret = -EINVAL; | ||
511 | goto out; | ||
512 | } | ||
513 | |||
514 | /* 1st msg is put into the internal address, start with 2nd */ | 494 | /* 1st msg is put into the internal address, start with 2nd */ |
515 | m_start = &msg[1]; | 495 | m_start = &msg[1]; |
516 | for (i = 0; i < msg->len; ++i) { | 496 | for (i = 0; i < msg->len; ++i) { |
@@ -540,6 +520,15 @@ out: | |||
540 | return ret; | 520 | return ret; |
541 | } | 521 | } |
542 | 522 | ||
523 | /* | ||
524 | * The hardware can handle at most two messages concatenated by a | ||
525 | * repeated start via it's internal address feature. | ||
526 | */ | ||
527 | static struct i2c_adapter_quirks at91_twi_quirks = { | ||
528 | .flags = I2C_AQ_COMB | I2C_AQ_COMB_WRITE_FIRST | I2C_AQ_COMB_SAME_ADDR, | ||
529 | .max_comb_1st_msg_len = 3, | ||
530 | }; | ||
531 | |||
543 | static u32 at91_twi_func(struct i2c_adapter *adapter) | 532 | static u32 at91_twi_func(struct i2c_adapter *adapter) |
544 | { | 533 | { |
545 | return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | 534 | return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL |
@@ -777,6 +766,7 @@ static int at91_twi_probe(struct platform_device *pdev) | |||
777 | dev->adapter.owner = THIS_MODULE; | 766 | dev->adapter.owner = THIS_MODULE; |
778 | dev->adapter.class = I2C_CLASS_DEPRECATED; | 767 | dev->adapter.class = I2C_CLASS_DEPRECATED; |
779 | dev->adapter.algo = &at91_twi_algorithm; | 768 | dev->adapter.algo = &at91_twi_algorithm; |
769 | dev->adapter.quirks = &at91_twi_quirks; | ||
780 | dev->adapter.dev.parent = dev->dev; | 770 | dev->adapter.dev.parent = dev->dev; |
781 | dev->adapter.nr = pdev->id; | 771 | dev->adapter.nr = pdev->id; |
782 | dev->adapter.timeout = AT91_I2C_TIMEOUT; | 772 | dev->adapter.timeout = AT91_I2C_TIMEOUT; |