aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-10-30 15:54:59 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2011-10-30 15:54:59 -0700
commit839d8810747bbf39e0a5a7f223b67bffa7945f8d (patch)
treec16583342b871107f6805c21da4b1a96cfaa7aac /include
parentMerge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu (diff)
parenti2c: Functions for byte-swapped smbus_write/read_word_data (diff)
downloadlinux-dev-839d8810747bbf39e0a5a7f223b67bffa7945f8d.tar.xz
linux-dev-839d8810747bbf39e0a5a7f223b67bffa7945f8d.zip
Merge branch 'i2c-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging
* 'i2c-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging: i2c: Functions for byte-swapped smbus_write/read_word_data i2c-algo-pca: Return standard fault codes i2c-algo-bit: Return standard fault codes i2c-algo-bit: Be verbose on bus testing failure i2c-algo-bit: Let user test buses without failing i2c/scx200_acb: Fix section mismatch warning in scx200_pci_drv i2c: I2C_ELEKTOR should depend on HAS_IOPORT
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 @@
#include <linux/sched.h> /* for completion */
#include <linux/mutex.h>
#include <linux/of.h> /* for struct device_node */
+#include <linux/swab.h> /* for swab16 */
extern struct bus_type i2c_bus_type;
extern struct device_type i2c_adapter_type;
@@ -88,6 +89,22 @@ extern s32 i2c_smbus_read_word_data(const struct i2c_client *client,
u8 command);
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_block_data(const struct i2c_client *client,
u8 command, u8 *values);