summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/i2c/i2c.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/i2c/i2c.h b/include/i2c/i2c.h
index 33a4791c96..cf784ca1f1 100644
--- a/include/i2c/i2c.h
+++ b/include/i2c/i2c.h
@@ -194,6 +194,21 @@ extern s32 i2c_smbus_read_word_data(const struct i2c_client *client,
extern s32 i2c_smbus_write_word_data(const struct i2c_client *client,
u8 command, u16 value);
+static inline s32
+i2c_smbus_read_word_swapped(const struct i2c_client *client, u8 command)
+{
+ s32 value = i2c_smbus_read_word_data(client, command);
+
+ return (value < 0) ? value : swab16(value);
+}
+
+static inline s32
+i2c_smbus_write_word_swapped(const struct i2c_client *client,
+ u8 command, u16 value)
+{
+ return i2c_smbus_write_word_data(client, command, swab16(value));
+}
+
/* Returns the number of read bytes */
extern s32 i2c_smbus_read_i2c_block_data(const struct i2c_client *client,
u8 command, u8 length, u8 *values);