All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/11] Split i2c_lock_adapter into i2c_lock_root and i2c_lock_segment
@ 2018-06-15 10:14 ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:14 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Rosin, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding

Hi!

With the introduction of mux-locked I2C muxes, the concept of
locking only a segment of the I2C adapter tree was added. At the
time, I did not want to cause a lot of extra churn, so left most
users of i2c_lock_adapter alone and aparently didn't think enough
about it; they simply continued to lock the whole adapter tree.
However, i2c_lock_adapter is in fact wrong for almost every caller
(there are naturally exceptions) that is itself not a driver for
a root adapter. What normal drivers generally want is to only
lock the segment of the adapter tree that their device sits on.

In fact, if a device sits behind a mux-locked I2C mux, and its
driver calls i2c_lock_adapter followed by an unlocked I2C transfer,
things will deadlock (since even a mux-locked I2C adapter will lock
its parent at some point). If the device is not sitting behind a
mux-locked I2C mux (i.e. either directly on the root adapter or
behind a (chain of) parent-locked I2C muxes) the root/segment
distinction is of no consequence; the root adapter is locked either
way.

Mux-locked I2C muxes are probably not that common, and putting any
of the affected devices behind one is probably even rarer, which
is why we have not seen any deadlocks. At least not that I know
of...

Since silently changing the semantics of i2c_lock_adapter might
be quite a surprise, especially for out-of-tree users, this
series instead introduces new helpers to make it easier to only
lock the I2C segment, then converts drivers over and finally
renames the remaining i2c_lock_adapter instances to i2c_lock_root.

I suggest that Wolfram takes this series through the I2C tree
and creates an immutable branch for the other subsystems. The
series is based on v4.17, but I did not find any new instances in
neither linus-master nor linux-next and the series still applies
cleanly to linus-master for me. linux-next has removed suspend
support from the i2c-tegra driver. A bit strange, I thought the
I2C changes was merged for this window? Anyway, the resolution
for that conflict is trivial, just remove the i2c-tegra hunk from
patch 11.

I do not have *any* of the affected devices, and have thus only
done build tests.

Cheers,
Peter

Peter Rosin (11):
  i2c: add helpers for locking the I2C segment
  tpm/tpm_i2c_infineon: switch to i2c_lock_segment
  i2c: mux: pca9541: switch to i2c_lock_segment
  input: rohm_bu21023: switch to i2c_lock_segment
  media: af9013: switch to i2c_lock_segment
  media: drxk_hard: switch to i2c_lock_segment
  media: rtl2830: switch to i2c_lock_segment
  media: tda1004x: switch to i2c_lock_segment
  media: tda18271: switch to i2c_lock_segment
  mfd: 88pm860x-i2c: switch to i2c_lock_segment
  i2c: rename i2c_lock_adapter to i2c_lock_root

 drivers/char/tpm/tpm_i2c_infineon.c      |  8 ++++----
 drivers/i2c/busses/i2c-brcmstb.c         |  8 ++++----
 drivers/i2c/busses/i2c-davinci.c         |  4 ++--
 drivers/i2c/busses/i2c-gpio.c            | 12 ++++++------
 drivers/i2c/busses/i2c-s3c2410.c         |  4 ++--
 drivers/i2c/busses/i2c-sprd.c            |  8 ++++----
 drivers/i2c/busses/i2c-tegra.c           |  8 ++++----
 drivers/i2c/i2c-core-base.c              |  6 +++---
 drivers/i2c/i2c-core-slave.c             |  8 ++++----
 drivers/i2c/i2c-core-smbus.c             |  4 ++--
 drivers/i2c/muxes/i2c-mux-pca9541.c      |  6 +++---
 drivers/iio/temperature/mlx90614.c       |  4 ++--
 drivers/input/touchscreen/rohm_bu21023.c |  4 ++--
 drivers/media/dvb-frontends/af9013.c     |  8 ++++----
 drivers/media/dvb-frontends/drxk_hard.c  |  4 ++--
 drivers/media/dvb-frontends/rtl2830.c    | 12 ++++++------
 drivers/media/dvb-frontends/tda1004x.c   |  6 +++---
 drivers/media/tuners/tda18271-common.c   |  8 ++++----
 drivers/mfd/88pm860x-i2c.c               |  8 ++++----
 include/linux/i2c.h                      | 22 ++++++++++++++++++++--
 20 files changed, 85 insertions(+), 67 deletions(-)

-- 
2.11.0

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [PATCH 00/11] Split i2c_lock_adapter into i2c_lock_root and i2c_lock_segment
@ 2018-06-15 10:14 ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:14 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Rosin, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding, Jonathan Hunter, Wolfram Sang,
	Guenter Roeck, Crt Mori, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, Dmitry Torokhov,
	Antti Palosaari, Mauro Carvalho Chehab, Michael Krufky,
	Lee Jones, linux-integrity, linux-i2c, linux-arm-kernel,
	linux-samsung-soc, linux-tegra, linux-iio, linux-input,
	linux-media

Hi!

With the introduction of mux-locked I2C muxes, the concept of
locking only a segment of the I2C adapter tree was added. At the
time, I did not want to cause a lot of extra churn, so left most
users of i2c_lock_adapter alone and aparently didn't think enough
about it; they simply continued to lock the whole adapter tree.
However, i2c_lock_adapter is in fact wrong for almost every caller
(there are naturally exceptions) that is itself not a driver for
a root adapter. What normal drivers generally want is to only
lock the segment of the adapter tree that their device sits on.

In fact, if a device sits behind a mux-locked I2C mux, and its
driver calls i2c_lock_adapter followed by an unlocked I2C transfer,
things will deadlock (since even a mux-locked I2C adapter will lock
its parent at some point). If the device is not sitting behind a
mux-locked I2C mux (i.e. either directly on the root adapter or
behind a (chain of) parent-locked I2C muxes) the root/segment
distinction is of no consequence; the root adapter is locked either
way.

Mux-locked I2C muxes are probably not that common, and putting any
of the affected devices behind one is probably even rarer, which
is why we have not seen any deadlocks. At least not that I know
of...

Since silently changing the semantics of i2c_lock_adapter might
be quite a surprise, especially for out-of-tree users, this
series instead introduces new helpers to make it easier to only
lock the I2C segment, then converts drivers over and finally
renames the remaining i2c_lock_adapter instances to i2c_lock_root.

I suggest that Wolfram takes this series through the I2C tree
and creates an immutable branch for the other subsystems. The
series is based on v4.17, but I did not find any new instances in
neither linus-master nor linux-next and the series still applies
cleanly to linus-master for me. linux-next has removed suspend
support from the i2c-tegra driver. A bit strange, I thought the
I2C changes was merged for this window? Anyway, the resolution
for that conflict is trivial, just remove the i2c-tegra hunk from
patch 11.

I do not have *any* of the affected devices, and have thus only
done build tests.

Cheers,
Peter

Peter Rosin (11):
  i2c: add helpers for locking the I2C segment
  tpm/tpm_i2c_infineon: switch to i2c_lock_segment
  i2c: mux: pca9541: switch to i2c_lock_segment
  input: rohm_bu21023: switch to i2c_lock_segment
  media: af9013: switch to i2c_lock_segment
  media: drxk_hard: switch to i2c_lock_segment
  media: rtl2830: switch to i2c_lock_segment
  media: tda1004x: switch to i2c_lock_segment
  media: tda18271: switch to i2c_lock_segment
  mfd: 88pm860x-i2c: switch to i2c_lock_segment
  i2c: rename i2c_lock_adapter to i2c_lock_root

 drivers/char/tpm/tpm_i2c_infineon.c      |  8 ++++----
 drivers/i2c/busses/i2c-brcmstb.c         |  8 ++++----
 drivers/i2c/busses/i2c-davinci.c         |  4 ++--
 drivers/i2c/busses/i2c-gpio.c            | 12 ++++++------
 drivers/i2c/busses/i2c-s3c2410.c         |  4 ++--
 drivers/i2c/busses/i2c-sprd.c            |  8 ++++----
 drivers/i2c/busses/i2c-tegra.c           |  8 ++++----
 drivers/i2c/i2c-core-base.c              |  6 +++---
 drivers/i2c/i2c-core-slave.c             |  8 ++++----
 drivers/i2c/i2c-core-smbus.c             |  4 ++--
 drivers/i2c/muxes/i2c-mux-pca9541.c      |  6 +++---
 drivers/iio/temperature/mlx90614.c       |  4 ++--
 drivers/input/touchscreen/rohm_bu21023.c |  4 ++--
 drivers/media/dvb-frontends/af9013.c     |  8 ++++----
 drivers/media/dvb-frontends/drxk_hard.c  |  4 ++--
 drivers/media/dvb-frontends/rtl2830.c    | 12 ++++++------
 drivers/media/dvb-frontends/tda1004x.c   |  6 +++---
 drivers/media/tuners/tda18271-common.c   |  8 ++++----
 drivers/mfd/88pm860x-i2c.c               |  8 ++++----
 include/linux/i2c.h                      | 22 ++++++++++++++++++++--
 20 files changed, 85 insertions(+), 67 deletions(-)

-- 
2.11.0


^ permalink raw reply	[flat|nested] 63+ messages in thread

* [PATCH 00/11] Split i2c_lock_adapter into i2c_lock_root and i2c_lock_segment
@ 2018-06-15 10:14 ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:14 UTC (permalink / raw)
  To: linux-arm-kernel

Hi!

With the introduction of mux-locked I2C muxes, the concept of
locking only a segment of the I2C adapter tree was added. At the
time, I did not want to cause a lot of extra churn, so left most
users of i2c_lock_adapter alone and aparently didn't think enough
about it; they simply continued to lock the whole adapter tree.
However, i2c_lock_adapter is in fact wrong for almost every caller
(there are naturally exceptions) that is itself not a driver for
a root adapter. What normal drivers generally want is to only
lock the segment of the adapter tree that their device sits on.

In fact, if a device sits behind a mux-locked I2C mux, and its
driver calls i2c_lock_adapter followed by an unlocked I2C transfer,
things will deadlock (since even a mux-locked I2C adapter will lock
its parent at some point). If the device is not sitting behind a
mux-locked I2C mux (i.e. either directly on the root adapter or
behind a (chain of) parent-locked I2C muxes) the root/segment
distinction is of no consequence; the root adapter is locked either
way.

Mux-locked I2C muxes are probably not that common, and putting any
of the affected devices behind one is probably even rarer, which
is why we have not seen any deadlocks. At least not that I know
of...

Since silently changing the semantics of i2c_lock_adapter might
be quite a surprise, especially for out-of-tree users, this
series instead introduces new helpers to make it easier to only
lock the I2C segment, then converts drivers over and finally
renames the remaining i2c_lock_adapter instances to i2c_lock_root.

I suggest that Wolfram takes this series through the I2C tree
and creates an immutable branch for the other subsystems. The
series is based on v4.17, but I did not find any new instances in
neither linus-master nor linux-next and the series still applies
cleanly to linus-master for me. linux-next has removed suspend
support from the i2c-tegra driver. A bit strange, I thought the
I2C changes was merged for this window? Anyway, the resolution
for that conflict is trivial, just remove the i2c-tegra hunk from
patch 11.

I do not have *any* of the affected devices, and have thus only
done build tests.

Cheers,
Peter

Peter Rosin (11):
  i2c: add helpers for locking the I2C segment
  tpm/tpm_i2c_infineon: switch to i2c_lock_segment
  i2c: mux: pca9541: switch to i2c_lock_segment
  input: rohm_bu21023: switch to i2c_lock_segment
  media: af9013: switch to i2c_lock_segment
  media: drxk_hard: switch to i2c_lock_segment
  media: rtl2830: switch to i2c_lock_segment
  media: tda1004x: switch to i2c_lock_segment
  media: tda18271: switch to i2c_lock_segment
  mfd: 88pm860x-i2c: switch to i2c_lock_segment
  i2c: rename i2c_lock_adapter to i2c_lock_root

 drivers/char/tpm/tpm_i2c_infineon.c      |  8 ++++----
 drivers/i2c/busses/i2c-brcmstb.c         |  8 ++++----
 drivers/i2c/busses/i2c-davinci.c         |  4 ++--
 drivers/i2c/busses/i2c-gpio.c            | 12 ++++++------
 drivers/i2c/busses/i2c-s3c2410.c         |  4 ++--
 drivers/i2c/busses/i2c-sprd.c            |  8 ++++----
 drivers/i2c/busses/i2c-tegra.c           |  8 ++++----
 drivers/i2c/i2c-core-base.c              |  6 +++---
 drivers/i2c/i2c-core-slave.c             |  8 ++++----
 drivers/i2c/i2c-core-smbus.c             |  4 ++--
 drivers/i2c/muxes/i2c-mux-pca9541.c      |  6 +++---
 drivers/iio/temperature/mlx90614.c       |  4 ++--
 drivers/input/touchscreen/rohm_bu21023.c |  4 ++--
 drivers/media/dvb-frontends/af9013.c     |  8 ++++----
 drivers/media/dvb-frontends/drxk_hard.c  |  4 ++--
 drivers/media/dvb-frontends/rtl2830.c    | 12 ++++++------
 drivers/media/dvb-frontends/tda1004x.c   |  6 +++---
 drivers/media/tuners/tda18271-common.c   |  8 ++++----
 drivers/mfd/88pm860x-i2c.c               |  8 ++++----
 include/linux/i2c.h                      | 22 ++++++++++++++++++++--
 20 files changed, 85 insertions(+), 67 deletions(-)

-- 
2.11.0

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [PATCH 01/11] i2c: add helpers for locking the I2C segment
  2018-06-15 10:14 ` Peter Rosin
  (?)
@ 2018-06-15 10:14   ` Peter Rosin
  -1 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:14 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Rosin, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding

This is what almost all drivers want to do. By only advertising
i2c_lock_adapter, they are tricked into locking the root adapter
which is too big of a hammer in most cases.

While at it, convert all open-coded locking of the I2C segment.

Signed-off-by: Peter Rosin <peda@axentia.se>
---
 drivers/i2c/i2c-core-base.c  |  6 +++---
 drivers/i2c/i2c-core-smbus.c |  4 ++--
 include/linux/i2c.h          | 18 ++++++++++++++++++
 3 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 1ba40bb2b966..3eb09dc20573 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -1932,16 +1932,16 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
 #endif
 
 		if (in_atomic() || irqs_disabled()) {
-			ret = i2c_trylock_bus(adap, I2C_LOCK_SEGMENT);
+			ret = i2c_trylock_segment(adap);
 			if (!ret)
 				/* I2C activity is ongoing. */
 				return -EAGAIN;
 		} else {
-			i2c_lock_bus(adap, I2C_LOCK_SEGMENT);
+			i2c_lock_segment(adap);
 		}
 
 		ret = __i2c_transfer(adap, msgs, num);
-		i2c_unlock_bus(adap, I2C_LOCK_SEGMENT);
+		i2c_unlock_segment(adap);
 
 		return ret;
 	} else {
diff --git a/drivers/i2c/i2c-core-smbus.c b/drivers/i2c/i2c-core-smbus.c
index b5aec33002c3..8a820fdef3e0 100644
--- a/drivers/i2c/i2c-core-smbus.c
+++ b/drivers/i2c/i2c-core-smbus.c
@@ -537,7 +537,7 @@ s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, unsigned short flags,
 	flags &= I2C_M_TEN | I2C_CLIENT_PEC | I2C_CLIENT_SCCB;
 
 	if (adapter->algo->smbus_xfer) {
-		i2c_lock_bus(adapter, I2C_LOCK_SEGMENT);
+		i2c_lock_segment(adapter);
 
 		/* Retry automatically on arbitration loss */
 		orig_jiffies = jiffies;
@@ -551,7 +551,7 @@ s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, unsigned short flags,
 				       orig_jiffies + adapter->timeout))
 				break;
 		}
-		i2c_unlock_bus(adapter, I2C_LOCK_SEGMENT);
+		i2c_unlock_segment(adapter);
 
 		if (res != -EOPNOTSUPP || !adapter->algo->master_xfer)
 			goto trace;
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 44ad14e016b5..c9080d49e988 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -768,6 +768,24 @@ i2c_unlock_adapter(struct i2c_adapter *adapter)
 	i2c_unlock_bus(adapter, I2C_LOCK_ROOT_ADAPTER);
 }
 
+static inline void
+i2c_lock_segment(struct i2c_adapter *adapter)
+{
+	i2c_lock_bus(adapter, I2C_LOCK_SEGMENT);
+}
+
+static inline int
+i2c_trylock_segment(struct i2c_adapter *adapter)
+{
+	return i2c_trylock_bus(adapter, I2C_LOCK_SEGMENT);
+}
+
+static inline void
+i2c_unlock_segment(struct i2c_adapter *adapter)
+{
+	i2c_unlock_bus(adapter, I2C_LOCK_SEGMENT);
+}
+
 /*flags for the client struct: */
 #define I2C_CLIENT_PEC		0x04	/* Use Packet Error Checking */
 #define I2C_CLIENT_TEN		0x10	/* we have a ten bit chip address */
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 01/11] i2c: add helpers for locking the I2C segment
@ 2018-06-15 10:14   ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:14 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Rosin, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding, Jonathan Hunter, Wolfram Sang,
	Guenter Roeck, Crt Mori, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, Dmitry Torokhov,
	Antti Palosaari, Mauro Carvalho Chehab, Michael Krufky,
	Lee Jones, linux-integrity, linux-i2c, linux-arm-kernel,
	linux-samsung-soc, linux-tegra, linux-iio, linux-input,
	linux-media

This is what almost all drivers want to do. By only advertising
i2c_lock_adapter, they are tricked into locking the root adapter
which is too big of a hammer in most cases.

While at it, convert all open-coded locking of the I2C segment.

Signed-off-by: Peter Rosin <peda@axentia.se>
---
 drivers/i2c/i2c-core-base.c  |  6 +++---
 drivers/i2c/i2c-core-smbus.c |  4 ++--
 include/linux/i2c.h          | 18 ++++++++++++++++++
 3 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 1ba40bb2b966..3eb09dc20573 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -1932,16 +1932,16 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
 #endif
 
 		if (in_atomic() || irqs_disabled()) {
-			ret = i2c_trylock_bus(adap, I2C_LOCK_SEGMENT);
+			ret = i2c_trylock_segment(adap);
 			if (!ret)
 				/* I2C activity is ongoing. */
 				return -EAGAIN;
 		} else {
-			i2c_lock_bus(adap, I2C_LOCK_SEGMENT);
+			i2c_lock_segment(adap);
 		}
 
 		ret = __i2c_transfer(adap, msgs, num);
-		i2c_unlock_bus(adap, I2C_LOCK_SEGMENT);
+		i2c_unlock_segment(adap);
 
 		return ret;
 	} else {
diff --git a/drivers/i2c/i2c-core-smbus.c b/drivers/i2c/i2c-core-smbus.c
index b5aec33002c3..8a820fdef3e0 100644
--- a/drivers/i2c/i2c-core-smbus.c
+++ b/drivers/i2c/i2c-core-smbus.c
@@ -537,7 +537,7 @@ s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, unsigned short flags,
 	flags &= I2C_M_TEN | I2C_CLIENT_PEC | I2C_CLIENT_SCCB;
 
 	if (adapter->algo->smbus_xfer) {
-		i2c_lock_bus(adapter, I2C_LOCK_SEGMENT);
+		i2c_lock_segment(adapter);
 
 		/* Retry automatically on arbitration loss */
 		orig_jiffies = jiffies;
@@ -551,7 +551,7 @@ s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, unsigned short flags,
 				       orig_jiffies + adapter->timeout))
 				break;
 		}
-		i2c_unlock_bus(adapter, I2C_LOCK_SEGMENT);
+		i2c_unlock_segment(adapter);
 
 		if (res != -EOPNOTSUPP || !adapter->algo->master_xfer)
 			goto trace;
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 44ad14e016b5..c9080d49e988 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -768,6 +768,24 @@ i2c_unlock_adapter(struct i2c_adapter *adapter)
 	i2c_unlock_bus(adapter, I2C_LOCK_ROOT_ADAPTER);
 }
 
+static inline void
+i2c_lock_segment(struct i2c_adapter *adapter)
+{
+	i2c_lock_bus(adapter, I2C_LOCK_SEGMENT);
+}
+
+static inline int
+i2c_trylock_segment(struct i2c_adapter *adapter)
+{
+	return i2c_trylock_bus(adapter, I2C_LOCK_SEGMENT);
+}
+
+static inline void
+i2c_unlock_segment(struct i2c_adapter *adapter)
+{
+	i2c_unlock_bus(adapter, I2C_LOCK_SEGMENT);
+}
+
 /*flags for the client struct: */
 #define I2C_CLIENT_PEC		0x04	/* Use Packet Error Checking */
 #define I2C_CLIENT_TEN		0x10	/* we have a ten bit chip address */
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 01/11] i2c: add helpers for locking the I2C segment
@ 2018-06-15 10:14   ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:14 UTC (permalink / raw)
  To: linux-arm-kernel

This is what almost all drivers want to do. By only advertising
i2c_lock_adapter, they are tricked into locking the root adapter
which is too big of a hammer in most cases.

While at it, convert all open-coded locking of the I2C segment.

Signed-off-by: Peter Rosin <peda@axentia.se>
---
 drivers/i2c/i2c-core-base.c  |  6 +++---
 drivers/i2c/i2c-core-smbus.c |  4 ++--
 include/linux/i2c.h          | 18 ++++++++++++++++++
 3 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 1ba40bb2b966..3eb09dc20573 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -1932,16 +1932,16 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
 #endif
 
 		if (in_atomic() || irqs_disabled()) {
-			ret = i2c_trylock_bus(adap, I2C_LOCK_SEGMENT);
+			ret = i2c_trylock_segment(adap);
 			if (!ret)
 				/* I2C activity is ongoing. */
 				return -EAGAIN;
 		} else {
-			i2c_lock_bus(adap, I2C_LOCK_SEGMENT);
+			i2c_lock_segment(adap);
 		}
 
 		ret = __i2c_transfer(adap, msgs, num);
-		i2c_unlock_bus(adap, I2C_LOCK_SEGMENT);
+		i2c_unlock_segment(adap);
 
 		return ret;
 	} else {
diff --git a/drivers/i2c/i2c-core-smbus.c b/drivers/i2c/i2c-core-smbus.c
index b5aec33002c3..8a820fdef3e0 100644
--- a/drivers/i2c/i2c-core-smbus.c
+++ b/drivers/i2c/i2c-core-smbus.c
@@ -537,7 +537,7 @@ s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, unsigned short flags,
 	flags &= I2C_M_TEN | I2C_CLIENT_PEC | I2C_CLIENT_SCCB;
 
 	if (adapter->algo->smbus_xfer) {
-		i2c_lock_bus(adapter, I2C_LOCK_SEGMENT);
+		i2c_lock_segment(adapter);
 
 		/* Retry automatically on arbitration loss */
 		orig_jiffies = jiffies;
@@ -551,7 +551,7 @@ s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, unsigned short flags,
 				       orig_jiffies + adapter->timeout))
 				break;
 		}
-		i2c_unlock_bus(adapter, I2C_LOCK_SEGMENT);
+		i2c_unlock_segment(adapter);
 
 		if (res != -EOPNOTSUPP || !adapter->algo->master_xfer)
 			goto trace;
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 44ad14e016b5..c9080d49e988 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -768,6 +768,24 @@ i2c_unlock_adapter(struct i2c_adapter *adapter)
 	i2c_unlock_bus(adapter, I2C_LOCK_ROOT_ADAPTER);
 }
 
+static inline void
+i2c_lock_segment(struct i2c_adapter *adapter)
+{
+	i2c_lock_bus(adapter, I2C_LOCK_SEGMENT);
+}
+
+static inline int
+i2c_trylock_segment(struct i2c_adapter *adapter)
+{
+	return i2c_trylock_bus(adapter, I2C_LOCK_SEGMENT);
+}
+
+static inline void
+i2c_unlock_segment(struct i2c_adapter *adapter)
+{
+	i2c_unlock_bus(adapter, I2C_LOCK_SEGMENT);
+}
+
 /*flags for the client struct: */
 #define I2C_CLIENT_PEC		0x04	/* Use Packet Error Checking */
 #define I2C_CLIENT_TEN		0x10	/* we have a ten bit chip address */
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 02/11] tpm/tpm_i2c_infineon: switch to i2c_lock_segment
  2018-06-15 10:14 ` Peter Rosin
  (?)
@ 2018-06-15 10:14   ` Peter Rosin
  -1 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:14 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Rosin, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding

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_segment. 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>
---
 drivers/char/tpm/tpm_i2c_infineon.c | 8 ++++----
 1 file 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..b2889405b4fa 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)
 	/* Lock the adapter for the duration of the whole sequence. */
 	if (!tpm_dev.client->adapter->algo->master_xfer)
 		return -EOPNOTSUPP;
-	i2c_lock_adapter(tpm_dev.client->adapter);
+	i2c_lock_segment(tpm_dev.client->adapter);
 
 	if (tpm_dev.chip_type == SLB9645) {
 		/* use a combined read for newer chips
@@ -192,7 +192,7 @@ static int iic_tpm_read(u8 addr, u8 *buffer, size_t len)
 	}
 
 out:
-	i2c_unlock_adapter(tpm_dev.client->adapter);
+	i2c_unlock_segment(tpm_dev.client->adapter);
 	/* take care of 'guard time' */
 	usleep_range(SLEEP_DURATION_LOW, SLEEP_DURATION_HI);
 
@@ -224,7 +224,7 @@ static int iic_tpm_write_generic(u8 addr, u8 *buffer, size_t len,
 
 	if (!tpm_dev.client->adapter->algo->master_xfer)
 		return -EOPNOTSUPP;
-	i2c_lock_adapter(tpm_dev.client->adapter);
+	i2c_lock_segment(tpm_dev.client->adapter);
 
 	/* prepend the 'register address' to the buffer */
 	tpm_dev.buf[0] = addr;
@@ -243,7 +243,7 @@ static int iic_tpm_write_generic(u8 addr, u8 *buffer, size_t len,
 		usleep_range(sleep_low, sleep_hi);
 	}
 
-	i2c_unlock_adapter(tpm_dev.client->adapter);
+	i2c_unlock_segment(tpm_dev.client->adapter);
 	/* take care of 'guard time' */
 	usleep_range(SLEEP_DURATION_LOW, SLEEP_DURATION_HI);
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 02/11] tpm/tpm_i2c_infineon: switch to i2c_lock_segment
@ 2018-06-15 10:14   ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:14 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Rosin, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding, Jonathan Hunter, Wolfram Sang,
	Guenter Roeck, Crt Mori, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, Dmitry Torokhov,
	Antti Palosaari, Mauro Carvalho Chehab, Michael Krufky,
	Lee Jones, linux-integrity, linux-i2c, linux-arm-kernel,
	linux-samsung-soc, linux-tegra, linux-iio, linux-input,
	linux-media

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_segment. 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>
---
 drivers/char/tpm/tpm_i2c_infineon.c | 8 ++++----
 1 file 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..b2889405b4fa 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)
 	/* Lock the adapter for the duration of the whole sequence. */
 	if (!tpm_dev.client->adapter->algo->master_xfer)
 		return -EOPNOTSUPP;
-	i2c_lock_adapter(tpm_dev.client->adapter);
+	i2c_lock_segment(tpm_dev.client->adapter);
 
 	if (tpm_dev.chip_type == SLB9645) {
 		/* use a combined read for newer chips
@@ -192,7 +192,7 @@ static int iic_tpm_read(u8 addr, u8 *buffer, size_t len)
 	}
 
 out:
-	i2c_unlock_adapter(tpm_dev.client->adapter);
+	i2c_unlock_segment(tpm_dev.client->adapter);
 	/* take care of 'guard time' */
 	usleep_range(SLEEP_DURATION_LOW, SLEEP_DURATION_HI);
 
@@ -224,7 +224,7 @@ static int iic_tpm_write_generic(u8 addr, u8 *buffer, size_t len,
 
 	if (!tpm_dev.client->adapter->algo->master_xfer)
 		return -EOPNOTSUPP;
-	i2c_lock_adapter(tpm_dev.client->adapter);
+	i2c_lock_segment(tpm_dev.client->adapter);
 
 	/* prepend the 'register address' to the buffer */
 	tpm_dev.buf[0] = addr;
@@ -243,7 +243,7 @@ static int iic_tpm_write_generic(u8 addr, u8 *buffer, size_t len,
 		usleep_range(sleep_low, sleep_hi);
 	}
 
-	i2c_unlock_adapter(tpm_dev.client->adapter);
+	i2c_unlock_segment(tpm_dev.client->adapter);
 	/* take care of 'guard time' */
 	usleep_range(SLEEP_DURATION_LOW, SLEEP_DURATION_HI);
 
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 02/11] tpm/tpm_i2c_infineon: switch to i2c_lock_segment
@ 2018-06-15 10:14   ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:14 UTC (permalink / raw)
  To: linux-arm-kernel

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_segment. 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>
---
 drivers/char/tpm/tpm_i2c_infineon.c | 8 ++++----
 1 file 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..b2889405b4fa 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)
 	/* Lock the adapter for the duration of the whole sequence. */
 	if (!tpm_dev.client->adapter->algo->master_xfer)
 		return -EOPNOTSUPP;
-	i2c_lock_adapter(tpm_dev.client->adapter);
+	i2c_lock_segment(tpm_dev.client->adapter);
 
 	if (tpm_dev.chip_type == SLB9645) {
 		/* use a combined read for newer chips
@@ -192,7 +192,7 @@ static int iic_tpm_read(u8 addr, u8 *buffer, size_t len)
 	}
 
 out:
-	i2c_unlock_adapter(tpm_dev.client->adapter);
+	i2c_unlock_segment(tpm_dev.client->adapter);
 	/* take care of 'guard time' */
 	usleep_range(SLEEP_DURATION_LOW, SLEEP_DURATION_HI);
 
@@ -224,7 +224,7 @@ static int iic_tpm_write_generic(u8 addr, u8 *buffer, size_t len,
 
 	if (!tpm_dev.client->adapter->algo->master_xfer)
 		return -EOPNOTSUPP;
-	i2c_lock_adapter(tpm_dev.client->adapter);
+	i2c_lock_segment(tpm_dev.client->adapter);
 
 	/* prepend the 'register address' to the buffer */
 	tpm_dev.buf[0] = addr;
@@ -243,7 +243,7 @@ static int iic_tpm_write_generic(u8 addr, u8 *buffer, size_t len,
 		usleep_range(sleep_low, sleep_hi);
 	}
 
-	i2c_unlock_adapter(tpm_dev.client->adapter);
+	i2c_unlock_segment(tpm_dev.client->adapter);
 	/* take care of 'guard time' */
 	usleep_range(SLEEP_DURATION_LOW, SLEEP_DURATION_HI);
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 03/11] i2c: mux: pca9541: switch to i2c_lock_segment
  2018-06-15 10:14 ` Peter Rosin
  (?)
@ 2018-06-15 10:14   ` Peter Rosin
  -1 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:14 UTC (permalink / raw)
  To: linux-kernel
  Cc: Crt Mori, Wolfram Sang, linux-iio, Sekhar Nori, Jarkko Sakkinen,
	Thierry Reding, linux-i2c, Peter Meerwald-Stadler, Peter Huewe,
	Michael Krufky, Lee Jones, Antti Palosaari, linux-samsung-soc,
	Florian Fainelli, Kevin Hilman, Chunyan Zhang,
	Krzysztof Kozlowski, Jonathan Hunter, Jason Gunthorpe,
	Kukjin Kim, bcm-kernel-feedback-list, linux-input, Orson Zhai,
	Guenter Roeck, Haavard Skinnemoen

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_segment. 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>
---
 drivers/i2c/muxes/i2c-mux-pca9541.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/muxes/i2c-mux-pca9541.c b/drivers/i2c/muxes/i2c-mux-pca9541.c
index 6a39adaf433f..74c560ed44cc 100644
--- a/drivers/i2c/muxes/i2c-mux-pca9541.c
+++ b/drivers/i2c/muxes/i2c-mux-pca9541.c
@@ -345,11 +345,11 @@ static int pca9541_probe(struct i2c_client *client,
 
 	/*
 	 * I2C accesses are unprotected here.
-	 * We have to lock the adapter before releasing the bus.
+	 * We have to lock the I2C segment before releasing the bus.
 	 */
-	i2c_lock_adapter(adap);
+	i2c_lock_segment(adap);
 	pca9541_release_bus(client);
-	i2c_unlock_adapter(adap);
+	i2c_unlock_segment(adap);
 
 	/* Create mux adapter */
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 03/11] i2c: mux: pca9541: switch to i2c_lock_segment
@ 2018-06-15 10:14   ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:14 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Rosin, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding, Jonathan Hunter, Wolfram Sang,
	Guenter Roeck, Crt Mori, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, Dmitry Torokhov,
	Antti Palosaari, Mauro Carvalho Chehab, Michael Krufky,
	Lee Jones, linux-integrity, linux-i2c, linux-arm-kernel,
	linux-samsung-soc, linux-tegra, linux-iio, linux-input,
	linux-media

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_segment. 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>
---
 drivers/i2c/muxes/i2c-mux-pca9541.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/muxes/i2c-mux-pca9541.c b/drivers/i2c/muxes/i2c-mux-pca9541.c
index 6a39adaf433f..74c560ed44cc 100644
--- a/drivers/i2c/muxes/i2c-mux-pca9541.c
+++ b/drivers/i2c/muxes/i2c-mux-pca9541.c
@@ -345,11 +345,11 @@ static int pca9541_probe(struct i2c_client *client,
 
 	/*
 	 * I2C accesses are unprotected here.
-	 * We have to lock the adapter before releasing the bus.
+	 * We have to lock the I2C segment before releasing the bus.
 	 */
-	i2c_lock_adapter(adap);
+	i2c_lock_segment(adap);
 	pca9541_release_bus(client);
-	i2c_unlock_adapter(adap);
+	i2c_unlock_segment(adap);
 
 	/* Create mux adapter */
 
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 03/11] i2c: mux: pca9541: switch to i2c_lock_segment
@ 2018-06-15 10:14   ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:14 UTC (permalink / raw)
  To: linux-arm-kernel

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_segment. 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>
---
 drivers/i2c/muxes/i2c-mux-pca9541.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/muxes/i2c-mux-pca9541.c b/drivers/i2c/muxes/i2c-mux-pca9541.c
index 6a39adaf433f..74c560ed44cc 100644
--- a/drivers/i2c/muxes/i2c-mux-pca9541.c
+++ b/drivers/i2c/muxes/i2c-mux-pca9541.c
@@ -345,11 +345,11 @@ static int pca9541_probe(struct i2c_client *client,
 
 	/*
 	 * I2C accesses are unprotected here.
-	 * We have to lock the adapter before releasing the bus.
+	 * We have to lock the I2C segment before releasing the bus.
 	 */
-	i2c_lock_adapter(adap);
+	i2c_lock_segment(adap);
 	pca9541_release_bus(client);
-	i2c_unlock_adapter(adap);
+	i2c_unlock_segment(adap);
 
 	/* Create mux adapter */
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 04/11] input: rohm_bu21023: switch to i2c_lock_segment
  2018-06-15 10:14 ` Peter Rosin
  (?)
@ 2018-06-15 10:14   ` Peter Rosin
  -1 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:14 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Rosin, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding

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_segment. 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>
---
 drivers/input/touchscreen/rohm_bu21023.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/rohm_bu21023.c b/drivers/input/touchscreen/rohm_bu21023.c
index bda0500c9b57..22d79db07234 100644
--- a/drivers/input/touchscreen/rohm_bu21023.c
+++ b/drivers/input/touchscreen/rohm_bu21023.c
@@ -304,7 +304,7 @@ static int rohm_i2c_burst_read(struct i2c_client *client, u8 start, void *buf,
 	msg[1].len = len;
 	msg[1].buf = buf;
 
-	i2c_lock_adapter(adap);
+	i2c_lock_segment(adap);
 
 	for (i = 0; i < 2; i++) {
 		if (__i2c_transfer(adap, &msg[i], 1) < 0) {
@@ -313,7 +313,7 @@ static int rohm_i2c_burst_read(struct i2c_client *client, u8 start, void *buf,
 		}
 	}
 
-	i2c_unlock_adapter(adap);
+	i2c_unlock_segment(adap);
 
 	return ret;
 }
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 04/11] input: rohm_bu21023: switch to i2c_lock_segment
@ 2018-06-15 10:14   ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:14 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Rosin, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding, Jonathan Hunter, Wolfram Sang,
	Guenter Roeck, Crt Mori, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, Dmitry Torokhov,
	Antti Palosaari, Mauro Carvalho Chehab, Michael Krufky,
	Lee Jones, linux-integrity, linux-i2c, linux-arm-kernel,
	linux-samsung-soc, linux-tegra, linux-iio, linux-input,
	linux-media

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_segment. 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>
---
 drivers/input/touchscreen/rohm_bu21023.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/rohm_bu21023.c b/drivers/input/touchscreen/rohm_bu21023.c
index bda0500c9b57..22d79db07234 100644
--- a/drivers/input/touchscreen/rohm_bu21023.c
+++ b/drivers/input/touchscreen/rohm_bu21023.c
@@ -304,7 +304,7 @@ static int rohm_i2c_burst_read(struct i2c_client *client, u8 start, void *buf,
 	msg[1].len = len;
 	msg[1].buf = buf;
 
-	i2c_lock_adapter(adap);
+	i2c_lock_segment(adap);
 
 	for (i = 0; i < 2; i++) {
 		if (__i2c_transfer(adap, &msg[i], 1) < 0) {
@@ -313,7 +313,7 @@ static int rohm_i2c_burst_read(struct i2c_client *client, u8 start, void *buf,
 		}
 	}
 
-	i2c_unlock_adapter(adap);
+	i2c_unlock_segment(adap);
 
 	return ret;
 }
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 04/11] input: rohm_bu21023: switch to i2c_lock_segment
@ 2018-06-15 10:14   ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:14 UTC (permalink / raw)
  To: linux-arm-kernel

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_segment. 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>
---
 drivers/input/touchscreen/rohm_bu21023.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/rohm_bu21023.c b/drivers/input/touchscreen/rohm_bu21023.c
index bda0500c9b57..22d79db07234 100644
--- a/drivers/input/touchscreen/rohm_bu21023.c
+++ b/drivers/input/touchscreen/rohm_bu21023.c
@@ -304,7 +304,7 @@ static int rohm_i2c_burst_read(struct i2c_client *client, u8 start, void *buf,
 	msg[1].len = len;
 	msg[1].buf = buf;
 
-	i2c_lock_adapter(adap);
+	i2c_lock_segment(adap);
 
 	for (i = 0; i < 2; i++) {
 		if (__i2c_transfer(adap, &msg[i], 1) < 0) {
@@ -313,7 +313,7 @@ static int rohm_i2c_burst_read(struct i2c_client *client, u8 start, void *buf,
 		}
 	}
 
-	i2c_unlock_adapter(adap);
+	i2c_unlock_segment(adap);
 
 	return ret;
 }
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 05/11] media: af9013: switch to i2c_lock_segment
  2018-06-15 10:14 ` Peter Rosin
  (?)
@ 2018-06-15 10:15   ` Peter Rosin
  -1 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Rosin, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding

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_segment. 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>
---
 drivers/media/dvb-frontends/af9013.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/dvb-frontends/af9013.c b/drivers/media/dvb-frontends/af9013.c
index 482bce49819a..a504697ff557 100644
--- a/drivers/media/dvb-frontends/af9013.c
+++ b/drivers/media/dvb-frontends/af9013.c
@@ -1312,10 +1312,10 @@ static int af9013_wregs(struct i2c_client *client, u8 cmd, u16 reg,
 	memcpy(&buf[3], val, len);
 
 	if (lock)
-		i2c_lock_adapter(client->adapter);
+		i2c_lock_segment(client->adapter);
 	ret = __i2c_transfer(client->adapter, msg, 1);
 	if (lock)
-		i2c_unlock_adapter(client->adapter);
+		i2c_unlock_segment(client->adapter);
 	if (ret < 0) {
 		goto err;
 	} else if (ret != 1) {
@@ -1353,10 +1353,10 @@ static int af9013_rregs(struct i2c_client *client, u8 cmd, u16 reg,
 	buf[2] = cmd;
 
 	if (lock)
-		i2c_lock_adapter(client->adapter);
+		i2c_lock_segment(client->adapter);
 	ret = __i2c_transfer(client->adapter, msg, 2);
 	if (lock)
-		i2c_unlock_adapter(client->adapter);
+		i2c_unlock_segment(client->adapter);
 	if (ret < 0) {
 		goto err;
 	} else if (ret != 2) {
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 05/11] media: af9013: switch to i2c_lock_segment
@ 2018-06-15 10:15   ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Rosin, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding, Jonathan Hunter, Wolfram Sang,
	Guenter Roeck, Crt Mori, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, Dmitry Torokhov,
	Antti Palosaari, Mauro Carvalho Chehab, Michael Krufky,
	Lee Jones, linux-integrity, linux-i2c, linux-arm-kernel,
	linux-samsung-soc, linux-tegra, linux-iio, linux-input,
	linux-media

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_segment. 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>
---
 drivers/media/dvb-frontends/af9013.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/dvb-frontends/af9013.c b/drivers/media/dvb-frontends/af9013.c
index 482bce49819a..a504697ff557 100644
--- a/drivers/media/dvb-frontends/af9013.c
+++ b/drivers/media/dvb-frontends/af9013.c
@@ -1312,10 +1312,10 @@ static int af9013_wregs(struct i2c_client *client, u8 cmd, u16 reg,
 	memcpy(&buf[3], val, len);
 
 	if (lock)
-		i2c_lock_adapter(client->adapter);
+		i2c_lock_segment(client->adapter);
 	ret = __i2c_transfer(client->adapter, msg, 1);
 	if (lock)
-		i2c_unlock_adapter(client->adapter);
+		i2c_unlock_segment(client->adapter);
 	if (ret < 0) {
 		goto err;
 	} else if (ret != 1) {
@@ -1353,10 +1353,10 @@ static int af9013_rregs(struct i2c_client *client, u8 cmd, u16 reg,
 	buf[2] = cmd;
 
 	if (lock)
-		i2c_lock_adapter(client->adapter);
+		i2c_lock_segment(client->adapter);
 	ret = __i2c_transfer(client->adapter, msg, 2);
 	if (lock)
-		i2c_unlock_adapter(client->adapter);
+		i2c_unlock_segment(client->adapter);
 	if (ret < 0) {
 		goto err;
 	} else if (ret != 2) {
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 05/11] media: af9013: switch to i2c_lock_segment
@ 2018-06-15 10:15   ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:15 UTC (permalink / raw)
  To: linux-arm-kernel

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_segment. 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>
---
 drivers/media/dvb-frontends/af9013.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/dvb-frontends/af9013.c b/drivers/media/dvb-frontends/af9013.c
index 482bce49819a..a504697ff557 100644
--- a/drivers/media/dvb-frontends/af9013.c
+++ b/drivers/media/dvb-frontends/af9013.c
@@ -1312,10 +1312,10 @@ static int af9013_wregs(struct i2c_client *client, u8 cmd, u16 reg,
 	memcpy(&buf[3], val, len);
 
 	if (lock)
-		i2c_lock_adapter(client->adapter);
+		i2c_lock_segment(client->adapter);
 	ret = __i2c_transfer(client->adapter, msg, 1);
 	if (lock)
-		i2c_unlock_adapter(client->adapter);
+		i2c_unlock_segment(client->adapter);
 	if (ret < 0) {
 		goto err;
 	} else if (ret != 1) {
@@ -1353,10 +1353,10 @@ static int af9013_rregs(struct i2c_client *client, u8 cmd, u16 reg,
 	buf[2] = cmd;
 
 	if (lock)
-		i2c_lock_adapter(client->adapter);
+		i2c_lock_segment(client->adapter);
 	ret = __i2c_transfer(client->adapter, msg, 2);
 	if (lock)
-		i2c_unlock_adapter(client->adapter);
+		i2c_unlock_segment(client->adapter);
 	if (ret < 0) {
 		goto err;
 	} else if (ret != 2) {
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 06/11] media: drxk_hard: switch to i2c_lock_segment
  2018-06-15 10:14 ` Peter Rosin
  (?)
@ 2018-06-15 10:15   ` Peter Rosin
  -1 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Rosin, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding

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_segment. 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>
---
 drivers/media/dvb-frontends/drxk_hard.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/drxk_hard.c b/drivers/media/dvb-frontends/drxk_hard.c
index 5a26ad93be10..10e6bb158712 100644
--- a/drivers/media/dvb-frontends/drxk_hard.c
+++ b/drivers/media/dvb-frontends/drxk_hard.c
@@ -213,7 +213,7 @@ static inline u32 log10times100(u32 value)
 
 static int drxk_i2c_lock(struct drxk_state *state)
 {
-	i2c_lock_adapter(state->i2c);
+	i2c_lock_segment(state->i2c);
 	state->drxk_i2c_exclusive_lock = true;
 
 	return 0;
@@ -224,7 +224,7 @@ static void drxk_i2c_unlock(struct drxk_state *state)
 	if (!state->drxk_i2c_exclusive_lock)
 		return;
 
-	i2c_unlock_adapter(state->i2c);
+	i2c_unlock_segment(state->i2c);
 	state->drxk_i2c_exclusive_lock = false;
 }
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 06/11] media: drxk_hard: switch to i2c_lock_segment
@ 2018-06-15 10:15   ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Rosin, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding, Jonathan Hunter, Wolfram Sang,
	Guenter Roeck, Crt Mori, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, Dmitry Torokhov,
	Antti Palosaari, Mauro Carvalho Chehab, Michael Krufky,
	Lee Jones, linux-integrity, linux-i2c, linux-arm-kernel,
	linux-samsung-soc, linux-tegra, linux-iio, linux-input,
	linux-media

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_segment. 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>
---
 drivers/media/dvb-frontends/drxk_hard.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/drxk_hard.c b/drivers/media/dvb-frontends/drxk_hard.c
index 5a26ad93be10..10e6bb158712 100644
--- a/drivers/media/dvb-frontends/drxk_hard.c
+++ b/drivers/media/dvb-frontends/drxk_hard.c
@@ -213,7 +213,7 @@ static inline u32 log10times100(u32 value)
 
 static int drxk_i2c_lock(struct drxk_state *state)
 {
-	i2c_lock_adapter(state->i2c);
+	i2c_lock_segment(state->i2c);
 	state->drxk_i2c_exclusive_lock = true;
 
 	return 0;
@@ -224,7 +224,7 @@ static void drxk_i2c_unlock(struct drxk_state *state)
 	if (!state->drxk_i2c_exclusive_lock)
 		return;
 
-	i2c_unlock_adapter(state->i2c);
+	i2c_unlock_segment(state->i2c);
 	state->drxk_i2c_exclusive_lock = false;
 }
 
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 06/11] media: drxk_hard: switch to i2c_lock_segment
@ 2018-06-15 10:15   ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:15 UTC (permalink / raw)
  To: linux-arm-kernel

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_segment. 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>
---
 drivers/media/dvb-frontends/drxk_hard.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/drxk_hard.c b/drivers/media/dvb-frontends/drxk_hard.c
index 5a26ad93be10..10e6bb158712 100644
--- a/drivers/media/dvb-frontends/drxk_hard.c
+++ b/drivers/media/dvb-frontends/drxk_hard.c
@@ -213,7 +213,7 @@ static inline u32 log10times100(u32 value)
 
 static int drxk_i2c_lock(struct drxk_state *state)
 {
-	i2c_lock_adapter(state->i2c);
+	i2c_lock_segment(state->i2c);
 	state->drxk_i2c_exclusive_lock = true;
 
 	return 0;
@@ -224,7 +224,7 @@ static void drxk_i2c_unlock(struct drxk_state *state)
 	if (!state->drxk_i2c_exclusive_lock)
 		return;
 
-	i2c_unlock_adapter(state->i2c);
+	i2c_unlock_segment(state->i2c);
 	state->drxk_i2c_exclusive_lock = false;
 }
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 07/11] media: rtl2830: switch to i2c_lock_segment
  2018-06-15 10:14 ` Peter Rosin
  (?)
@ 2018-06-15 10:15   ` Peter Rosin
  -1 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Rosin, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding

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_segment. 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>
---
 drivers/media/dvb-frontends/rtl2830.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/dvb-frontends/rtl2830.c b/drivers/media/dvb-frontends/rtl2830.c
index 7bbfe11d11ed..85a8a9c4d020 100644
--- a/drivers/media/dvb-frontends/rtl2830.c
+++ b/drivers/media/dvb-frontends/rtl2830.c
@@ -24,9 +24,9 @@ static int rtl2830_bulk_write(struct i2c_client *client, unsigned int reg,
 	struct rtl2830_dev *dev = i2c_get_clientdata(client);
 	int ret;
 
-	i2c_lock_adapter(client->adapter);
+	i2c_lock_segment(client->adapter);
 	ret = regmap_bulk_write(dev->regmap, reg, val, val_count);
-	i2c_unlock_adapter(client->adapter);
+	i2c_unlock_segment(client->adapter);
 	return ret;
 }
 
@@ -36,9 +36,9 @@ static int rtl2830_update_bits(struct i2c_client *client, unsigned int reg,
 	struct rtl2830_dev *dev = i2c_get_clientdata(client);
 	int ret;
 
-	i2c_lock_adapter(client->adapter);
+	i2c_lock_segment(client->adapter);
 	ret = regmap_update_bits(dev->regmap, reg, mask, val);
-	i2c_unlock_adapter(client->adapter);
+	i2c_unlock_segment(client->adapter);
 	return ret;
 }
 
@@ -48,9 +48,9 @@ static int rtl2830_bulk_read(struct i2c_client *client, unsigned int reg,
 	struct rtl2830_dev *dev = i2c_get_clientdata(client);
 	int ret;
 
-	i2c_lock_adapter(client->adapter);
+	i2c_lock_segment(client->adapter);
 	ret = regmap_bulk_read(dev->regmap, reg, val, val_count);
-	i2c_unlock_adapter(client->adapter);
+	i2c_unlock_segment(client->adapter);
 	return ret;
 }
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 07/11] media: rtl2830: switch to i2c_lock_segment
@ 2018-06-15 10:15   ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Rosin, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding, Jonathan Hunter, Wolfram Sang,
	Guenter Roeck, Crt Mori, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, Dmitry Torokhov,
	Antti Palosaari, Mauro Carvalho Chehab, Michael Krufky,
	Lee Jones, linux-integrity, linux-i2c, linux-arm-kernel,
	linux-samsung-soc, linux-tegra, linux-iio, linux-input,
	linux-media

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_segment. 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>
---
 drivers/media/dvb-frontends/rtl2830.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/dvb-frontends/rtl2830.c b/drivers/media/dvb-frontends/rtl2830.c
index 7bbfe11d11ed..85a8a9c4d020 100644
--- a/drivers/media/dvb-frontends/rtl2830.c
+++ b/drivers/media/dvb-frontends/rtl2830.c
@@ -24,9 +24,9 @@ static int rtl2830_bulk_write(struct i2c_client *client, unsigned int reg,
 	struct rtl2830_dev *dev = i2c_get_clientdata(client);
 	int ret;
 
-	i2c_lock_adapter(client->adapter);
+	i2c_lock_segment(client->adapter);
 	ret = regmap_bulk_write(dev->regmap, reg, val, val_count);
-	i2c_unlock_adapter(client->adapter);
+	i2c_unlock_segment(client->adapter);
 	return ret;
 }
 
@@ -36,9 +36,9 @@ static int rtl2830_update_bits(struct i2c_client *client, unsigned int reg,
 	struct rtl2830_dev *dev = i2c_get_clientdata(client);
 	int ret;
 
-	i2c_lock_adapter(client->adapter);
+	i2c_lock_segment(client->adapter);
 	ret = regmap_update_bits(dev->regmap, reg, mask, val);
-	i2c_unlock_adapter(client->adapter);
+	i2c_unlock_segment(client->adapter);
 	return ret;
 }
 
@@ -48,9 +48,9 @@ static int rtl2830_bulk_read(struct i2c_client *client, unsigned int reg,
 	struct rtl2830_dev *dev = i2c_get_clientdata(client);
 	int ret;
 
-	i2c_lock_adapter(client->adapter);
+	i2c_lock_segment(client->adapter);
 	ret = regmap_bulk_read(dev->regmap, reg, val, val_count);
-	i2c_unlock_adapter(client->adapter);
+	i2c_unlock_segment(client->adapter);
 	return ret;
 }
 
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 07/11] media: rtl2830: switch to i2c_lock_segment
@ 2018-06-15 10:15   ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:15 UTC (permalink / raw)
  To: linux-arm-kernel

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_segment. 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>
---
 drivers/media/dvb-frontends/rtl2830.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/dvb-frontends/rtl2830.c b/drivers/media/dvb-frontends/rtl2830.c
index 7bbfe11d11ed..85a8a9c4d020 100644
--- a/drivers/media/dvb-frontends/rtl2830.c
+++ b/drivers/media/dvb-frontends/rtl2830.c
@@ -24,9 +24,9 @@ static int rtl2830_bulk_write(struct i2c_client *client, unsigned int reg,
 	struct rtl2830_dev *dev = i2c_get_clientdata(client);
 	int ret;
 
-	i2c_lock_adapter(client->adapter);
+	i2c_lock_segment(client->adapter);
 	ret = regmap_bulk_write(dev->regmap, reg, val, val_count);
-	i2c_unlock_adapter(client->adapter);
+	i2c_unlock_segment(client->adapter);
 	return ret;
 }
 
@@ -36,9 +36,9 @@ static int rtl2830_update_bits(struct i2c_client *client, unsigned int reg,
 	struct rtl2830_dev *dev = i2c_get_clientdata(client);
 	int ret;
 
-	i2c_lock_adapter(client->adapter);
+	i2c_lock_segment(client->adapter);
 	ret = regmap_update_bits(dev->regmap, reg, mask, val);
-	i2c_unlock_adapter(client->adapter);
+	i2c_unlock_segment(client->adapter);
 	return ret;
 }
 
@@ -48,9 +48,9 @@ static int rtl2830_bulk_read(struct i2c_client *client, unsigned int reg,
 	struct rtl2830_dev *dev = i2c_get_clientdata(client);
 	int ret;
 
-	i2c_lock_adapter(client->adapter);
+	i2c_lock_segment(client->adapter);
 	ret = regmap_bulk_read(dev->regmap, reg, val, val_count);
-	i2c_unlock_adapter(client->adapter);
+	i2c_unlock_segment(client->adapter);
 	return ret;
 }
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 08/11] media: tda1004x: switch to i2c_lock_segment
  2018-06-15 10:14 ` Peter Rosin
  (?)
@ 2018-06-15 10:15   ` Peter Rosin
  -1 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Rosin, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding

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_segment. 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>
---
 drivers/media/dvb-frontends/tda1004x.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/dvb-frontends/tda1004x.c b/drivers/media/dvb-frontends/tda1004x.c
index 58e3beff5adc..1e5c183cdd86 100644
--- a/drivers/media/dvb-frontends/tda1004x.c
+++ b/drivers/media/dvb-frontends/tda1004x.c
@@ -329,7 +329,7 @@ static int tda1004x_do_upload(struct tda1004x_state *state,
 	tda1004x_write_byteI(state, dspCodeCounterReg, 0);
 	fw_msg.addr = state->config->demod_address;
 
-	i2c_lock_adapter(state->i2c);
+	i2c_lock_segment(state->i2c);
 	buf[0] = dspCodeInReg;
 	while (pos != len) {
 		// work out how much to send this time
@@ -342,14 +342,14 @@ static int tda1004x_do_upload(struct tda1004x_state *state,
 		fw_msg.len = tx_size + 1;
 		if (__i2c_transfer(state->i2c, &fw_msg, 1) != 1) {
 			printk(KERN_ERR "tda1004x: Error during firmware upload\n");
-			i2c_unlock_adapter(state->i2c);
+			i2c_unlock_segment(state->i2c);
 			return -EIO;
 		}
 		pos += tx_size;
 
 		dprintk("%s: fw_pos=0x%x\n", __func__, pos);
 	}
-	i2c_unlock_adapter(state->i2c);
+	i2c_unlock_segment(state->i2c);
 
 	/* give the DSP a chance to settle 03/10/05 Hac */
 	msleep(100);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 08/11] media: tda1004x: switch to i2c_lock_segment
@ 2018-06-15 10:15   ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Rosin, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding, Jonathan Hunter, Wolfram Sang,
	Guenter Roeck, Crt Mori, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, Dmitry Torokhov,
	Antti Palosaari, Mauro Carvalho Chehab, Michael Krufky,
	Lee Jones, linux-integrity, linux-i2c, linux-arm-kernel,
	linux-samsung-soc, linux-tegra, linux-iio, linux-input,
	linux-media

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_segment. 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>
---
 drivers/media/dvb-frontends/tda1004x.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/dvb-frontends/tda1004x.c b/drivers/media/dvb-frontends/tda1004x.c
index 58e3beff5adc..1e5c183cdd86 100644
--- a/drivers/media/dvb-frontends/tda1004x.c
+++ b/drivers/media/dvb-frontends/tda1004x.c
@@ -329,7 +329,7 @@ static int tda1004x_do_upload(struct tda1004x_state *state,
 	tda1004x_write_byteI(state, dspCodeCounterReg, 0);
 	fw_msg.addr = state->config->demod_address;
 
-	i2c_lock_adapter(state->i2c);
+	i2c_lock_segment(state->i2c);
 	buf[0] = dspCodeInReg;
 	while (pos != len) {
 		// work out how much to send this time
@@ -342,14 +342,14 @@ static int tda1004x_do_upload(struct tda1004x_state *state,
 		fw_msg.len = tx_size + 1;
 		if (__i2c_transfer(state->i2c, &fw_msg, 1) != 1) {
 			printk(KERN_ERR "tda1004x: Error during firmware upload\n");
-			i2c_unlock_adapter(state->i2c);
+			i2c_unlock_segment(state->i2c);
 			return -EIO;
 		}
 		pos += tx_size;
 
 		dprintk("%s: fw_pos=0x%x\n", __func__, pos);
 	}
-	i2c_unlock_adapter(state->i2c);
+	i2c_unlock_segment(state->i2c);
 
 	/* give the DSP a chance to settle 03/10/05 Hac */
 	msleep(100);
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 08/11] media: tda1004x: switch to i2c_lock_segment
@ 2018-06-15 10:15   ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:15 UTC (permalink / raw)
  To: linux-arm-kernel

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_segment. 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>
---
 drivers/media/dvb-frontends/tda1004x.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/dvb-frontends/tda1004x.c b/drivers/media/dvb-frontends/tda1004x.c
index 58e3beff5adc..1e5c183cdd86 100644
--- a/drivers/media/dvb-frontends/tda1004x.c
+++ b/drivers/media/dvb-frontends/tda1004x.c
@@ -329,7 +329,7 @@ static int tda1004x_do_upload(struct tda1004x_state *state,
 	tda1004x_write_byteI(state, dspCodeCounterReg, 0);
 	fw_msg.addr = state->config->demod_address;
 
-	i2c_lock_adapter(state->i2c);
+	i2c_lock_segment(state->i2c);
 	buf[0] = dspCodeInReg;
 	while (pos != len) {
 		// work out how much to send this time
@@ -342,14 +342,14 @@ static int tda1004x_do_upload(struct tda1004x_state *state,
 		fw_msg.len = tx_size + 1;
 		if (__i2c_transfer(state->i2c, &fw_msg, 1) != 1) {
 			printk(KERN_ERR "tda1004x: Error during firmware upload\n");
-			i2c_unlock_adapter(state->i2c);
+			i2c_unlock_segment(state->i2c);
 			return -EIO;
 		}
 		pos += tx_size;
 
 		dprintk("%s: fw_pos=0x%x\n", __func__, pos);
 	}
-	i2c_unlock_adapter(state->i2c);
+	i2c_unlock_segment(state->i2c);
 
 	/* give the DSP a chance to settle 03/10/05 Hac */
 	msleep(100);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 09/11] media: tda18271: switch to i2c_lock_segment
  2018-06-15 10:14 ` Peter Rosin
  (?)
@ 2018-06-15 10:15   ` Peter Rosin
  -1 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Rosin, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding

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_segment. 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>
---
 drivers/media/tuners/tda18271-common.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/tuners/tda18271-common.c b/drivers/media/tuners/tda18271-common.c
index 7e81cd887c13..93cce2bcd601 100644
--- a/drivers/media/tuners/tda18271-common.c
+++ b/drivers/media/tuners/tda18271-common.c
@@ -225,7 +225,7 @@ static int __tda18271_write_regs(struct dvb_frontend *fe, int idx, int len,
 	 */
 	if (lock_i2c) {
 		tda18271_i2c_gate_ctrl(fe, 1);
-		i2c_lock_adapter(priv->i2c_props.adap);
+		i2c_lock_segment(priv->i2c_props.adap);
 	}
 	while (len) {
 		if (max > len)
@@ -246,7 +246,7 @@ static int __tda18271_write_regs(struct dvb_frontend *fe, int idx, int len,
 		len -= max;
 	}
 	if (lock_i2c) {
-		i2c_unlock_adapter(priv->i2c_props.adap);
+		i2c_unlock_segment(priv->i2c_props.adap);
 		tda18271_i2c_gate_ctrl(fe, 0);
 	}
 
@@ -300,7 +300,7 @@ int tda18271_init_regs(struct dvb_frontend *fe)
 	 * as those could cause bad things
 	 */
 	tda18271_i2c_gate_ctrl(fe, 1);
-	i2c_lock_adapter(priv->i2c_props.adap);
+	i2c_lock_segment(priv->i2c_props.adap);
 
 	/* initialize registers */
 	switch (priv->id) {
@@ -516,7 +516,7 @@ int tda18271_init_regs(struct dvb_frontend *fe)
 	/* synchronize */
 	__tda18271_write_regs(fe, R_EP1, 1, false);
 
-	i2c_unlock_adapter(priv->i2c_props.adap);
+	i2c_unlock_segment(priv->i2c_props.adap);
 	tda18271_i2c_gate_ctrl(fe, 0);
 
 	return 0;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 09/11] media: tda18271: switch to i2c_lock_segment
@ 2018-06-15 10:15   ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Rosin, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding, Jonathan Hunter, Wolfram Sang,
	Guenter Roeck, Crt Mori, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, Dmitry Torokhov,
	Antti Palosaari, Mauro Carvalho Chehab, Michael Krufky,
	Lee Jones, linux-integrity, linux-i2c, linux-arm-kernel,
	linux-samsung-soc, linux-tegra, linux-iio, linux-input,
	linux-media

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_segment. 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>
---
 drivers/media/tuners/tda18271-common.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/tuners/tda18271-common.c b/drivers/media/tuners/tda18271-common.c
index 7e81cd887c13..93cce2bcd601 100644
--- a/drivers/media/tuners/tda18271-common.c
+++ b/drivers/media/tuners/tda18271-common.c
@@ -225,7 +225,7 @@ static int __tda18271_write_regs(struct dvb_frontend *fe, int idx, int len,
 	 */
 	if (lock_i2c) {
 		tda18271_i2c_gate_ctrl(fe, 1);
-		i2c_lock_adapter(priv->i2c_props.adap);
+		i2c_lock_segment(priv->i2c_props.adap);
 	}
 	while (len) {
 		if (max > len)
@@ -246,7 +246,7 @@ static int __tda18271_write_regs(struct dvb_frontend *fe, int idx, int len,
 		len -= max;
 	}
 	if (lock_i2c) {
-		i2c_unlock_adapter(priv->i2c_props.adap);
+		i2c_unlock_segment(priv->i2c_props.adap);
 		tda18271_i2c_gate_ctrl(fe, 0);
 	}
 
@@ -300,7 +300,7 @@ int tda18271_init_regs(struct dvb_frontend *fe)
 	 * as those could cause bad things
 	 */
 	tda18271_i2c_gate_ctrl(fe, 1);
-	i2c_lock_adapter(priv->i2c_props.adap);
+	i2c_lock_segment(priv->i2c_props.adap);
 
 	/* initialize registers */
 	switch (priv->id) {
@@ -516,7 +516,7 @@ int tda18271_init_regs(struct dvb_frontend *fe)
 	/* synchronize */
 	__tda18271_write_regs(fe, R_EP1, 1, false);
 
-	i2c_unlock_adapter(priv->i2c_props.adap);
+	i2c_unlock_segment(priv->i2c_props.adap);
 	tda18271_i2c_gate_ctrl(fe, 0);
 
 	return 0;
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 09/11] media: tda18271: switch to i2c_lock_segment
@ 2018-06-15 10:15   ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:15 UTC (permalink / raw)
  To: linux-arm-kernel

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_segment. 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>
---
 drivers/media/tuners/tda18271-common.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/tuners/tda18271-common.c b/drivers/media/tuners/tda18271-common.c
index 7e81cd887c13..93cce2bcd601 100644
--- a/drivers/media/tuners/tda18271-common.c
+++ b/drivers/media/tuners/tda18271-common.c
@@ -225,7 +225,7 @@ static int __tda18271_write_regs(struct dvb_frontend *fe, int idx, int len,
 	 */
 	if (lock_i2c) {
 		tda18271_i2c_gate_ctrl(fe, 1);
-		i2c_lock_adapter(priv->i2c_props.adap);
+		i2c_lock_segment(priv->i2c_props.adap);
 	}
 	while (len) {
 		if (max > len)
@@ -246,7 +246,7 @@ static int __tda18271_write_regs(struct dvb_frontend *fe, int idx, int len,
 		len -= max;
 	}
 	if (lock_i2c) {
-		i2c_unlock_adapter(priv->i2c_props.adap);
+		i2c_unlock_segment(priv->i2c_props.adap);
 		tda18271_i2c_gate_ctrl(fe, 0);
 	}
 
@@ -300,7 +300,7 @@ int tda18271_init_regs(struct dvb_frontend *fe)
 	 * as those could cause bad things
 	 */
 	tda18271_i2c_gate_ctrl(fe, 1);
-	i2c_lock_adapter(priv->i2c_props.adap);
+	i2c_lock_segment(priv->i2c_props.adap);
 
 	/* initialize registers */
 	switch (priv->id) {
@@ -516,7 +516,7 @@ int tda18271_init_regs(struct dvb_frontend *fe)
 	/* synchronize */
 	__tda18271_write_regs(fe, R_EP1, 1, false);
 
-	i2c_unlock_adapter(priv->i2c_props.adap);
+	i2c_unlock_segment(priv->i2c_props.adap);
 	tda18271_i2c_gate_ctrl(fe, 0);
 
 	return 0;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 10/11] mfd: 88pm860x-i2c: switch to i2c_lock_segment
  2018-06-15 10:14 ` Peter Rosin
  (?)
@ 2018-06-15 10:15   ` Peter Rosin
  -1 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Rosin, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding

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_segment. 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>
---
 drivers/mfd/88pm860x-i2c.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mfd/88pm860x-i2c.c b/drivers/mfd/88pm860x-i2c.c
index 84e313107233..8e54fc2dc29c 100644
--- a/drivers/mfd/88pm860x-i2c.c
+++ b/drivers/mfd/88pm860x-i2c.c
@@ -146,14 +146,14 @@ int pm860x_page_reg_write(struct i2c_client *i2c, int reg,
 	unsigned char zero;
 	int ret;
 
-	i2c_lock_adapter(i2c->adapter);
+	i2c_lock_segment(i2c->adapter);
 	read_device(i2c, 0xFA, 0, &zero);
 	read_device(i2c, 0xFB, 0, &zero);
 	read_device(i2c, 0xFF, 0, &zero);
 	ret = write_device(i2c, reg, 1, &data);
 	read_device(i2c, 0xFE, 0, &zero);
 	read_device(i2c, 0xFC, 0, &zero);
-	i2c_unlock_adapter(i2c->adapter);
+	i2c_unlock_segment(i2c->adapter);
 	return ret;
 }
 EXPORT_SYMBOL(pm860x_page_reg_write);
@@ -164,14 +164,14 @@ int pm860x_page_bulk_read(struct i2c_client *i2c, int reg,
 	unsigned char zero = 0;
 	int ret;
 
-	i2c_lock_adapter(i2c->adapter);
+	i2c_lock_segment(i2c->adapter);
 	read_device(i2c, 0xfa, 0, &zero);
 	read_device(i2c, 0xfb, 0, &zero);
 	read_device(i2c, 0xff, 0, &zero);
 	ret = read_device(i2c, reg, count, buf);
 	read_device(i2c, 0xFE, 0, &zero);
 	read_device(i2c, 0xFC, 0, &zero);
-	i2c_unlock_adapter(i2c->adapter);
+	i2c_unlock_segment(i2c->adapter);
 	return ret;
 }
 EXPORT_SYMBOL(pm860x_page_bulk_read);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 10/11] mfd: 88pm860x-i2c: switch to i2c_lock_segment
@ 2018-06-15 10:15   ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Rosin, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding, Jonathan Hunter, Wolfram Sang,
	Guenter Roeck, Crt Mori, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, Dmitry Torokhov,
	Antti Palosaari, Mauro Carvalho Chehab, Michael Krufky,
	Lee Jones, linux-integrity, linux-i2c, linux-arm-kernel,
	linux-samsung-soc, linux-tegra, linux-iio, linux-input,
	linux-media

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_segment. 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>
---
 drivers/mfd/88pm860x-i2c.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mfd/88pm860x-i2c.c b/drivers/mfd/88pm860x-i2c.c
index 84e313107233..8e54fc2dc29c 100644
--- a/drivers/mfd/88pm860x-i2c.c
+++ b/drivers/mfd/88pm860x-i2c.c
@@ -146,14 +146,14 @@ int pm860x_page_reg_write(struct i2c_client *i2c, int reg,
 	unsigned char zero;
 	int ret;
 
-	i2c_lock_adapter(i2c->adapter);
+	i2c_lock_segment(i2c->adapter);
 	read_device(i2c, 0xFA, 0, &zero);
 	read_device(i2c, 0xFB, 0, &zero);
 	read_device(i2c, 0xFF, 0, &zero);
 	ret = write_device(i2c, reg, 1, &data);
 	read_device(i2c, 0xFE, 0, &zero);
 	read_device(i2c, 0xFC, 0, &zero);
-	i2c_unlock_adapter(i2c->adapter);
+	i2c_unlock_segment(i2c->adapter);
 	return ret;
 }
 EXPORT_SYMBOL(pm860x_page_reg_write);
@@ -164,14 +164,14 @@ int pm860x_page_bulk_read(struct i2c_client *i2c, int reg,
 	unsigned char zero = 0;
 	int ret;
 
-	i2c_lock_adapter(i2c->adapter);
+	i2c_lock_segment(i2c->adapter);
 	read_device(i2c, 0xfa, 0, &zero);
 	read_device(i2c, 0xfb, 0, &zero);
 	read_device(i2c, 0xff, 0, &zero);
 	ret = read_device(i2c, reg, count, buf);
 	read_device(i2c, 0xFE, 0, &zero);
 	read_device(i2c, 0xFC, 0, &zero);
-	i2c_unlock_adapter(i2c->adapter);
+	i2c_unlock_segment(i2c->adapter);
 	return ret;
 }
 EXPORT_SYMBOL(pm860x_page_bulk_read);
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 10/11] mfd: 88pm860x-i2c: switch to i2c_lock_segment
@ 2018-06-15 10:15   ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:15 UTC (permalink / raw)
  To: linux-arm-kernel

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_segment. 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>
---
 drivers/mfd/88pm860x-i2c.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mfd/88pm860x-i2c.c b/drivers/mfd/88pm860x-i2c.c
index 84e313107233..8e54fc2dc29c 100644
--- a/drivers/mfd/88pm860x-i2c.c
+++ b/drivers/mfd/88pm860x-i2c.c
@@ -146,14 +146,14 @@ int pm860x_page_reg_write(struct i2c_client *i2c, int reg,
 	unsigned char zero;
 	int ret;
 
-	i2c_lock_adapter(i2c->adapter);
+	i2c_lock_segment(i2c->adapter);
 	read_device(i2c, 0xFA, 0, &zero);
 	read_device(i2c, 0xFB, 0, &zero);
 	read_device(i2c, 0xFF, 0, &zero);
 	ret = write_device(i2c, reg, 1, &data);
 	read_device(i2c, 0xFE, 0, &zero);
 	read_device(i2c, 0xFC, 0, &zero);
-	i2c_unlock_adapter(i2c->adapter);
+	i2c_unlock_segment(i2c->adapter);
 	return ret;
 }
 EXPORT_SYMBOL(pm860x_page_reg_write);
@@ -164,14 +164,14 @@ int pm860x_page_bulk_read(struct i2c_client *i2c, int reg,
 	unsigned char zero = 0;
 	int ret;
 
-	i2c_lock_adapter(i2c->adapter);
+	i2c_lock_segment(i2c->adapter);
 	read_device(i2c, 0xfa, 0, &zero);
 	read_device(i2c, 0xfb, 0, &zero);
 	read_device(i2c, 0xff, 0, &zero);
 	ret = read_device(i2c, reg, count, buf);
 	read_device(i2c, 0xFE, 0, &zero);
 	read_device(i2c, 0xFC, 0, &zero);
-	i2c_unlock_adapter(i2c->adapter);
+	i2c_unlock_segment(i2c->adapter);
 	return ret;
 }
 EXPORT_SYMBOL(pm860x_page_bulk_read);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 11/11] i2c: rename i2c_lock_adapter to i2c_lock_root
  2018-06-15 10:14 ` Peter Rosin
  (?)
@ 2018-06-15 10:15   ` Peter Rosin
  -1 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Rosin, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding

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. Rename the function to indicate
what is really going on. Also rename i2c_unlock_adapter, of course.

This patch was generated with

  grep -rlI --exclude-dir=.git 'i2c_\(un\)\?lock_adapter' \
    | xargs sed -i 's/i2c_\(un\)\?lock_adapter/i2c_\1lock_root/g'

followed by some minor white-space touch-up.

Signed-off-by: Peter Rosin <peda@axentia.se>
---
 drivers/i2c/busses/i2c-brcmstb.c   |  8 ++++----
 drivers/i2c/busses/i2c-davinci.c   |  4 ++--
 drivers/i2c/busses/i2c-gpio.c      | 12 ++++++------
 drivers/i2c/busses/i2c-s3c2410.c   |  4 ++--
 drivers/i2c/busses/i2c-sprd.c      |  8 ++++----
 drivers/i2c/busses/i2c-tegra.c     |  8 ++++----
 drivers/i2c/i2c-core-slave.c       |  8 ++++----
 drivers/iio/temperature/mlx90614.c |  4 ++--
 include/linux/i2c.h                |  4 ++--
 9 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/drivers/i2c/busses/i2c-brcmstb.c b/drivers/i2c/busses/i2c-brcmstb.c
index 78792b4d6437..c42e14d4a127 100644
--- a/drivers/i2c/busses/i2c-brcmstb.c
+++ b/drivers/i2c/busses/i2c-brcmstb.c
@@ -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_root(&i2c_dev->adapter);
 	i2c_dev->is_suspended = true;
-	i2c_unlock_adapter(&i2c_dev->adapter);
+	i2c_unlock_root(&i2c_dev->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_root(&i2c_dev->adapter);
 	brcmstb_i2c_set_bsc_reg_defaults(i2c_dev);
 	i2c_dev->is_suspended = false;
-	i2c_unlock_adapter(&i2c_dev->adapter);
+	i2c_unlock_root(&i2c_dev->adapter);
 
 	return 0;
 }
diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index 75d6ab177055..9139d8da29ae 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -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_root(&dev->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_root(&dev->adapter);
 
 	return 0;
 }
diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
index 58abb3eced58..6983968735ca 100644
--- a/drivers/i2c/busses/i2c-gpio.c
+++ b/drivers/i2c/busses/i2c-gpio.c
@@ -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_root(&priv->adap);			\
 	*val = get##wire(&priv->bit_data);		\
-	i2c_unlock_adapter(&priv->adap);		\
+	i2c_unlock_root(&priv->adap);			\
 	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_root(&priv->adap);			\
 	set##wire(&priv->bit_data, val);		\
-	i2c_unlock_adapter(&priv->adap);		\
+	i2c_unlock_root(&priv->adap);			\
 	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_root(&priv->adap);
 
 	/* 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_root(&priv->adap);
 
 	return 0;
 }
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 5d97510ee48b..6e8f8d2e847c 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -921,9 +921,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_root(&i2c->adap);
 		ret = s3c24xx_i2c_clockrate(i2c, &got);
-		i2c_unlock_adapter(&i2c->adap);
+		i2c_unlock_root(&i2c->adap);
 
 		if (ret < 0)
 			dev_err(i2c->dev, "cannot find frequency (%d)\n", ret);
diff --git a/drivers/i2c/busses/i2c-sprd.c b/drivers/i2c/busses/i2c-sprd.c
index 4053259bccb8..58a4a263984f 100644
--- a/drivers/i2c/busses/i2c-sprd.c
+++ b/drivers/i2c/busses/i2c-sprd.c
@@ -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_root(&i2c_dev->adap);
 	i2c_dev->is_suspended = true;
-	i2c_unlock_adapter(&i2c_dev->adap);
+	i2c_unlock_root(&i2c_dev->adap);
 
 	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_root(&i2c_dev->adap);
 	i2c_dev->is_suspended = false;
-	i2c_unlock_adapter(&i2c_dev->adap);
+	i2c_unlock_root(&i2c_dev->adap);
 
 	return pm_runtime_force_resume(pdev);
 }
diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index 60292d243e24..1f2ed0dfbbaf 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -1055,9 +1055,9 @@ static int tegra_i2c_suspend(struct device *dev)
 {
 	struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
 
-	i2c_lock_adapter(&i2c_dev->adapter);
+	i2c_lock_root(&i2c_dev->adapter);
 	i2c_dev->is_suspended = true;
-	i2c_unlock_adapter(&i2c_dev->adapter);
+	i2c_unlock_root(&i2c_dev->adapter);
 
 	return 0;
 }
@@ -1067,13 +1067,13 @@ static int tegra_i2c_resume(struct device *dev)
 	struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
 	int ret;
 
-	i2c_lock_adapter(&i2c_dev->adapter);
+	i2c_lock_root(&i2c_dev->adapter);
 
 	ret = tegra_i2c_init(i2c_dev);
 	if (!ret)
 		i2c_dev->is_suspended = false;
 
-	i2c_unlock_adapter(&i2c_dev->adapter);
+	i2c_unlock_root(&i2c_dev->adapter);
 
 	return ret;
 }
diff --git a/drivers/i2c/i2c-core-slave.c b/drivers/i2c/i2c-core-slave.c
index 4a78c65e9971..fd68678f31c2 100644
--- a/drivers/i2c/i2c-core-slave.c
+++ b/drivers/i2c/i2c-core-slave.c
@@ -47,9 +47,9 @@ int i2c_slave_register(struct i2c_client *client, i2c_slave_cb_t slave_cb)
 
 	client->slave_cb = slave_cb;
 
-	i2c_lock_adapter(client->adapter);
+	i2c_lock_root(client->adapter);
 	ret = client->adapter->algo->reg_slave(client);
-	i2c_unlock_adapter(client->adapter);
+	i2c_unlock_root(client->adapter);
 
 	if (ret) {
 		client->slave_cb = NULL;
@@ -69,9 +69,9 @@ int i2c_slave_unregister(struct i2c_client *client)
 		return -EOPNOTSUPP;
 	}
 
-	i2c_lock_adapter(client->adapter);
+	i2c_lock_root(client->adapter);
 	ret = client->adapter->algo->unreg_slave(client);
-	i2c_unlock_adapter(client->adapter);
+	i2c_unlock_root(client->adapter);
 
 	if (ret == 0)
 		client->slave_cb = NULL;
diff --git a/drivers/iio/temperature/mlx90614.c b/drivers/iio/temperature/mlx90614.c
index d619e8634a00..15e7b2c3e7d7 100644
--- a/drivers/iio/temperature/mlx90614.c
+++ b/drivers/iio/temperature/mlx90614.c
@@ -433,11 +433,11 @@ static int mlx90614_wakeup(struct mlx90614_data *data)
 
 	dev_dbg(&data->client->dev, "Requesting wake-up");
 
-	i2c_lock_adapter(data->client->adapter);
+	i2c_lock_root(data->client->adapter);
 	gpiod_direction_output(data->wakeup_gpio, 0);
 	msleep(MLX90614_TIMING_WAKEUP);
 	gpiod_direction_input(data->wakeup_gpio);
-	i2c_unlock_adapter(data->client->adapter);
+	i2c_unlock_root(data->client->adapter);
 
 	data->ready_timestamp = jiffies +
 			msecs_to_jiffies(MLX90614_TIMING_STARTUP);
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index c9080d49e988..40db4b0accb8 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -757,13 +757,13 @@ i2c_unlock_bus(struct i2c_adapter *adapter, unsigned int flags)
 }
 
 static inline void
-i2c_lock_adapter(struct i2c_adapter *adapter)
+i2c_lock_root(struct i2c_adapter *adapter)
 {
 	i2c_lock_bus(adapter, I2C_LOCK_ROOT_ADAPTER);
 }
 
 static inline void
-i2c_unlock_adapter(struct i2c_adapter *adapter)
+i2c_unlock_root(struct i2c_adapter *adapter)
 {
 	i2c_unlock_bus(adapter, I2C_LOCK_ROOT_ADAPTER);
 }
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 11/11] i2c: rename i2c_lock_adapter to i2c_lock_root
@ 2018-06-15 10:15   ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Rosin, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding, Jonathan Hunter, Wolfram Sang,
	Guenter Roeck, Crt Mori, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, Dmitry Torokhov,
	Antti Palosaari, Mauro Carvalho Chehab, Michael Krufky,
	Lee Jones, linux-integrity, linux-i2c, linux-arm-kernel,
	linux-samsung-soc, linux-tegra, linux-iio, linux-input,
	linux-media

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. Rename the function to indicate
what is really going on. Also rename i2c_unlock_adapter, of course.

This patch was generated with

  grep -rlI --exclude-dir=.git 'i2c_\(un\)\?lock_adapter' \
    | xargs sed -i 's/i2c_\(un\)\?lock_adapter/i2c_\1lock_root/g'

followed by some minor white-space touch-up.

Signed-off-by: Peter Rosin <peda@axentia.se>
---
 drivers/i2c/busses/i2c-brcmstb.c   |  8 ++++----
 drivers/i2c/busses/i2c-davinci.c   |  4 ++--
 drivers/i2c/busses/i2c-gpio.c      | 12 ++++++------
 drivers/i2c/busses/i2c-s3c2410.c   |  4 ++--
 drivers/i2c/busses/i2c-sprd.c      |  8 ++++----
 drivers/i2c/busses/i2c-tegra.c     |  8 ++++----
 drivers/i2c/i2c-core-slave.c       |  8 ++++----
 drivers/iio/temperature/mlx90614.c |  4 ++--
 include/linux/i2c.h                |  4 ++--
 9 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/drivers/i2c/busses/i2c-brcmstb.c b/drivers/i2c/busses/i2c-brcmstb.c
index 78792b4d6437..c42e14d4a127 100644
--- a/drivers/i2c/busses/i2c-brcmstb.c
+++ b/drivers/i2c/busses/i2c-brcmstb.c
@@ -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_root(&i2c_dev->adapter);
 	i2c_dev->is_suspended = true;
-	i2c_unlock_adapter(&i2c_dev->adapter);
+	i2c_unlock_root(&i2c_dev->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_root(&i2c_dev->adapter);
 	brcmstb_i2c_set_bsc_reg_defaults(i2c_dev);
 	i2c_dev->is_suspended = false;
-	i2c_unlock_adapter(&i2c_dev->adapter);
+	i2c_unlock_root(&i2c_dev->adapter);
 
 	return 0;
 }
diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index 75d6ab177055..9139d8da29ae 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -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_root(&dev->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_root(&dev->adapter);
 
 	return 0;
 }
diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
index 58abb3eced58..6983968735ca 100644
--- a/drivers/i2c/busses/i2c-gpio.c
+++ b/drivers/i2c/busses/i2c-gpio.c
@@ -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_root(&priv->adap);			\
 	*val = get##wire(&priv->bit_data);		\
-	i2c_unlock_adapter(&priv->adap);		\
+	i2c_unlock_root(&priv->adap);			\
 	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_root(&priv->adap);			\
 	set##wire(&priv->bit_data, val);		\
-	i2c_unlock_adapter(&priv->adap);		\
+	i2c_unlock_root(&priv->adap);			\
 	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_root(&priv->adap);
 
 	/* 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_root(&priv->adap);
 
 	return 0;
 }
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 5d97510ee48b..6e8f8d2e847c 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -921,9 +921,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_root(&i2c->adap);
 		ret = s3c24xx_i2c_clockrate(i2c, &got);
-		i2c_unlock_adapter(&i2c->adap);
+		i2c_unlock_root(&i2c->adap);
 
 		if (ret < 0)
 			dev_err(i2c->dev, "cannot find frequency (%d)\n", ret);
diff --git a/drivers/i2c/busses/i2c-sprd.c b/drivers/i2c/busses/i2c-sprd.c
index 4053259bccb8..58a4a263984f 100644
--- a/drivers/i2c/busses/i2c-sprd.c
+++ b/drivers/i2c/busses/i2c-sprd.c
@@ -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_root(&i2c_dev->adap);
 	i2c_dev->is_suspended = true;
-	i2c_unlock_adapter(&i2c_dev->adap);
+	i2c_unlock_root(&i2c_dev->adap);
 
 	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_root(&i2c_dev->adap);
 	i2c_dev->is_suspended = false;
-	i2c_unlock_adapter(&i2c_dev->adap);
+	i2c_unlock_root(&i2c_dev->adap);
 
 	return pm_runtime_force_resume(pdev);
 }
diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index 60292d243e24..1f2ed0dfbbaf 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -1055,9 +1055,9 @@ static int tegra_i2c_suspend(struct device *dev)
 {
 	struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
 
-	i2c_lock_adapter(&i2c_dev->adapter);
+	i2c_lock_root(&i2c_dev->adapter);
 	i2c_dev->is_suspended = true;
-	i2c_unlock_adapter(&i2c_dev->adapter);
+	i2c_unlock_root(&i2c_dev->adapter);
 
 	return 0;
 }
@@ -1067,13 +1067,13 @@ static int tegra_i2c_resume(struct device *dev)
 	struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
 	int ret;
 
-	i2c_lock_adapter(&i2c_dev->adapter);
+	i2c_lock_root(&i2c_dev->adapter);
 
 	ret = tegra_i2c_init(i2c_dev);
 	if (!ret)
 		i2c_dev->is_suspended = false;
 
-	i2c_unlock_adapter(&i2c_dev->adapter);
+	i2c_unlock_root(&i2c_dev->adapter);
 
 	return ret;
 }
diff --git a/drivers/i2c/i2c-core-slave.c b/drivers/i2c/i2c-core-slave.c
index 4a78c65e9971..fd68678f31c2 100644
--- a/drivers/i2c/i2c-core-slave.c
+++ b/drivers/i2c/i2c-core-slave.c
@@ -47,9 +47,9 @@ int i2c_slave_register(struct i2c_client *client, i2c_slave_cb_t slave_cb)
 
 	client->slave_cb = slave_cb;
 
-	i2c_lock_adapter(client->adapter);
+	i2c_lock_root(client->adapter);
 	ret = client->adapter->algo->reg_slave(client);
-	i2c_unlock_adapter(client->adapter);
+	i2c_unlock_root(client->adapter);
 
 	if (ret) {
 		client->slave_cb = NULL;
@@ -69,9 +69,9 @@ int i2c_slave_unregister(struct i2c_client *client)
 		return -EOPNOTSUPP;
 	}
 
-	i2c_lock_adapter(client->adapter);
+	i2c_lock_root(client->adapter);
 	ret = client->adapter->algo->unreg_slave(client);
-	i2c_unlock_adapter(client->adapter);
+	i2c_unlock_root(client->adapter);
 
 	if (ret == 0)
 		client->slave_cb = NULL;
diff --git a/drivers/iio/temperature/mlx90614.c b/drivers/iio/temperature/mlx90614.c
index d619e8634a00..15e7b2c3e7d7 100644
--- a/drivers/iio/temperature/mlx90614.c
+++ b/drivers/iio/temperature/mlx90614.c
@@ -433,11 +433,11 @@ static int mlx90614_wakeup(struct mlx90614_data *data)
 
 	dev_dbg(&data->client->dev, "Requesting wake-up");
 
-	i2c_lock_adapter(data->client->adapter);
+	i2c_lock_root(data->client->adapter);
 	gpiod_direction_output(data->wakeup_gpio, 0);
 	msleep(MLX90614_TIMING_WAKEUP);
 	gpiod_direction_input(data->wakeup_gpio);
-	i2c_unlock_adapter(data->client->adapter);
+	i2c_unlock_root(data->client->adapter);
 
 	data->ready_timestamp = jiffies +
 			msecs_to_jiffies(MLX90614_TIMING_STARTUP);
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index c9080d49e988..40db4b0accb8 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -757,13 +757,13 @@ i2c_unlock_bus(struct i2c_adapter *adapter, unsigned int flags)
 }
 
 static inline void
-i2c_lock_adapter(struct i2c_adapter *adapter)
+i2c_lock_root(struct i2c_adapter *adapter)
 {
 	i2c_lock_bus(adapter, I2C_LOCK_ROOT_ADAPTER);
 }
 
 static inline void
-i2c_unlock_adapter(struct i2c_adapter *adapter)
+i2c_unlock_root(struct i2c_adapter *adapter)
 {
 	i2c_unlock_bus(adapter, I2C_LOCK_ROOT_ADAPTER);
 }
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 63+ messages in thread

* [PATCH 11/11] i2c: rename i2c_lock_adapter to i2c_lock_root
@ 2018-06-15 10:15   ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-15 10:15 UTC (permalink / raw)
  To: linux-arm-kernel

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. Rename the function to indicate
what is really going on. Also rename i2c_unlock_adapter, of course.

This patch was generated with

  grep -rlI --exclude-dir=.git 'i2c_\(un\)\?lock_adapter' \
    | xargs sed -i 's/i2c_\(un\)\?lock_adapter/i2c_\1lock_root/g'

followed by some minor white-space touch-up.

Signed-off-by: Peter Rosin <peda@axentia.se>
---
 drivers/i2c/busses/i2c-brcmstb.c   |  8 ++++----
 drivers/i2c/busses/i2c-davinci.c   |  4 ++--
 drivers/i2c/busses/i2c-gpio.c      | 12 ++++++------
 drivers/i2c/busses/i2c-s3c2410.c   |  4 ++--
 drivers/i2c/busses/i2c-sprd.c      |  8 ++++----
 drivers/i2c/busses/i2c-tegra.c     |  8 ++++----
 drivers/i2c/i2c-core-slave.c       |  8 ++++----
 drivers/iio/temperature/mlx90614.c |  4 ++--
 include/linux/i2c.h                |  4 ++--
 9 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/drivers/i2c/busses/i2c-brcmstb.c b/drivers/i2c/busses/i2c-brcmstb.c
index 78792b4d6437..c42e14d4a127 100644
--- a/drivers/i2c/busses/i2c-brcmstb.c
+++ b/drivers/i2c/busses/i2c-brcmstb.c
@@ -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_root(&i2c_dev->adapter);
 	i2c_dev->is_suspended = true;
-	i2c_unlock_adapter(&i2c_dev->adapter);
+	i2c_unlock_root(&i2c_dev->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_root(&i2c_dev->adapter);
 	brcmstb_i2c_set_bsc_reg_defaults(i2c_dev);
 	i2c_dev->is_suspended = false;
-	i2c_unlock_adapter(&i2c_dev->adapter);
+	i2c_unlock_root(&i2c_dev->adapter);
 
 	return 0;
 }
diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index 75d6ab177055..9139d8da29ae 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -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_root(&dev->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_root(&dev->adapter);
 
 	return 0;
 }
diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
index 58abb3eced58..6983968735ca 100644
--- a/drivers/i2c/busses/i2c-gpio.c
+++ b/drivers/i2c/busses/i2c-gpio.c
@@ -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_root(&priv->adap);			\
 	*val = get##wire(&priv->bit_data);		\
-	i2c_unlock_adapter(&priv->adap);		\
+	i2c_unlock_root(&priv->adap);			\
 	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_root(&priv->adap);			\
 	set##wire(&priv->bit_data, val);		\
-	i2c_unlock_adapter(&priv->adap);		\
+	i2c_unlock_root(&priv->adap);			\
 	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_root(&priv->adap);
 
 	/* 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_root(&priv->adap);
 
 	return 0;
 }
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 5d97510ee48b..6e8f8d2e847c 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -921,9 +921,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_root(&i2c->adap);
 		ret = s3c24xx_i2c_clockrate(i2c, &got);
-		i2c_unlock_adapter(&i2c->adap);
+		i2c_unlock_root(&i2c->adap);
 
 		if (ret < 0)
 			dev_err(i2c->dev, "cannot find frequency (%d)\n", ret);
diff --git a/drivers/i2c/busses/i2c-sprd.c b/drivers/i2c/busses/i2c-sprd.c
index 4053259bccb8..58a4a263984f 100644
--- a/drivers/i2c/busses/i2c-sprd.c
+++ b/drivers/i2c/busses/i2c-sprd.c
@@ -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_root(&i2c_dev->adap);
 	i2c_dev->is_suspended = true;
-	i2c_unlock_adapter(&i2c_dev->adap);
+	i2c_unlock_root(&i2c_dev->adap);
 
 	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_root(&i2c_dev->adap);
 	i2c_dev->is_suspended = false;
-	i2c_unlock_adapter(&i2c_dev->adap);
+	i2c_unlock_root(&i2c_dev->adap);
 
 	return pm_runtime_force_resume(pdev);
 }
diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index 60292d243e24..1f2ed0dfbbaf 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -1055,9 +1055,9 @@ static int tegra_i2c_suspend(struct device *dev)
 {
 	struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
 
-	i2c_lock_adapter(&i2c_dev->adapter);
+	i2c_lock_root(&i2c_dev->adapter);
 	i2c_dev->is_suspended = true;
-	i2c_unlock_adapter(&i2c_dev->adapter);
+	i2c_unlock_root(&i2c_dev->adapter);
 
 	return 0;
 }
@@ -1067,13 +1067,13 @@ static int tegra_i2c_resume(struct device *dev)
 	struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
 	int ret;
 
-	i2c_lock_adapter(&i2c_dev->adapter);
+	i2c_lock_root(&i2c_dev->adapter);
 
 	ret = tegra_i2c_init(i2c_dev);
 	if (!ret)
 		i2c_dev->is_suspended = false;
 
-	i2c_unlock_adapter(&i2c_dev->adapter);
+	i2c_unlock_root(&i2c_dev->adapter);
 
 	return ret;
 }
diff --git a/drivers/i2c/i2c-core-slave.c b/drivers/i2c/i2c-core-slave.c
index 4a78c65e9971..fd68678f31c2 100644
--- a/drivers/i2c/i2c-core-slave.c
+++ b/drivers/i2c/i2c-core-slave.c
@@ -47,9 +47,9 @@ int i2c_slave_register(struct i2c_client *client, i2c_slave_cb_t slave_cb)
 
 	client->slave_cb = slave_cb;
 
-	i2c_lock_adapter(client->adapter);
+	i2c_lock_root(client->adapter);
 	ret = client->adapter->algo->reg_slave(client);
-	i2c_unlock_adapter(client->adapter);
+	i2c_unlock_root(client->adapter);
 
 	if (ret) {
 		client->slave_cb = NULL;
@@ -69,9 +69,9 @@ int i2c_slave_unregister(struct i2c_client *client)
 		return -EOPNOTSUPP;
 	}
 
-	i2c_lock_adapter(client->adapter);
+	i2c_lock_root(client->adapter);
 	ret = client->adapter->algo->unreg_slave(client);
-	i2c_unlock_adapter(client->adapter);
+	i2c_unlock_root(client->adapter);
 
 	if (ret == 0)
 		client->slave_cb = NULL;
diff --git a/drivers/iio/temperature/mlx90614.c b/drivers/iio/temperature/mlx90614.c
index d619e8634a00..15e7b2c3e7d7 100644
--- a/drivers/iio/temperature/mlx90614.c
+++ b/drivers/iio/temperature/mlx90614.c
@@ -433,11 +433,11 @@ static int mlx90614_wakeup(struct mlx90614_data *data)
 
 	dev_dbg(&data->client->dev, "Requesting wake-up");
 
-	i2c_lock_adapter(data->client->adapter);
+	i2c_lock_root(data->client->adapter);
 	gpiod_direction_output(data->wakeup_gpio, 0);
 	msleep(MLX90614_TIMING_WAKEUP);
 	gpiod_direction_input(data->wakeup_gpio);
-	i2c_unlock_adapter(data->client->adapter);
+	i2c_unlock_root(data->client->adapter);
 
 	data->ready_timestamp = jiffies +
 			msecs_to_jiffies(MLX90614_TIMING_STARTUP);
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index c9080d49e988..40db4b0accb8 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -757,13 +757,13 @@ i2c_unlock_bus(struct i2c_adapter *adapter, unsigned int flags)
 }
 
 static inline void
-i2c_lock_adapter(struct i2c_adapter *adapter)
+i2c_lock_root(struct i2c_adapter *adapter)
 {
 	i2c_lock_bus(adapter, I2C_LOCK_ROOT_ADAPTER);
 }
 
 static inline void
-i2c_unlock_adapter(struct i2c_adapter *adapter)
+i2c_unlock_root(struct i2c_adapter *adapter)
 {
 	i2c_unlock_bus(adapter, I2C_LOCK_ROOT_ADAPTER);
 }
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 63+ messages in thread

* Re: [PATCH 01/11] i2c: add helpers for locking the I2C segment
  2018-06-15 10:14   ` Peter Rosin
  (?)
  (?)
@ 2018-06-18 11:05     ` Wolfram Sang
  -1 siblings, 0 replies; 63+ messages in thread
From: Wolfram Sang @ 2018-06-18 11:05 UTC (permalink / raw)
  To: Peter Rosin
  Cc: linux-kernel, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding

[-- Attachment #1: Type: text/plain, Size: 669 bytes --]


> +static inline void
> +i2c_lock_segment(struct i2c_adapter *adapter)
> +{
> +	i2c_lock_bus(adapter, I2C_LOCK_SEGMENT);
> +}
> +
> +static inline int
> +i2c_trylock_segment(struct i2c_adapter *adapter)
> +{
> +	return i2c_trylock_bus(adapter, I2C_LOCK_SEGMENT);
> +}
> +
> +static inline void
> +i2c_unlock_segment(struct i2c_adapter *adapter)
> +{
> +	i2c_unlock_bus(adapter, I2C_LOCK_SEGMENT);
> +}

I wonder if i2c_lock_segment() and i2c_lock_root_adapter() are really
more readable and convenient than i2c_lock_bus() with the flag. I think
the flags have speaking names, too.

Is that an idea to remove these functions altogether and start using
i2c_lock_bus()?


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 01/11] i2c: add helpers for locking the I2C segment
@ 2018-06-18 11:05     ` Wolfram Sang
  0 siblings, 0 replies; 63+ messages in thread
From: Wolfram Sang @ 2018-06-18 11:05 UTC (permalink / raw)
  To: Peter Rosin
  Cc: linux-kernel, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding, Jonathan Hunter, Guenter Roeck,
	Crt Mori, Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Dmitry Torokhov, Antti Palosaari,
	Mauro Carvalho Chehab, Michael Krufky, Lee Jones,
	linux-integrity, linux-i2c, linux-arm-kernel, linux-samsung-soc,
	linux-tegra, linux-iio, linux-input, linux-media

[-- Attachment #1: Type: text/plain, Size: 669 bytes --]


> +static inline void
> +i2c_lock_segment(struct i2c_adapter *adapter)
> +{
> +	i2c_lock_bus(adapter, I2C_LOCK_SEGMENT);
> +}
> +
> +static inline int
> +i2c_trylock_segment(struct i2c_adapter *adapter)
> +{
> +	return i2c_trylock_bus(adapter, I2C_LOCK_SEGMENT);
> +}
> +
> +static inline void
> +i2c_unlock_segment(struct i2c_adapter *adapter)
> +{
> +	i2c_unlock_bus(adapter, I2C_LOCK_SEGMENT);
> +}

I wonder if i2c_lock_segment() and i2c_lock_root_adapter() are really
more readable and convenient than i2c_lock_bus() with the flag. I think
the flags have speaking names, too.

Is that an idea to remove these functions altogether and start using
i2c_lock_bus()?


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 01/11] i2c: add helpers for locking the I2C segment
@ 2018-06-18 11:05     ` Wolfram Sang
  0 siblings, 0 replies; 63+ messages in thread
From: Wolfram Sang @ 2018-06-18 11:05 UTC (permalink / raw)
  To: Peter Rosin
  Cc: linux-kernel, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding, Jonathan Hunter, Guenter Roeck,
	Crt Mori, Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Dmitry Torokhov, Antti Palosaari,
	Mauro Carvalho Chehab, Michael Krufky, Lee Jones,
	linux-integrity, linux-i2c, linux-arm-kernel, linux-samsung-soc,
	linux-tegra, linux-iio, linux-input, linux-media

[-- Attachment #1: Type: multipart/signed, Size: 783 bytes --]

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [PATCH 01/11] i2c: add helpers for locking the I2C segment
@ 2018-06-18 11:05     ` Wolfram Sang
  0 siblings, 0 replies; 63+ messages in thread
From: Wolfram Sang @ 2018-06-18 11:05 UTC (permalink / raw)
  To: linux-arm-kernel


> +static inline void
> +i2c_lock_segment(struct i2c_adapter *adapter)
> +{
> +	i2c_lock_bus(adapter, I2C_LOCK_SEGMENT);
> +}
> +
> +static inline int
> +i2c_trylock_segment(struct i2c_adapter *adapter)
> +{
> +	return i2c_trylock_bus(adapter, I2C_LOCK_SEGMENT);
> +}
> +
> +static inline void
> +i2c_unlock_segment(struct i2c_adapter *adapter)
> +{
> +	i2c_unlock_bus(adapter, I2C_LOCK_SEGMENT);
> +}

I wonder if i2c_lock_segment() and i2c_lock_root_adapter() are really
more readable and convenient than i2c_lock_bus() with the flag. I think
the flags have speaking names, too.

Is that an idea to remove these functions altogether and start using
i2c_lock_bus()?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180618/b15be943/attachment.sig>

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 00/11] Split i2c_lock_adapter into i2c_lock_root and i2c_lock_segment
  2018-06-15 10:14 ` Peter Rosin
  (?)
  (?)
@ 2018-06-18 11:06   ` Wolfram Sang
  -1 siblings, 0 replies; 63+ messages in thread
From: Wolfram Sang @ 2018-06-18 11:06 UTC (permalink / raw)
  To: Peter Rosin
  Cc: linux-kernel, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding

[-- Attachment #1: Type: text/plain, Size: 311 bytes --]


> I suggest that Wolfram takes this series through the I2C tree
> and creates an immutable branch for the other subsystems. The

I'd prefer this, too. Are the other subsystem maintainers fine with
that?

I am very positive on the series. I just have one comment which I just
posted. It looks good in general.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 00/11] Split i2c_lock_adapter into i2c_lock_root and i2c_lock_segment
@ 2018-06-18 11:06   ` Wolfram Sang
  0 siblings, 0 replies; 63+ messages in thread
From: Wolfram Sang @ 2018-06-18 11:06 UTC (permalink / raw)
  To: Peter Rosin
  Cc: linux-kernel, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding, Jonathan Hunter, Guenter Roeck,
	Crt Mori, Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Dmitry Torokhov, Antti Palosaari,
	Mauro Carvalho Chehab, Michael Krufky, Lee Jones,
	linux-integrity, linux-i2c, linux-arm-kernel, linux-samsung-soc,
	linux-tegra, linux-iio, linux-input, linux-media

[-- Attachment #1: Type: text/plain, Size: 311 bytes --]


> I suggest that Wolfram takes this series through the I2C tree
> and creates an immutable branch for the other subsystems. The

I'd prefer this, too. Are the other subsystem maintainers fine with
that?

I am very positive on the series. I just have one comment which I just
posted. It looks good in general.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 00/11] Split i2c_lock_adapter into i2c_lock_root and i2c_lock_segment
@ 2018-06-18 11:06   ` Wolfram Sang
  0 siblings, 0 replies; 63+ messages in thread
From: Wolfram Sang @ 2018-06-18 11:06 UTC (permalink / raw)
  To: Peter Rosin
  Cc: linux-kernel, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding, Jonathan Hunter, Guenter Roeck,
	Crt Mori, Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Dmitry Torokhov, Antti Palosaari,
	Mauro Carvalho Chehab, Michael Krufky, Lee Jones,
	linux-integrity, linux-i2c, linux-arm-kernel, linux-samsung-soc,
	linux-tegra, linux-iio, linux-input, linux-media

[-- Attachment #1: Type: multipart/signed, Size: 425 bytes --]

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [PATCH 00/11] Split i2c_lock_adapter into i2c_lock_root and i2c_lock_segment
@ 2018-06-18 11:06   ` Wolfram Sang
  0 siblings, 0 replies; 63+ messages in thread
From: Wolfram Sang @ 2018-06-18 11:06 UTC (permalink / raw)
  To: linux-arm-kernel


> I suggest that Wolfram takes this series through the I2C tree
> and creates an immutable branch for the other subsystems. The

I'd prefer this, too. Are the other subsystem maintainers fine with
that?

I am very positive on the series. I just have one comment which I just
posted. It looks good in general.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180618/38e24c06/attachment.sig>

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 01/11] i2c: add helpers for locking the I2C segment
  2018-06-18 11:05     ` Wolfram Sang
  (?)
@ 2018-06-18 11:32       ` Peter Rosin
  -1 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-18 11:32 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-kernel, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding

On 2018-06-18 13:05, Wolfram Sang wrote:
> 
>> +static inline void
>> +i2c_lock_segment(struct i2c_adapter *adapter)
>> +{
>> +	i2c_lock_bus(adapter, I2C_LOCK_SEGMENT);
>> +}
>> +
>> +static inline int
>> +i2c_trylock_segment(struct i2c_adapter *adapter)
>> +{
>> +	return i2c_trylock_bus(adapter, I2C_LOCK_SEGMENT);
>> +}
>> +
>> +static inline void
>> +i2c_unlock_segment(struct i2c_adapter *adapter)
>> +{
>> +	i2c_unlock_bus(adapter, I2C_LOCK_SEGMENT);
>> +}
> 
> I wonder if i2c_lock_segment() and i2c_lock_root_adapter() are really
> more readable and convenient than i2c_lock_bus() with the flag. I think
> the flags have speaking names, too.
> 
> Is that an idea to remove these functions altogether and start using
> i2c_lock_bus()?

That would be fine with me. I don't have a strong opinion and agree that
both are readable enough...

It would make for a reduction of the number of lines so that's nice, but
the macro in drivers/i2c/busses/i2c-gpio.c (patch 11) would not fit in
the current \-width (or whatever you'd call that line of backslashes to
the right in a multi-line macro).

Does anyone have a strong opinion?

Cheers,
Peter

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 01/11] i2c: add helpers for locking the I2C segment
@ 2018-06-18 11:32       ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-18 11:32 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-kernel, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding, Jonathan Hunter, Guenter Roeck,
	Crt Mori, Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Dmitry Torokhov, Antti Palosaari,
	Mauro Carvalho Chehab, Michael Krufky, Lee Jones,
	linux-integrity, linux-i2c, linux-arm-kernel, linux-samsung-soc,
	linux-tegra, linux-iio, linux-input, linux-media

On 2018-06-18 13:05, Wolfram Sang wrote:
> 
>> +static inline void
>> +i2c_lock_segment(struct i2c_adapter *adapter)
>> +{
>> +	i2c_lock_bus(adapter, I2C_LOCK_SEGMENT);
>> +}
>> +
>> +static inline int
>> +i2c_trylock_segment(struct i2c_adapter *adapter)
>> +{
>> +	return i2c_trylock_bus(adapter, I2C_LOCK_SEGMENT);
>> +}
>> +
>> +static inline void
>> +i2c_unlock_segment(struct i2c_adapter *adapter)
>> +{
>> +	i2c_unlock_bus(adapter, I2C_LOCK_SEGMENT);
>> +}
> 
> I wonder if i2c_lock_segment() and i2c_lock_root_adapter() are really
> more readable and convenient than i2c_lock_bus() with the flag. I think
> the flags have speaking names, too.
> 
> Is that an idea to remove these functions altogether and start using
> i2c_lock_bus()?

That would be fine with me. I don't have a strong opinion and agree that
both are readable enough...

It would make for a reduction of the number of lines so that's nice, but
the macro in drivers/i2c/busses/i2c-gpio.c (patch 11) would not fit in
the current \-width (or whatever you'd call that line of backslashes to
the right in a multi-line macro).

Does anyone have a strong opinion?

Cheers,
Peter

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [PATCH 01/11] i2c: add helpers for locking the I2C segment
@ 2018-06-18 11:32       ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-18 11:32 UTC (permalink / raw)
  To: linux-arm-kernel

On 2018-06-18 13:05, Wolfram Sang wrote:
> 
>> +static inline void
>> +i2c_lock_segment(struct i2c_adapter *adapter)
>> +{
>> +	i2c_lock_bus(adapter, I2C_LOCK_SEGMENT);
>> +}
>> +
>> +static inline int
>> +i2c_trylock_segment(struct i2c_adapter *adapter)
>> +{
>> +	return i2c_trylock_bus(adapter, I2C_LOCK_SEGMENT);
>> +}
>> +
>> +static inline void
>> +i2c_unlock_segment(struct i2c_adapter *adapter)
>> +{
>> +	i2c_unlock_bus(adapter, I2C_LOCK_SEGMENT);
>> +}
> 
> I wonder if i2c_lock_segment() and i2c_lock_root_adapter() are really
> more readable and convenient than i2c_lock_bus() with the flag. I think
> the flags have speaking names, too.
> 
> Is that an idea to remove these functions altogether and start using
> i2c_lock_bus()?

That would be fine with me. I don't have a strong opinion and agree that
both are readable enough...

It would make for a reduction of the number of lines so that's nice, but
the macro in drivers/i2c/busses/i2c-gpio.c (patch 11) would not fit in
the current \-width (or whatever you'd call that line of backslashes to
the right in a multi-line macro).

Does anyone have a strong opinion?

Cheers,
Peter

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 01/11] i2c: add helpers for locking the I2C segment
  2018-06-18 11:32       ` Peter Rosin
  (?)
  (?)
@ 2018-06-18 11:54         ` Wolfram Sang
  -1 siblings, 0 replies; 63+ messages in thread
From: Wolfram Sang @ 2018-06-18 11:54 UTC (permalink / raw)
  To: Peter Rosin
  Cc: linux-kernel, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding

[-- Attachment #1: Type: text/plain, Size: 886 bytes --]


> > I wonder if i2c_lock_segment() and i2c_lock_root_adapter() are really
> > more readable and convenient than i2c_lock_bus() with the flag. I think
> > the flags have speaking names, too.
> > 
> > Is that an idea to remove these functions altogether and start using
> > i2c_lock_bus()?
> 
> That would be fine with me. I don't have a strong opinion and agree that
> both are readable enough...
> 
> It would make for a reduction of the number of lines so that's nice, but
> the macro in drivers/i2c/busses/i2c-gpio.c (patch 11) would not fit in
> the current \-width (or whatever you'd call that line of backslashes to
> the right in a multi-line macro).
> 
> Does anyone have a strong opinion?

I have a strong opinion on making i2c.h less bloated. And yes, less
number of lines is nice, too. I think that surely pays off the
whitespace exception.

Thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 01/11] i2c: add helpers for locking the I2C segment
@ 2018-06-18 11:54         ` Wolfram Sang
  0 siblings, 0 replies; 63+ messages in thread
From: Wolfram Sang @ 2018-06-18 11:54 UTC (permalink / raw)
  To: Peter Rosin
  Cc: linux-kernel, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding, Jonathan Hunter, Guenter Roeck,
	Crt Mori, Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Dmitry Torokhov, Antti Palosaari,
	Mauro Carvalho Chehab, Michael Krufky, Lee Jones,
	linux-integrity, linux-i2c, linux-arm-kernel, linux-samsung-soc,
	linux-tegra, linux-iio, linux-input, linux-media

[-- Attachment #1: Type: text/plain, Size: 886 bytes --]


> > I wonder if i2c_lock_segment() and i2c_lock_root_adapter() are really
> > more readable and convenient than i2c_lock_bus() with the flag. I think
> > the flags have speaking names, too.
> > 
> > Is that an idea to remove these functions altogether and start using
> > i2c_lock_bus()?
> 
> That would be fine with me. I don't have a strong opinion and agree that
> both are readable enough...
> 
> It would make for a reduction of the number of lines so that's nice, but
> the macro in drivers/i2c/busses/i2c-gpio.c (patch 11) would not fit in
> the current \-width (or whatever you'd call that line of backslashes to
> the right in a multi-line macro).
> 
> Does anyone have a strong opinion?

I have a strong opinion on making i2c.h less bloated. And yes, less
number of lines is nice, too. I think that surely pays off the
whitespace exception.

Thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 01/11] i2c: add helpers for locking the I2C segment
@ 2018-06-18 11:54         ` Wolfram Sang
  0 siblings, 0 replies; 63+ messages in thread
From: Wolfram Sang @ 2018-06-18 11:54 UTC (permalink / raw)
  To: Peter Rosin
  Cc: linux-kernel, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding, Jonathan Hunter, Guenter Roeck,
	Crt Mori, Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Dmitry Torokhov, Antti Palosaari,
	Mauro Carvalho Chehab, Michael Krufky, Lee Jones,
	linux-integrity, linux-i2c, linux-arm-kernel, linux-samsung-soc,
	linux-tegra, linux-iio, linux-input, linux-media

[-- Attachment #1: Type: multipart/signed, Size: 976 bytes --]

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [PATCH 01/11] i2c: add helpers for locking the I2C segment
@ 2018-06-18 11:54         ` Wolfram Sang
  0 siblings, 0 replies; 63+ messages in thread
From: Wolfram Sang @ 2018-06-18 11:54 UTC (permalink / raw)
  To: linux-arm-kernel


> > I wonder if i2c_lock_segment() and i2c_lock_root_adapter() are really
> > more readable and convenient than i2c_lock_bus() with the flag. I think
> > the flags have speaking names, too.
> > 
> > Is that an idea to remove these functions altogether and start using
> > i2c_lock_bus()?
> 
> That would be fine with me. I don't have a strong opinion and agree that
> both are readable enough...
> 
> It would make for a reduction of the number of lines so that's nice, but
> the macro in drivers/i2c/busses/i2c-gpio.c (patch 11) would not fit in
> the current \-width (or whatever you'd call that line of backslashes to
> the right in a multi-line macro).
> 
> Does anyone have a strong opinion?

I have a strong opinion on making i2c.h less bloated. And yes, less
number of lines is nice, too. I think that surely pays off the
whitespace exception.

Thanks!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180618/045df151/attachment.sig>

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 02/11] tpm/tpm_i2c_infineon: switch to i2c_lock_segment
  2018-06-15 10:14   ` Peter Rosin
  (?)
@ 2018-06-19 12:56     ` Jarkko Sakkinen
  -1 siblings, 0 replies; 63+ messages in thread
From: Jarkko Sakkinen @ 2018-06-19 12:56 UTC (permalink / raw)
  To: Peter Rosin
  Cc: linux-kernel, Peter Huewe, Jason Gunthorpe, Arnd Bergmann,
	Greg Kroah-Hartman, Brian Norris, Gregory Fong, Florian Fainelli,
	bcm-kernel-feedback-list, Sekhar Nori, Kevin Hilman,
	Haavard Skinnemoen, Kukjin Kim, Krzysztof Kozlowski, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Laxman Dewangan, Thierry Reding,
	Jonathan Hunter, Wo

On Fri, Jun 15, 2018 at 12:14:57PM +0200, Peter Rosin wrote:
> 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_segment. 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>

Can you quickly explain (or give a reference) the difference with these
functions? Not an expert in this area. Thanks.

/Jarkko

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 02/11] tpm/tpm_i2c_infineon: switch to i2c_lock_segment
@ 2018-06-19 12:56     ` Jarkko Sakkinen
  0 siblings, 0 replies; 63+ messages in thread
From: Jarkko Sakkinen @ 2018-06-19 12:56 UTC (permalink / raw)
  To: Peter Rosin
  Cc: linux-kernel, Peter Huewe, Jason Gunthorpe, Arnd Bergmann,
	Greg Kroah-Hartman, Brian Norris, Gregory Fong, Florian Fainelli,
	bcm-kernel-feedback-list, Sekhar Nori, Kevin Hilman,
	Haavard Skinnemoen, Kukjin Kim, Krzysztof Kozlowski, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Laxman Dewangan, Thierry Reding,
	Jonathan Hunter, Wolfram Sang, Guenter Roeck, Crt Mori,
	Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Dmitry Torokhov, Antti Palosaari,
	Mauro Carvalho Chehab, Michael Krufky, Lee Jones,
	linux-integrity, linux-i2c, linux-arm-kernel, linux-samsung-soc,
	linux-tegra, linux-iio, linux-input, linux-media

On Fri, Jun 15, 2018 at 12:14:57PM +0200, Peter Rosin wrote:
> 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_segment. 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>

Can you quickly explain (or give a reference) the difference with these
functions? Not an expert in this area. Thanks.

/Jarkko

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [PATCH 02/11] tpm/tpm_i2c_infineon: switch to i2c_lock_segment
@ 2018-06-19 12:56     ` Jarkko Sakkinen
  0 siblings, 0 replies; 63+ messages in thread
From: Jarkko Sakkinen @ 2018-06-19 12:56 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jun 15, 2018 at 12:14:57PM +0200, Peter Rosin wrote:
> 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_segment. 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>

Can you quickly explain (or give a reference) the difference with these
functions? Not an expert in this area. Thanks.

/Jarkko

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 02/11] tpm/tpm_i2c_infineon: switch to i2c_lock_segment
  2018-06-19 12:56     ` Jarkko Sakkinen
  (?)
@ 2018-06-19 13:05       ` Peter Rosin
  -1 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-19 13:05 UTC (permalink / raw)
  To: Jarkko Sakkinen
  Cc: linux-kernel, Peter Huewe, Jason Gunthorpe, Arnd Bergmann,
	Greg Kroah-Hartman, Brian Norris, Gregory Fong, Florian Fainelli,
	bcm-kernel-feedback-list, Sekhar Nori, Kevin Hilman,
	Haavard Skinnemoen, Kukjin Kim, Krzysztof Kozlowski, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Laxman Dewangan, Thierry Reding,
	Jonathan Hunter, Wo

On 2018-06-19 14:56, Jarkko Sakkinen wrote:
> On Fri, Jun 15, 2018 at 12:14:57PM +0200, Peter Rosin wrote:
>> 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_segment. 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>
> 
> Can you quickly explain (or give a reference) the difference with these
> functions? Not an expert in this area. Thanks.

There are some words in the cover letter. If you need more, there's
always Documentation/i2c/i2c-topology. Hope that helps, otherwise I'll
try to explain better...

Cheers,
Peter

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 02/11] tpm/tpm_i2c_infineon: switch to i2c_lock_segment
@ 2018-06-19 13:05       ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-19 13:05 UTC (permalink / raw)
  To: Jarkko Sakkinen
  Cc: linux-kernel, Peter Huewe, Jason Gunthorpe, Arnd Bergmann,
	Greg Kroah-Hartman, Brian Norris, Gregory Fong, Florian Fainelli,
	bcm-kernel-feedback-list, Sekhar Nori, Kevin Hilman,
	Haavard Skinnemoen, Kukjin Kim, Krzysztof Kozlowski, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Laxman Dewangan, Thierry Reding,
	Jonathan Hunter, Wolfram Sang, Guenter Roeck, Crt Mori,
	Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Dmitry Torokhov, Antti Palosaari,
	Mauro Carvalho Chehab, Michael Krufky, Lee Jones,
	linux-integrity, linux-i2c, linux-arm-kernel, linux-samsung-soc,
	linux-tegra, linux-iio, linux-input, linux-media

On 2018-06-19 14:56, Jarkko Sakkinen wrote:
> On Fri, Jun 15, 2018 at 12:14:57PM +0200, Peter Rosin wrote:
>> 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_segment. 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>
> 
> Can you quickly explain (or give a reference) the difference with these
> functions? Not an expert in this area. Thanks.

There are some words in the cover letter. If you need more, there's
always Documentation/i2c/i2c-topology. Hope that helps, otherwise I'll
try to explain better...

Cheers,
Peter

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [PATCH 02/11] tpm/tpm_i2c_infineon: switch to i2c_lock_segment
@ 2018-06-19 13:05       ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-19 13:05 UTC (permalink / raw)
  To: linux-arm-kernel

On 2018-06-19 14:56, Jarkko Sakkinen wrote:
> On Fri, Jun 15, 2018 at 12:14:57PM +0200, Peter Rosin wrote:
>> 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_segment. 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>
> 
> Can you quickly explain (or give a reference) the difference with these
> functions? Not an expert in this area. Thanks.

There are some words in the cover letter. If you need more, there's
always Documentation/i2c/i2c-topology. Hope that helps, otherwise I'll
try to explain better...

Cheers,
Peter

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 04/11] input: rohm_bu21023: switch to i2c_lock_segment
  2018-06-15 10:14   ` Peter Rosin
  (?)
@ 2018-06-19 18:40     ` Dmitry Torokhov
  -1 siblings, 0 replies; 63+ messages in thread
From: Dmitry Torokhov @ 2018-06-19 18:40 UTC (permalink / raw)
  To: Peter Rosin
  Cc: linux-kernel, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding

On Fri, Jun 15, 2018 at 12:14:59PM +0200, Peter Rosin wrote:
> 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_segment. 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>

Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

I'm OK with it going through Wolfram's tree; I do not think I'd need an
immutable branch for this even...

> ---
>  drivers/input/touchscreen/rohm_bu21023.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/rohm_bu21023.c b/drivers/input/touchscreen/rohm_bu21023.c
> index bda0500c9b57..22d79db07234 100644
> --- a/drivers/input/touchscreen/rohm_bu21023.c
> +++ b/drivers/input/touchscreen/rohm_bu21023.c
> @@ -304,7 +304,7 @@ static int rohm_i2c_burst_read(struct i2c_client *client, u8 start, void *buf,
>  	msg[1].len = len;
>  	msg[1].buf = buf;
>  
> -	i2c_lock_adapter(adap);
> +	i2c_lock_segment(adap);
>  
>  	for (i = 0; i < 2; i++) {
>  		if (__i2c_transfer(adap, &msg[i], 1) < 0) {
> @@ -313,7 +313,7 @@ static int rohm_i2c_burst_read(struct i2c_client *client, u8 start, void *buf,
>  		}
>  	}
>  
> -	i2c_unlock_adapter(adap);
> +	i2c_unlock_segment(adap);
>  
>  	return ret;
>  }
> -- 
> 2.11.0
> 

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 04/11] input: rohm_bu21023: switch to i2c_lock_segment
@ 2018-06-19 18:40     ` Dmitry Torokhov
  0 siblings, 0 replies; 63+ messages in thread
From: Dmitry Torokhov @ 2018-06-19 18:40 UTC (permalink / raw)
  To: Peter Rosin
  Cc: linux-kernel, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding, Jonathan Hunter, Wolfram Sang,
	Guenter Roeck, Crt Mori, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, Antti Palosaari,
	Mauro Carvalho Chehab, Michael Krufky, Lee Jones,
	linux-integrity, linux-i2c, linux-arm-kernel, linux-samsung-soc,
	linux-tegra, linux-iio, linux-input, linux-media

On Fri, Jun 15, 2018 at 12:14:59PM +0200, Peter Rosin wrote:
> 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_segment. 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>

Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

I'm OK with it going through Wolfram's tree; I do not think I'd need an
immutable branch for this even...

> ---
>  drivers/input/touchscreen/rohm_bu21023.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/rohm_bu21023.c b/drivers/input/touchscreen/rohm_bu21023.c
> index bda0500c9b57..22d79db07234 100644
> --- a/drivers/input/touchscreen/rohm_bu21023.c
> +++ b/drivers/input/touchscreen/rohm_bu21023.c
> @@ -304,7 +304,7 @@ static int rohm_i2c_burst_read(struct i2c_client *client, u8 start, void *buf,
>  	msg[1].len = len;
>  	msg[1].buf = buf;
>  
> -	i2c_lock_adapter(adap);
> +	i2c_lock_segment(adap);
>  
>  	for (i = 0; i < 2; i++) {
>  		if (__i2c_transfer(adap, &msg[i], 1) < 0) {
> @@ -313,7 +313,7 @@ static int rohm_i2c_burst_read(struct i2c_client *client, u8 start, void *buf,
>  		}
>  	}
>  
> -	i2c_unlock_adapter(adap);
> +	i2c_unlock_segment(adap);
>  
>  	return ret;
>  }
> -- 
> 2.11.0
> 

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [PATCH 04/11] input: rohm_bu21023: switch to i2c_lock_segment
@ 2018-06-19 18:40     ` Dmitry Torokhov
  0 siblings, 0 replies; 63+ messages in thread
From: Dmitry Torokhov @ 2018-06-19 18:40 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jun 15, 2018 at 12:14:59PM +0200, Peter Rosin wrote:
> 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_segment. 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>

Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

I'm OK with it going through Wolfram's tree; I do not think I'd need an
immutable branch for this even...

> ---
>  drivers/input/touchscreen/rohm_bu21023.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/rohm_bu21023.c b/drivers/input/touchscreen/rohm_bu21023.c
> index bda0500c9b57..22d79db07234 100644
> --- a/drivers/input/touchscreen/rohm_bu21023.c
> +++ b/drivers/input/touchscreen/rohm_bu21023.c
> @@ -304,7 +304,7 @@ static int rohm_i2c_burst_read(struct i2c_client *client, u8 start, void *buf,
>  	msg[1].len = len;
>  	msg[1].buf = buf;
>  
> -	i2c_lock_adapter(adap);
> +	i2c_lock_segment(adap);
>  
>  	for (i = 0; i < 2; i++) {
>  		if (__i2c_transfer(adap, &msg[i], 1) < 0) {
> @@ -313,7 +313,7 @@ static int rohm_i2c_burst_read(struct i2c_client *client, u8 start, void *buf,
>  		}
>  	}
>  
> -	i2c_unlock_adapter(adap);
> +	i2c_unlock_segment(adap);
>  
>  	return ret;
>  }
> -- 
> 2.11.0
> 

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 01/11] i2c: add helpers for locking the I2C segment
  2018-06-18 11:54         ` Wolfram Sang
  (?)
@ 2018-06-19 21:29           ` Peter Rosin
  -1 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-19 21:29 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-kernel, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding

On 2018-06-18 13:54, Wolfram Sang wrote:
> 
>>> I wonder if i2c_lock_segment() and i2c_lock_root_adapter() are really
>>> more readable and convenient than i2c_lock_bus() with the flag. I think
>>> the flags have speaking names, too.
>>>
>>> Is that an idea to remove these functions altogether and start using
>>> i2c_lock_bus()?
>>
>> That would be fine with me. I don't have a strong opinion and agree that
>> both are readable enough...
>>
>> It would make for a reduction of the number of lines so that's nice, but
>> the macro in drivers/i2c/busses/i2c-gpio.c (patch 11) would not fit in
>> the current \-width (or whatever you'd call that line of backslashes to
>> the right in a multi-line macro).
>>
>> Does anyone have a strong opinion?
> 
> I have a strong opinion on making i2c.h less bloated. And yes, less
> number of lines is nice, too. I think that surely pays off the
> whitespace exception.

Ok, I have rebased onto v4.18-rc1, killed the i2c-tegra hunk and converted
i2c_lock_root(foo) over to i2c_lock_bus(foo, I2C_LOCK_ROOT_ADAPTER) and
i2c_lock_segment(foo) over to i2c_lock_bus(foo, I2C_LOCK_SEGMENT). And I
of course killed a bunch of locking helpers in i2c.h.

I doing build tests now, will post a v2 in the morning.

Cheers,
Peter

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [PATCH 01/11] i2c: add helpers for locking the I2C segment
@ 2018-06-19 21:29           ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-19 21:29 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-kernel, Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe,
	Arnd Bergmann, Greg Kroah-Hartman, Brian Norris, Gregory Fong,
	Florian Fainelli, bcm-kernel-feedback-list, Sekhar Nori,
	Kevin Hilman, Haavard Skinnemoen, Kukjin Kim,
	Krzysztof Kozlowski, Orson Zhai, Baolin Wang, Chunyan Zhang,
	Laxman Dewangan, Thierry Reding, Jonathan Hunter, Guenter Roeck,
	Crt Mori, Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Dmitry Torokhov, Antti Palosaari,
	Mauro Carvalho Chehab, Michael Krufky, Lee Jones,
	linux-integrity, linux-i2c, linux-arm-kernel, linux-samsung-soc,
	linux-tegra, linux-iio, linux-input, linux-media

On 2018-06-18 13:54, Wolfram Sang wrote:
> 
>>> I wonder if i2c_lock_segment() and i2c_lock_root_adapter() are really
>>> more readable and convenient than i2c_lock_bus() with the flag. I think
>>> the flags have speaking names, too.
>>>
>>> Is that an idea to remove these functions altogether and start using
>>> i2c_lock_bus()?
>>
>> That would be fine with me. I don't have a strong opinion and agree that
>> both are readable enough...
>>
>> It would make for a reduction of the number of lines so that's nice, but
>> the macro in drivers/i2c/busses/i2c-gpio.c (patch 11) would not fit in
>> the current \-width (or whatever you'd call that line of backslashes to
>> the right in a multi-line macro).
>>
>> Does anyone have a strong opinion?
> 
> I have a strong opinion on making i2c.h less bloated. And yes, less
> number of lines is nice, too. I think that surely pays off the
> whitespace exception.

Ok, I have rebased onto v4.18-rc1, killed the i2c-tegra hunk and converted
i2c_lock_root(foo) over to i2c_lock_bus(foo, I2C_LOCK_ROOT_ADAPTER) and
i2c_lock_segment(foo) over to i2c_lock_bus(foo, I2C_LOCK_SEGMENT). And I
of course killed a bunch of locking helpers in i2c.h.

I doing build tests now, will post a v2 in the morning.

Cheers,
Peter

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [PATCH 01/11] i2c: add helpers for locking the I2C segment
@ 2018-06-19 21:29           ` Peter Rosin
  0 siblings, 0 replies; 63+ messages in thread
From: Peter Rosin @ 2018-06-19 21:29 UTC (permalink / raw)
  To: linux-arm-kernel

On 2018-06-18 13:54, Wolfram Sang wrote:
> 
>>> I wonder if i2c_lock_segment() and i2c_lock_root_adapter() are really
>>> more readable and convenient than i2c_lock_bus() with the flag. I think
>>> the flags have speaking names, too.
>>>
>>> Is that an idea to remove these functions altogether and start using
>>> i2c_lock_bus()?
>>
>> That would be fine with me. I don't have a strong opinion and agree that
>> both are readable enough...
>>
>> It would make for a reduction of the number of lines so that's nice, but
>> the macro in drivers/i2c/busses/i2c-gpio.c (patch 11) would not fit in
>> the current \-width (or whatever you'd call that line of backslashes to
>> the right in a multi-line macro).
>>
>> Does anyone have a strong opinion?
> 
> I have a strong opinion on making i2c.h less bloated. And yes, less
> number of lines is nice, too. I think that surely pays off the
> whitespace exception.

Ok, I have rebased onto v4.18-rc1, killed the i2c-tegra hunk and converted
i2c_lock_root(foo) over to i2c_lock_bus(foo, I2C_LOCK_ROOT_ADAPTER) and
i2c_lock_segment(foo) over to i2c_lock_bus(foo, I2C_LOCK_SEGMENT). And I
of course killed a bunch of locking helpers in i2c.h.

I doing build tests now, will post a v2 in the morning.

Cheers,
Peter

^ permalink raw reply	[flat|nested] 63+ messages in thread

end of thread, other threads:[~2018-06-19 21:30 UTC | newest]

Thread overview: 63+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-15 10:14 [PATCH 00/11] Split i2c_lock_adapter into i2c_lock_root and i2c_lock_segment Peter Rosin
2018-06-15 10:14 ` Peter Rosin
2018-06-15 10:14 ` Peter Rosin
2018-06-15 10:14 ` [PATCH 01/11] i2c: add helpers for locking the I2C segment Peter Rosin
2018-06-15 10:14   ` Peter Rosin
2018-06-15 10:14   ` Peter Rosin
2018-06-18 11:05   ` Wolfram Sang
2018-06-18 11:05     ` Wolfram Sang
2018-06-18 11:05     ` Wolfram Sang
2018-06-18 11:05     ` Wolfram Sang
2018-06-18 11:32     ` Peter Rosin
2018-06-18 11:32       ` Peter Rosin
2018-06-18 11:32       ` Peter Rosin
2018-06-18 11:54       ` Wolfram Sang
2018-06-18 11:54         ` Wolfram Sang
2018-06-18 11:54         ` Wolfram Sang
2018-06-18 11:54         ` Wolfram Sang
2018-06-19 21:29         ` Peter Rosin
2018-06-19 21:29           ` Peter Rosin
2018-06-19 21:29           ` Peter Rosin
2018-06-15 10:14 ` [PATCH 02/11] tpm/tpm_i2c_infineon: switch to i2c_lock_segment Peter Rosin
2018-06-15 10:14   ` Peter Rosin
2018-06-15 10:14   ` Peter Rosin
2018-06-19 12:56   ` Jarkko Sakkinen
2018-06-19 12:56     ` Jarkko Sakkinen
2018-06-19 12:56     ` Jarkko Sakkinen
2018-06-19 13:05     ` Peter Rosin
2018-06-19 13:05       ` Peter Rosin
2018-06-19 13:05       ` Peter Rosin
2018-06-15 10:14 ` [PATCH 03/11] i2c: mux: pca9541: " Peter Rosin
2018-06-15 10:14   ` Peter Rosin
2018-06-15 10:14   ` Peter Rosin
2018-06-15 10:14 ` [PATCH 04/11] input: rohm_bu21023: " Peter Rosin
2018-06-15 10:14   ` Peter Rosin
2018-06-15 10:14   ` Peter Rosin
2018-06-19 18:40   ` Dmitry Torokhov
2018-06-19 18:40     ` Dmitry Torokhov
2018-06-19 18:40     ` Dmitry Torokhov
2018-06-15 10:15 ` [PATCH 05/11] media: af9013: " Peter Rosin
2018-06-15 10:15   ` Peter Rosin
2018-06-15 10:15   ` Peter Rosin
2018-06-15 10:15 ` [PATCH 06/11] media: drxk_hard: " Peter Rosin
2018-06-15 10:15   ` Peter Rosin
2018-06-15 10:15   ` Peter Rosin
2018-06-15 10:15 ` [PATCH 07/11] media: rtl2830: " Peter Rosin
2018-06-15 10:15   ` Peter Rosin
2018-06-15 10:15   ` Peter Rosin
2018-06-15 10:15 ` [PATCH 08/11] media: tda1004x: " Peter Rosin
2018-06-15 10:15   ` Peter Rosin
2018-06-15 10:15   ` Peter Rosin
2018-06-15 10:15 ` [PATCH 09/11] media: tda18271: " Peter Rosin
2018-06-15 10:15   ` Peter Rosin
2018-06-15 10:15   ` Peter Rosin
2018-06-15 10:15 ` [PATCH 10/11] mfd: 88pm860x-i2c: " Peter Rosin
2018-06-15 10:15   ` Peter Rosin
2018-06-15 10:15   ` Peter Rosin
2018-06-15 10:15 ` [PATCH 11/11] i2c: rename i2c_lock_adapter to i2c_lock_root Peter Rosin
2018-06-15 10:15   ` Peter Rosin
2018-06-15 10:15   ` Peter Rosin
2018-06-18 11:06 ` [PATCH 00/11] Split i2c_lock_adapter into i2c_lock_root and i2c_lock_segment Wolfram Sang
2018-06-18 11:06   ` Wolfram Sang
2018-06-18 11:06   ` Wolfram Sang
2018-06-18 11:06   ` Wolfram Sang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.