diff options
author | Peter Rosin <peda@axentia.se> | 2018-06-20 01:17:54 -0400 |
---|---|---|
committer | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> | 2018-07-28 10:03:11 -0400 |
commit | 79e2472f99ab457417aaad98bf83ab565fa32bd0 (patch) | |
tree | dea26930f05e65b5a53ce5ddf252537853a55ad4 | |
parent | 1a339b658d9dbe1471f67b78237cf8fa08bbbeb5 (diff) |
tpm/tpm_i2c_infineon: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT)
Locking the root adapter for __i2c_transfer will deadlock if the
device sits behind a mux-locked I2C mux. Switch to the finer-grained
i2c_lock_bus with the I2C_LOCK_SEGMENT flag. If the device does not
sit behind a mux-locked mux, the two locking variants are equivalent.
Signed-off-by: Peter Rosin <peda@axentia.se>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Alexander Steffen <Alexander.Steffen@infineon.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
-rw-r--r-- | drivers/char/tpm/tpm_i2c_infineon.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/char/tpm/tpm_i2c_infineon.c b/drivers/char/tpm/tpm_i2c_infineon.c index 6116cd05e228..9086edc9066b 100644 --- a/drivers/char/tpm/tpm_i2c_infineon.c +++ b/drivers/char/tpm/tpm_i2c_infineon.c | |||
@@ -117,7 +117,7 @@ static int iic_tpm_read(u8 addr, u8 *buffer, size_t len) | |||
117 | /* Lock the adapter for the duration of the whole sequence. */ | 117 | /* Lock the adapter for the duration of the whole sequence. */ |
118 | if (!tpm_dev.client->adapter->algo->master_xfer) | 118 | if (!tpm_dev.client->adapter->algo->master_xfer) |
119 | return -EOPNOTSUPP; | 119 | return -EOPNOTSUPP; |
120 | i2c_lock_adapter(tpm_dev.client->adapter); | 120 | i2c_lock_bus(tpm_dev.client->adapter, I2C_LOCK_SEGMENT); |
121 | 121 | ||
122 | if (tpm_dev.chip_type == SLB9645) { | 122 | if (tpm_dev.chip_type == SLB9645) { |
123 | /* use a combined read for newer chips | 123 | /* use a combined read for newer chips |
@@ -192,7 +192,7 @@ static int iic_tpm_read(u8 addr, u8 *buffer, size_t len) | |||
192 | } | 192 | } |
193 | 193 | ||
194 | out: | 194 | out: |
195 | i2c_unlock_adapter(tpm_dev.client->adapter); | 195 | i2c_unlock_bus(tpm_dev.client->adapter, I2C_LOCK_SEGMENT); |
196 | /* take care of 'guard time' */ | 196 | /* take care of 'guard time' */ |
197 | usleep_range(SLEEP_DURATION_LOW, SLEEP_DURATION_HI); | 197 | usleep_range(SLEEP_DURATION_LOW, SLEEP_DURATION_HI); |
198 | 198 | ||
@@ -224,7 +224,7 @@ static int iic_tpm_write_generic(u8 addr, u8 *buffer, size_t len, | |||
224 | 224 | ||
225 | if (!tpm_dev.client->adapter->algo->master_xfer) | 225 | if (!tpm_dev.client->adapter->algo->master_xfer) |
226 | return -EOPNOTSUPP; | 226 | return -EOPNOTSUPP; |
227 | i2c_lock_adapter(tpm_dev.client->adapter); | 227 | i2c_lock_bus(tpm_dev.client->adapter, I2C_LOCK_SEGMENT); |
228 | 228 | ||
229 | /* prepend the 'register address' to the buffer */ | 229 | /* prepend the 'register address' to the buffer */ |
230 | tpm_dev.buf[0] = addr; | 230 | tpm_dev.buf[0] = addr; |
@@ -243,7 +243,7 @@ static int iic_tpm_write_generic(u8 addr, u8 *buffer, size_t len, | |||
243 | usleep_range(sleep_low, sleep_hi); | 243 | usleep_range(sleep_low, sleep_hi); |
244 | } | 244 | } |
245 | 245 | ||
246 | i2c_unlock_adapter(tpm_dev.client->adapter); | 246 | i2c_unlock_bus(tpm_dev.client->adapter, I2C_LOCK_SEGMENT); |
247 | /* take care of 'guard time' */ | 247 | /* take care of 'guard time' */ |
248 | usleep_range(SLEEP_DURATION_LOW, SLEEP_DURATION_HI); | 248 | usleep_range(SLEEP_DURATION_LOW, SLEEP_DURATION_HI); |
249 | 249 | ||