X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=include%2Flinux%2Fi2c.h;h=a81bf6d23b3e6ad62333696032e0b49317115667;hb=fe8a0df46e5076429872887b467c538bc9c0c738;hp=a6c652ef516d559dc405cefe5607d08772436e63;hpb=3210d190dcb717c328d74f8c3f69ec717d665b40;p=pandora-kernel.git diff --git a/include/linux/i2c.h b/include/linux/i2c.h index a6c652ef516d..a81bf6d23b3e 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -28,12 +28,12 @@ #include #ifdef __KERNEL__ -#include #include #include /* for struct device */ #include /* for completion */ #include #include /* for struct device_node */ +#include /* for swab16 */ extern struct bus_type i2c_bus_type; extern struct device_type i2c_adapter_type; @@ -48,6 +48,8 @@ struct i2c_driver; union i2c_smbus_data; struct i2c_board_info; +struct module; + #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) /* * The master routines are the ones normally used to transmit data to devices @@ -88,6 +90,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); @@ -434,10 +452,9 @@ extern int i2c_add_numbered_adapter(struct i2c_adapter *); extern int i2c_register_driver(struct module *, struct i2c_driver *); extern void i2c_del_driver(struct i2c_driver *); -static inline int i2c_add_driver(struct i2c_driver *driver) -{ - return i2c_register_driver(THIS_MODULE, driver); -} +/* use a define to avoid include chaining to get THIS_MODULE */ +#define i2c_add_driver(driver) \ + i2c_register_driver(THIS_MODULE, driver) extern struct i2c_client *i2c_use_client(struct i2c_client *client); extern void i2c_release_client(struct i2c_client *client);