diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-06-29 15:21:12 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-06-29 15:21:12 -0400 |
commit | 44813aa62aa2f6ac98ba3554cf8bc49087098b74 (patch) | |
tree | f8cc4a8460bca215435d31c082aba06d6547e7b1 | |
parent | 788695385933ff2dedaef0c3e5cb07659cc44018 (diff) | |
parent | 12b731dd46d9ee646318e6e9dc587314a3908a46 (diff) |
Merge branch 'i2c/for-current-fixed' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c fixes from Wolfram Sang:
- a revert because of bugzilla #200045 (and some documentation about
it)
- another regression fix in the i2c-gpio driver
- a leak fix for the i2c core
* 'i2c/for-current-fixed' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
i2c: gpio: initialize SCL to HIGH again
i2c: smbus: kill memory leak on emulated and failed DMA SMBus xfers
i2c: algos: bit: mention our experience about initial states
Revert "i2c: algo-bit: init the bus to a known state"
-rw-r--r-- | drivers/i2c/algos/i2c-algo-bit.c | 8 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-gpio.c | 4 | ||||
-rw-r--r-- | drivers/i2c/i2c-core-smbus.c | 14 |
3 files changed, 15 insertions, 11 deletions
diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c index 4a34f311e1ff..6ec65adaba49 100644 --- a/drivers/i2c/algos/i2c-algo-bit.c +++ b/drivers/i2c/algos/i2c-algo-bit.c | |||
@@ -647,10 +647,10 @@ static int __i2c_bit_add_bus(struct i2c_adapter *adap, | |||
647 | if (bit_adap->getscl == NULL) | 647 | if (bit_adap->getscl == NULL) |
648 | adap->quirks = &i2c_bit_quirk_no_clk_stretch; | 648 | adap->quirks = &i2c_bit_quirk_no_clk_stretch; |
649 | 649 | ||
650 | /* Bring bus to a known state. Looks like STOP if bus is not free yet */ | 650 | /* |
651 | setscl(bit_adap, 1); | 651 | * We tried forcing SCL/SDA to an initial state here. But that caused a |
652 | udelay(bit_adap->udelay); | 652 | * regression, sadly. Check Bugzilla #200045 for details. |
653 | setsda(bit_adap, 1); | 653 | */ |
654 | 654 | ||
655 | ret = add_adapter(adap); | 655 | ret = add_adapter(adap); |
656 | if (ret < 0) | 656 | if (ret < 0) |
diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c index 005e6e0330c2..66f85bbf3591 100644 --- a/drivers/i2c/busses/i2c-gpio.c +++ b/drivers/i2c/busses/i2c-gpio.c | |||
@@ -279,9 +279,9 @@ static int i2c_gpio_probe(struct platform_device *pdev) | |||
279 | * required for an I2C bus. | 279 | * required for an I2C bus. |
280 | */ | 280 | */ |
281 | if (pdata->scl_is_open_drain) | 281 | if (pdata->scl_is_open_drain) |
282 | gflags = GPIOD_OUT_LOW; | 282 | gflags = GPIOD_OUT_HIGH; |
283 | else | 283 | else |
284 | gflags = GPIOD_OUT_LOW_OPEN_DRAIN; | 284 | gflags = GPIOD_OUT_HIGH_OPEN_DRAIN; |
285 | priv->scl = i2c_gpio_get_desc(dev, "scl", 1, gflags); | 285 | priv->scl = i2c_gpio_get_desc(dev, "scl", 1, gflags); |
286 | if (IS_ERR(priv->scl)) | 286 | if (IS_ERR(priv->scl)) |
287 | return PTR_ERR(priv->scl); | 287 | return PTR_ERR(priv->scl); |
diff --git a/drivers/i2c/i2c-core-smbus.c b/drivers/i2c/i2c-core-smbus.c index f3f683041e7f..51970bae3c4a 100644 --- a/drivers/i2c/i2c-core-smbus.c +++ b/drivers/i2c/i2c-core-smbus.c | |||
@@ -465,15 +465,18 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr, | |||
465 | 465 | ||
466 | status = i2c_transfer(adapter, msg, num); | 466 | status = i2c_transfer(adapter, msg, num); |
467 | if (status < 0) | 467 | if (status < 0) |
468 | return status; | 468 | goto cleanup; |
469 | if (status != num) | 469 | if (status != num) { |
470 | return -EIO; | 470 | status = -EIO; |
471 | goto cleanup; | ||
472 | } | ||
473 | status = 0; | ||
471 | 474 | ||
472 | /* Check PEC if last message is a read */ | 475 | /* Check PEC if last message is a read */ |
473 | if (i && (msg[num-1].flags & I2C_M_RD)) { | 476 | if (i && (msg[num-1].flags & I2C_M_RD)) { |
474 | status = i2c_smbus_check_pec(partial_pec, &msg[num-1]); | 477 | status = i2c_smbus_check_pec(partial_pec, &msg[num-1]); |
475 | if (status < 0) | 478 | if (status < 0) |
476 | return status; | 479 | goto cleanup; |
477 | } | 480 | } |
478 | 481 | ||
479 | if (read_write == I2C_SMBUS_READ) | 482 | if (read_write == I2C_SMBUS_READ) |
@@ -499,12 +502,13 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr, | |||
499 | break; | 502 | break; |
500 | } | 503 | } |
501 | 504 | ||
505 | cleanup: | ||
502 | if (msg[0].flags & I2C_M_DMA_SAFE) | 506 | if (msg[0].flags & I2C_M_DMA_SAFE) |
503 | kfree(msg[0].buf); | 507 | kfree(msg[0].buf); |
504 | if (msg[1].flags & I2C_M_DMA_SAFE) | 508 | if (msg[1].flags & I2C_M_DMA_SAFE) |
505 | kfree(msg[1].buf); | 509 | kfree(msg[1].buf); |
506 | 510 | ||
507 | return 0; | 511 | return status; |
508 | } | 512 | } |
509 | 513 | ||
510 | /** | 514 | /** |