i2c: Functions for byte-swapped smbus_write/read_word_data
[pandora-kernel.git] / include / linux / i2c.h
index f1e3ff5..38a21c3 100644 (file)
@@ -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);
@@ -409,7 +426,7 @@ void i2c_unlock_adapter(struct i2c_adapter *);
 /* i2c adapter classes (bitmask) */
 #define I2C_CLASS_HWMON                (1<<0)  /* lm_sensors, ... */
 #define I2C_CLASS_DDC          (1<<3)  /* DDC bus on graphics adapters */
-#define I2C_CLASS_SPD          (1<<7)  /* SPD EEPROMs and similar */
+#define I2C_CLASS_SPD          (1<<7)  /* Memory modules */
 
 /* Internal numbers to terminate lists */
 #define I2C_CLIENT_END         0xfffeU