13
13
#include <linux/kernel.h>
14
14
#include <linux/errno.h>
15
15
#include <linux/module.h>
16
+ #include <linux/types.h>
16
17
17
18
/* include interfaces to usb layer */
18
19
#include <linux/usb.h>
31
32
#define CMD_I2C_IO_END (1<<1)
32
33
33
34
/* i2c bit delay, default is 10us -> 100kHz */
34
- static int delay = 10 ;
35
- module_param (delay , int , 0 );
35
+ static unsigned short delay = 10 ;
36
+ module_param (delay , ushort , 0 );
36
37
MODULE_PARM_DESC (delay , "bit delay in microseconds, "
37
38
"e.g. 10 for 100kHz (default is 100kHz)" );
38
39
@@ -109,7 +110,7 @@ static int usb_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num)
109
110
110
111
static u32 usb_func (struct i2c_adapter * adapter )
111
112
{
112
- u32 func ;
113
+ __le32 func ;
113
114
114
115
/* get functionality from adapter */
115
116
if (usb_read (adapter , CMD_GET_FUNC , 0 , 0 , & func , sizeof (func )) !=
@@ -118,7 +119,7 @@ static u32 usb_func(struct i2c_adapter *adapter)
118
119
return 0 ;
119
120
}
120
121
121
- return func ;
122
+ return le32_to_cpu ( func ) ;
122
123
}
123
124
124
125
/* This is the actual algorithm we define */
@@ -216,8 +217,7 @@ static int i2c_tiny_usb_probe(struct usb_interface *interface,
216
217
"i2c-tiny-usb at bus %03d device %03d" ,
217
218
dev -> usb_dev -> bus -> busnum , dev -> usb_dev -> devnum );
218
219
219
- if (usb_write (& dev -> adapter , CMD_SET_DELAY ,
220
- cpu_to_le16 (delay ), 0 , NULL , 0 ) != 0 ) {
220
+ if (usb_write (& dev -> adapter , CMD_SET_DELAY , delay , 0 , NULL , 0 ) != 0 ) {
221
221
dev_err (& dev -> adapter .dev ,
222
222
"failure setting delay to %dus\n" , delay );
223
223
retval = - EIO ;
0 commit comments