Skip to content

Commit 30792d1

Browse files
Saurav SachidanandAndi Shyti
authored andcommitted
i2c: tegra: make tegra_i2c_mutex_unlock() return void
tegra_i2c_mutex_unlock() returning an error that overwrites the transfer result causes silent loss of I2C transfer errors. If the transfer failed but the unlock succeeded, the error was lost and the function incorrectly reported success. Rather than propagating the unlock error (which is not actionable by the caller - the I2C message may have been sent regardless), convert the function to return void and WARN on the unexpected condition. If the unlock fails, subsequent lock attempts will fail anyway, making the error visible on the next transfer. Fixes: 6077cfd ("i2c: tegra: Add support for SW mutex register") Signed-off-by: Saurav Sachidanand <sauravsc@amazon.com> Cc: <stable@vger.kernel.org> # v7.0+ Reviewed-by: Jon Hunter <jonathanh@nvidia.com> Acked-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Andi Shyti <andi.shyti@kernel.org> Link: https://lore.kernel.org/r/20260507221145.62183-3-sauravsc@amazon.com
1 parent 57cf4e8 commit 30792d1

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

drivers/i2c/busses/i2c-tegra.c

Lines changed: 6 additions & 9 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)
@@ -1700,7 +1697,7 @@ static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
17001697
break;
17011698
}
17021699

1703-
ret = tegra_i2c_mutex_unlock(i2c_dev);
1700+
tegra_i2c_mutex_unlock(i2c_dev);
17041701
pm_runtime_put(i2c_dev->dev);
17051702

17061703
return ret ?: i;

0 commit comments

Comments
 (0)