Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3f3a89e1 authored by Peter Rosin's avatar Peter Rosin Committed by Wolfram Sang
Browse files

i2c: remove i2c_lock_adapter and use i2c_lock_bus directly



The i2c_lock_adapter name is ambiguous since it is unclear if it
refers to the root adapter or the adapter you name in the argument.
The natural interpretation is the adapter you name in the argument,
but there are historical reasons for that not being the case; it
in fact locks the root adapter. Just remove the function and force
users to spell out the I2C_LOCK_ROOT_ADAPTER name to indicate what
is really going on. Also remove i2c_unlock_adapter, of course.

This patch was generated with

git grep -l 'i2c_\(un\)\?lock_adapter' \
| xargs sed -i 's/i2c_\(un\)\?lock_adapter(\([^)]*\))/'\
'i2c_\1lock_bus(\2, I2C_LOCK_ROOT_ADAPTER)/g'

followed by white-space touch-up.

Signed-off-by: default avatarPeter Rosin <peda@axentia.se>
Acked-by: default avatarJonathan Cameron <jonathan.cameron@huawei.com>
Tested-by: default avatarSekhar Nori <nsekhar@ti.com>
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
parent 8c8f74f3
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -689,9 +689,9 @@ static int brcmstb_i2c_suspend(struct device *dev)
{
	struct brcmstb_i2c_dev *i2c_dev = dev_get_drvdata(dev);

	i2c_lock_adapter(&i2c_dev->adapter);
	i2c_lock_bus(&i2c_dev->adapter, I2C_LOCK_ROOT_ADAPTER);
	i2c_dev->is_suspended = true;
	i2c_unlock_adapter(&i2c_dev->adapter);
	i2c_unlock_bus(&i2c_dev->adapter, I2C_LOCK_ROOT_ADAPTER);

	return 0;
}
@@ -700,10 +700,10 @@ static int brcmstb_i2c_resume(struct device *dev)
{
	struct brcmstb_i2c_dev *i2c_dev = dev_get_drvdata(dev);

	i2c_lock_adapter(&i2c_dev->adapter);
	i2c_lock_bus(&i2c_dev->adapter, I2C_LOCK_ROOT_ADAPTER);
	brcmstb_i2c_set_bsc_reg_defaults(i2c_dev);
	i2c_dev->is_suspended = false;
	i2c_unlock_adapter(&i2c_dev->adapter);
	i2c_unlock_bus(&i2c_dev->adapter, I2C_LOCK_ROOT_ADAPTER);

	return 0;
}
+2 −2
Original line number Diff line number Diff line
@@ -714,14 +714,14 @@ static int i2c_davinci_cpufreq_transition(struct notifier_block *nb,

	dev = container_of(nb, struct davinci_i2c_dev, freq_transition);

	i2c_lock_adapter(&dev->adapter);
	i2c_lock_bus(&dev->adapter, I2C_LOCK_ROOT_ADAPTER);
	if (val == CPUFREQ_PRECHANGE) {
		davinci_i2c_reset_ctrl(dev, 0);
	} else if (val == CPUFREQ_POSTCHANGE) {
		i2c_davinci_calc_clk_dividers(dev);
		davinci_i2c_reset_ctrl(dev, 1);
	}
	i2c_unlock_adapter(&dev->adapter);
	i2c_unlock_bus(&dev->adapter, I2C_LOCK_ROOT_ADAPTER);

	return 0;
}
+20 −20
Original line number Diff line number Diff line
@@ -82,18 +82,18 @@ static int fops_##wire##_get(void *data, u64 *val) \
{								\
	struct i2c_gpio_private_data *priv = data;		\
								\
	i2c_lock_adapter(&priv->adap);			\
	i2c_lock_bus(&priv->adap, I2C_LOCK_ROOT_ADAPTER);	\
	*val = get##wire(&priv->bit_data);			\
	i2c_unlock_adapter(&priv->adap);		\
	i2c_unlock_bus(&priv->adap, I2C_LOCK_ROOT_ADAPTER);	\
	return 0;						\
}								\
static int fops_##wire##_set(void *data, u64 val)		\
{								\
	struct i2c_gpio_private_data *priv = data;		\
								\
	i2c_lock_adapter(&priv->adap);			\
	i2c_lock_bus(&priv->adap, I2C_LOCK_ROOT_ADAPTER);	\
	set##wire(&priv->bit_data, val);			\
	i2c_unlock_adapter(&priv->adap);		\
	i2c_unlock_bus(&priv->adap, I2C_LOCK_ROOT_ADAPTER);	\
	return 0;						\
}								\
DEFINE_DEBUGFS_ATTRIBUTE(fops_##wire, fops_##wire##_get, fops_##wire##_set, "%llu\n")
@@ -113,7 +113,7 @@ static int fops_incomplete_transfer_set(void *data, u64 addr)
	/* ADDR (7 bit) + RD (1 bit) + SDA hi (1 bit) */
	pattern = (addr << 2) | 3;

	i2c_lock_adapter(&priv->adap);
	i2c_lock_bus(&priv->adap, I2C_LOCK_ROOT_ADAPTER);

	/* START condition */
	setsda(bit_data, 0);
@@ -129,7 +129,7 @@ static int fops_incomplete_transfer_set(void *data, u64 addr)
		udelay(bit_data->udelay);
	}

	i2c_unlock_adapter(&priv->adap);
	i2c_unlock_bus(&priv->adap, I2C_LOCK_ROOT_ADAPTER);

	return 0;
}
+2 −2
Original line number Diff line number Diff line
@@ -919,9 +919,9 @@ static int s3c24xx_i2c_cpufreq_transition(struct notifier_block *nb,

	if ((val == CPUFREQ_POSTCHANGE && delta_f < 0) ||
	    (val == CPUFREQ_PRECHANGE && delta_f > 0)) {
		i2c_lock_adapter(&i2c->adap);
		i2c_lock_bus(&i2c->adap, I2C_LOCK_ROOT_ADAPTER);
		ret = s3c24xx_i2c_clockrate(i2c, &got);
		i2c_unlock_adapter(&i2c->adap);
		i2c_unlock_bus(&i2c->adap, I2C_LOCK_ROOT_ADAPTER);

		if (ret < 0)
			dev_err(i2c->dev, "cannot find frequency (%d)\n", ret);
+4 −4
Original line number Diff line number Diff line
@@ -590,9 +590,9 @@ static int __maybe_unused sprd_i2c_suspend_noirq(struct device *pdev)
{
	struct sprd_i2c *i2c_dev = dev_get_drvdata(pdev);

	i2c_lock_adapter(&i2c_dev->adap);
	i2c_lock_bus(&i2c_dev->adap, I2C_LOCK_ROOT_ADAPTER);
	i2c_dev->is_suspended = true;
	i2c_unlock_adapter(&i2c_dev->adap);
	i2c_unlock_bus(&i2c_dev->adap, I2C_LOCK_ROOT_ADAPTER);

	return pm_runtime_force_suspend(pdev);
}
@@ -601,9 +601,9 @@ static int __maybe_unused sprd_i2c_resume_noirq(struct device *pdev)
{
	struct sprd_i2c *i2c_dev = dev_get_drvdata(pdev);

	i2c_lock_adapter(&i2c_dev->adap);
	i2c_lock_bus(&i2c_dev->adap, I2C_LOCK_ROOT_ADAPTER);
	i2c_dev->is_suspended = false;
	i2c_unlock_adapter(&i2c_dev->adap);
	i2c_unlock_bus(&i2c_dev->adap, I2C_LOCK_ROOT_ADAPTER);

	return pm_runtime_force_resume(pdev);
}
Loading