summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorPeter Rosin <peda@axentia.se>2016-06-29 15:04:03 +0200
committerWolfram Sang <wsa@the-dreams.de>2016-08-25 18:02:14 +0200
commitfb79e09a74faf39fbeee975e0ead442b7b7f6aac (patch)
tree465679257bdac8b169b5e5d20b17aabbd9859aef /include
parent00f0ea70d2b82b7d7afeb1bdedc9169eb8ea6675 (diff)
downloadlinux-stable-fb79e09a74faf39fbeee975e0ead442b7b7f6aac.tar.gz
linux-stable-fb79e09a74faf39fbeee975e0ead442b7b7f6aac.tar.bz2
linux-stable-fb79e09a74faf39fbeee975e0ead442b7b7f6aac.zip
i2c: add i2c_trylock_bus wrapper, use it
This unifies usage with i2c_lock_bus and i2c_unlock_bus, and paves the way for the next patch which looks a bit saner with this preparatory work taken care of beforehand. Signed-off-by: Peter Rosin <peda@axentia.se> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'include')
-rw-r--r--include/linux/i2c.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index fffdc270ca18..c1f60a345db7 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -601,6 +601,20 @@ i2c_lock_bus(struct i2c_adapter *adapter, unsigned int flags)
}
/**
+ * i2c_trylock_bus - Try to get exclusive access to an I2C bus segment
+ * @adapter: Target I2C bus segment
+ * @flags: I2C_LOCK_ROOT_ADAPTER tries to locks the root i2c adapter,
+ * I2C_LOCK_SEGMENT tries to lock only this branch in the adapter tree
+ *
+ * Return: true if the I2C bus segment is locked, false otherwise
+ */
+static inline int
+i2c_trylock_bus(struct i2c_adapter *adapter, unsigned int flags)
+{
+ return adapter->trylock_bus(adapter, flags);
+}
+
+/**
* i2c_unlock_bus - Release exclusive access to an I2C bus segment
* @adapter: Target I2C bus segment
* @flags: I2C_LOCK_ROOT_ADAPTER unlocks the root i2c adapter, I2C_LOCK_SEGMENT