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>
This commit is contained in:
Peter Rosin 2016-06-29 15:04:03 +02:00 committed by Wolfram Sang
parent 00f0ea70d2
commit fb79e09a74
3 changed files with 17 additions and 3 deletions

View file

@ -600,6 +600,20 @@ i2c_lock_bus(struct i2c_adapter *adapter, unsigned int flags)
adapter->lock_bus(adapter, 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