aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/linux/i2c.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index a6c652ef516d..38a21c3edd2c 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -34,6 +34,7 @@
34#include <linux/sched.h> /* for completion */ 34#include <linux/sched.h> /* for completion */
35#include <linux/mutex.h> 35#include <linux/mutex.h>
36#include <linux/of.h> /* for struct device_node */ 36#include <linux/of.h> /* for struct device_node */
37#include <linux/swab.h> /* for swab16 */
37 38
38extern struct bus_type i2c_bus_type; 39extern struct bus_type i2c_bus_type;
39extern struct device_type i2c_adapter_type; 40extern struct device_type i2c_adapter_type;
@@ -88,6 +89,22 @@ extern s32 i2c_smbus_read_word_data(const struct i2c_client *client,
88 u8 command); 89 u8 command);
89extern s32 i2c_smbus_write_word_data(const struct i2c_client *client, 90extern s32 i2c_smbus_write_word_data(const struct i2c_client *client,
90 u8 command, u16 value); 91 u8 command, u16 value);
92
93static inline s32
94i2c_smbus_read_word_swapped(const struct i2c_client *client, u8 command)
95{
96 s32 value = i2c_smbus_read_word_data(client, command);
97
98 return (value < 0) ? value : swab16(value);
99}
100
101static inline s32
102i2c_smbus_write_word_swapped(const struct i2c_client *client,
103 u8 command, u16 value)
104{
105 return i2c_smbus_write_word_data(client, command, swab16(value));
106}
107
91/* Returns the number of read bytes */ 108/* Returns the number of read bytes */
92extern s32 i2c_smbus_read_block_data(const struct i2c_client *client, 109extern s32 i2c_smbus_read_block_data(const struct i2c_client *client,
93 u8 command, u8 *values); 110 u8 command, u8 *values);