File tree 2 files changed +25
-0
lines changed
2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,10 @@ byte. But this time, the data is a complete word (16 bits).
88
88
89
89
S Addr Wr [A] Comm [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P
90
90
91
+ Note the convenience function i2c_smbus_read_word_swapped is
92
+ available for reads where the two data bytes are the other way
93
+ around (not SMBus compliant, but very popular.)
94
+
91
95
92
96
SMBus Write Byte: i2c_smbus_write_byte_data()
93
97
==============================================
@@ -108,6 +112,10 @@ specified through the Comm byte.
108
112
109
113
S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] P
110
114
115
+ Note the convenience function i2c_smbus_write_word_swapped is
116
+ available for writes where the two data bytes are the other way
117
+ around (not SMBus compliant, but very popular.)
118
+
111
119
112
120
SMBus Process Call: i2c_smbus_process_call()
113
121
=============================================
Original file line number Diff line number Diff line change 34
34
#include <linux/sched.h> /* for completion */
35
35
#include <linux/mutex.h>
36
36
#include <linux/of.h> /* for struct device_node */
37
+ #include <linux/swab.h> /* for swab16 */
37
38
38
39
extern struct bus_type i2c_bus_type ;
39
40
extern struct device_type i2c_adapter_type ;
@@ -88,6 +89,22 @@ extern s32 i2c_smbus_read_word_data(const struct i2c_client *client,
88
89
u8 command );
89
90
extern s32 i2c_smbus_write_word_data (const struct i2c_client * client ,
90
91
u8 command , u16 value );
92
+
93
+ static inline s32
94
+ i2c_smbus_read_word_swapped (const struct i2c_client * client , u8 command )
95
+ {
96
+ s32 value = i2c_smbus_read_word_data (client , command );
97
+
98
+ return (value < 0 ) ? value : swab16 (value );
99
+ }
100
+
101
+ static inline s32
102
+ i2c_smbus_write_word_swapped (const struct i2c_client * client ,
103
+ u8 command , u16 value )
104
+ {
105
+ return i2c_smbus_write_word_data (client , command , swab16 (value ));
106
+ }
107
+
91
108
/* Returns the number of read bytes */
92
109
extern s32 i2c_smbus_read_block_data (const struct i2c_client * client ,
93
110
u8 command , u8 * values );
You can’t perform that action at this time.
0 commit comments