diff options
Diffstat (limited to 'include/linux/i2c.h')
-rw-r--r-- | include/linux/i2c.h | 27 |
1 files changed, 22 insertions, 5 deletions
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 @@ | |||
28 | 28 | ||
29 | #include <linux/types.h> | 29 | #include <linux/types.h> |
30 | #ifdef __KERNEL__ | 30 | #ifdef __KERNEL__ |
31 | #include <linux/module.h> | ||
32 | #include <linux/mod_devicetable.h> | 31 | #include <linux/mod_devicetable.h> |
33 | #include <linux/device.h> /* for struct device */ | 32 | #include <linux/device.h> /* for struct device */ |
34 | #include <linux/sched.h> /* for completion */ | 33 | #include <linux/sched.h> /* for completion */ |
35 | #include <linux/mutex.h> | 34 | #include <linux/mutex.h> |
36 | #include <linux/of.h> /* for struct device_node */ | 35 | #include <linux/of.h> /* for struct device_node */ |
36 | #include <linux/swab.h> /* for swab16 */ | ||
37 | 37 | ||
38 | extern struct bus_type i2c_bus_type; | 38 | extern struct bus_type i2c_bus_type; |
39 | extern struct device_type i2c_adapter_type; | 39 | extern struct device_type i2c_adapter_type; |
@@ -48,6 +48,8 @@ struct i2c_driver; | |||
48 | union i2c_smbus_data; | 48 | union i2c_smbus_data; |
49 | struct i2c_board_info; | 49 | struct i2c_board_info; |
50 | 50 | ||
51 | struct module; | ||
52 | |||
51 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 53 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) |
52 | /* | 54 | /* |
53 | * The master routines are the ones normally used to transmit data to devices | 55 | * 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, | |||
88 | u8 command); | 90 | u8 command); |
89 | extern s32 i2c_smbus_write_word_data(const struct i2c_client *client, | 91 | extern s32 i2c_smbus_write_word_data(const struct i2c_client *client, |
90 | u8 command, u16 value); | 92 | u8 command, u16 value); |
93 | |||
94 | static inline s32 | ||
95 | i2c_smbus_read_word_swapped(const struct i2c_client *client, u8 command) | ||
96 | { | ||
97 | s32 value = i2c_smbus_read_word_data(client, command); | ||
98 | |||
99 | return (value < 0) ? value : swab16(value); | ||
100 | } | ||
101 | |||
102 | static inline s32 | ||
103 | i2c_smbus_write_word_swapped(const struct i2c_client *client, | ||
104 | u8 command, u16 value) | ||
105 | { | ||
106 | return i2c_smbus_write_word_data(client, command, swab16(value)); | ||
107 | } | ||
108 | |||
91 | /* Returns the number of read bytes */ | 109 | /* Returns the number of read bytes */ |
92 | extern s32 i2c_smbus_read_block_data(const struct i2c_client *client, | 110 | extern s32 i2c_smbus_read_block_data(const struct i2c_client *client, |
93 | u8 command, u8 *values); | 111 | u8 command, u8 *values); |
@@ -434,10 +452,9 @@ extern int i2c_add_numbered_adapter(struct i2c_adapter *); | |||
434 | extern int i2c_register_driver(struct module *, struct i2c_driver *); | 452 | extern int i2c_register_driver(struct module *, struct i2c_driver *); |
435 | extern void i2c_del_driver(struct i2c_driver *); | 453 | extern void i2c_del_driver(struct i2c_driver *); |
436 | 454 | ||
437 | static inline int i2c_add_driver(struct i2c_driver *driver) | 455 | /* use a define to avoid include chaining to get THIS_MODULE */ |
438 | { | 456 | #define i2c_add_driver(driver) \ |
439 | return i2c_register_driver(THIS_MODULE, driver); | 457 | i2c_register_driver(THIS_MODULE, driver) |
440 | } | ||
441 | 458 | ||
442 | extern struct i2c_client *i2c_use_client(struct i2c_client *client); | 459 | extern struct i2c_client *i2c_use_client(struct i2c_client *client); |
443 | extern void i2c_release_client(struct i2c_client *client); | 460 | extern void i2c_release_client(struct i2c_client *client); |