Skip to content

Commit

Permalink
Merge branch 'i2c/for-current-fixed' of git://git.kernel.org/pub/scm/…
Browse files Browse the repository at this point in the history
…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"
  • Loading branch information
torvalds committed Jun 29, 2018
2 parents 7886953 + 12b731d commit 44813aa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
8 changes: 4 additions & 4 deletions drivers/i2c/algos/i2c-algo-bit.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,10 +647,10 @@ static int __i2c_bit_add_bus(struct i2c_adapter *adap,
if (bit_adap->getscl == NULL)
adap->quirks = &i2c_bit_quirk_no_clk_stretch;

/* Bring bus to a known state. Looks like STOP if bus is not free yet */
setscl(bit_adap, 1);
udelay(bit_adap->udelay);
setsda(bit_adap, 1);
/*
* We tried forcing SCL/SDA to an initial state here. But that caused a
* regression, sadly. Check Bugzilla #200045 for details.
*/

ret = add_adapter(adap);
if (ret < 0)
Expand Down
4 changes: 2 additions & 2 deletions drivers/i2c/busses/i2c-gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,9 @@ static int i2c_gpio_probe(struct platform_device *pdev)
* required for an I2C bus.
*/
if (pdata->scl_is_open_drain)
gflags = GPIOD_OUT_LOW;
gflags = GPIOD_OUT_HIGH;
else
gflags = GPIOD_OUT_LOW_OPEN_DRAIN;
gflags = GPIOD_OUT_HIGH_OPEN_DRAIN;
priv->scl = i2c_gpio_get_desc(dev, "scl", 1, gflags);
if (IS_ERR(priv->scl))
return PTR_ERR(priv->scl);
Expand Down
14 changes: 9 additions & 5 deletions drivers/i2c/i2c-core-smbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,15 +465,18 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr,

status = i2c_transfer(adapter, msg, num);
if (status < 0)
return status;
if (status != num)
return -EIO;
goto cleanup;
if (status != num) {
status = -EIO;
goto cleanup;
}
status = 0;

/* Check PEC if last message is a read */
if (i && (msg[num-1].flags & I2C_M_RD)) {
status = i2c_smbus_check_pec(partial_pec, &msg[num-1]);
if (status < 0)
return status;
goto cleanup;
}

if (read_write == I2C_SMBUS_READ)
Expand All @@ -499,12 +502,13 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr,
break;
}

cleanup:
if (msg[0].flags & I2C_M_DMA_SAFE)
kfree(msg[0].buf);
if (msg[1].flags & I2C_M_DMA_SAFE)
kfree(msg[1].buf);

return 0;
return status;
}

/**
Expand Down

0 comments on commit 44813aa

Please sign in to comment.