Commit 24214ad4 authored by Wolfram Sang's avatar Wolfram Sang
Browse files

Merge tag 'i2c-host-fixes-7.1-rc4' of...

Merge tag 'i2c-host-fixes-7.1-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux into i2c/for-current

i2c-host-fixes for v7.1-rc4

- tegra:
  - drop runtime PM reference when exiting on mutex_lock failure
  - preserve transfer errors when releasing the mutex
parents 5200f5f4 30792d12
Loading
Loading
Loading
Loading
+9 −10
Original line number Diff line number Diff line
@@ -589,25 +589,22 @@ static int tegra_i2c_mutex_lock(struct tegra_i2c_dev *i2c_dev)
	return ret;
}

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

	if (!i2c_dev->hw->has_mutex)
		return 0;
		return;

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

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

	writel(0, i2c_dev->base + reg);

	return 0;
}

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[],
	}

	ret = tegra_i2c_mutex_lock(i2c_dev);
	if (ret)
	if (ret) {
		pm_runtime_put(i2c_dev->dev);
		return ret;
	}

	for (i = 0; i < num; i++) {
		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[],
			break;
	}

	ret = tegra_i2c_mutex_unlock(i2c_dev);
	tegra_i2c_mutex_unlock(i2c_dev);
	pm_runtime_put(i2c_dev->dev);

	return ret ?: i;