diff options
author | Jean Delvare <khali@linux-fr.org> | 2009-11-07 13:10:46 +0100 |
---|---|---|
committer | Jean Delvare <khali@linux-fr.org> | 2009-11-07 13:10:46 +0100 |
commit | afa08974fe80c198b8650f73ed8ab59135ca10d0 (patch) | |
tree | b649e06dc4cb9fa10b87f1914f05c6ca2ba0d910 /include/linux/i2c.h | |
parent | 3806e94b0148350c72f9a3214274026b6ca03f49 (diff) | |
download | linux-3.10-afa08974fe80c198b8650f73ed8ab59135ca10d0.tar.gz linux-3.10-afa08974fe80c198b8650f73ed8ab59135ca10d0.tar.bz2 linux-3.10-afa08974fe80c198b8650f73ed8ab59135ca10d0.zip |
i2c: Add an interface to lock/unlock an I2C bus segment
Some drivers need to be able to prevent access to an I2C bus segment
for a specific period of time. Add an interface for them to do so
without twiddling with i2c-core internals.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Ben Hutchings <bhutchings@solarflare.com>
Diffstat (limited to 'include/linux/i2c.h')
-rw-r--r-- | include/linux/i2c.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 57d41b0abce..7b40cda57a7 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -361,6 +361,24 @@ static inline void i2c_set_adapdata(struct i2c_adapter *dev, void *data) dev_set_drvdata(&dev->dev, data); } +/** + * i2c_lock_adapter - Prevent access to an I2C bus segment + * @adapter: Target I2C bus segment + */ +static inline void i2c_lock_adapter(struct i2c_adapter *adapter) +{ + mutex_lock(&adapter->bus_lock); +} + +/** + * i2c_unlock_adapter - Reauthorize access to an I2C bus segment + * @adapter: Target I2C bus segment + */ +static inline void i2c_unlock_adapter(struct i2c_adapter *adapter) +{ + mutex_unlock(&adapter->bus_lock); +} + /*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 */ |