Skip to content

Commit 3f26465

Browse files
committed
Merge tag 'i2c-for-7.1-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c fixes from Wolfram Sang: "Core: - smbus: fix a potential uninitialization bug Tegra: - drop runtime PM reference when exiting on mutex_lock failure - preserve transfer errors when releasing the mutex" * tag 'i2c-for-7.1-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: i2c: smbus: fix a potential uninitialization bug i2c: tegra: make tegra_i2c_mutex_unlock() return void i2c: tegra: fix pm_runtime leak on mutex_lock failure
2 parents ab868c1 + 023453c commit 3f26465

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

drivers/i2c/busses/i2c-tegra.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -589,25 +589,22 @@ static int tegra_i2c_mutex_lock(struct tegra_i2c_dev *i2c_dev)
589589
return ret;
590590
}
591591

592-
static int tegra_i2c_mutex_unlock(struct tegra_i2c_dev *i2c_dev)
592+
static void tegra_i2c_mutex_unlock(struct tegra_i2c_dev *i2c_dev)
593593
{
594594
unsigned int reg = i2c_dev->hw->regs->sw_mutex;
595595
u32 val, id;
596596

597597
if (!i2c_dev->hw->has_mutex)
598-
return 0;
598+
return;
599599

600600
val = readl(i2c_dev->base + reg);
601601

602602
id = FIELD_GET(I2C_SW_MUTEX_GRANT, val);
603-
if (id && id != I2C_SW_MUTEX_ID_CCPLEX) {
604-
dev_warn(i2c_dev->dev, "unable to unlock mutex, mutex is owned by: %u\n", id);
605-
return -EPERM;
606-
}
603+
if (WARN(id && id != I2C_SW_MUTEX_ID_CCPLEX,
604+
"unable to unlock mutex, mutex is owned by: %u\n", id))
605+
return;
607606

608607
writel(0, i2c_dev->base + reg);
609-
610-
return 0;
611608
}
612609

613610
static void tegra_i2c_mask_irq(struct tegra_i2c_dev *i2c_dev, u32 mask)
@@ -1666,8 +1663,10 @@ static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
16661663
}
16671664

16681665
ret = tegra_i2c_mutex_lock(i2c_dev);
1669-
if (ret)
1666+
if (ret) {
1667+
pm_runtime_put(i2c_dev->dev);
16701668
return ret;
1669+
}
16711670

16721671
for (i = 0; i < num; i++) {
16731672
enum msg_end_type end_type = MSG_END_STOP;
@@ -1698,7 +1697,7 @@ static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
16981697
break;
16991698
}
17001699

1701-
ret = tegra_i2c_mutex_unlock(i2c_dev);
1700+
tegra_i2c_mutex_unlock(i2c_dev);
17021701
pm_runtime_put(i2c_dev->dev);
17031702

17041703
return ret ?: i;

drivers/i2c/i2c-core-smbus.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr,
353353
&& size != I2C_SMBUS_I2C_BLOCK_DATA);
354354

355355
msgbuf0[0] = command;
356+
msgbuf1[0] = 0;
356357
switch (size) {
357358
case I2C_SMBUS_QUICK:
358359
msg[0].len = 0;

0 commit comments

Comments
 (0)