diff options
Diffstat (limited to 'drivers/i2c/busses/i2c-tiny-usb.c')
-rw-r--r-- | drivers/i2c/busses/i2c-tiny-usb.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/drivers/i2c/busses/i2c-tiny-usb.c b/drivers/i2c/busses/i2c-tiny-usb.c index b1c050ff311d..d03b04002f0d 100644 --- a/drivers/i2c/busses/i2c-tiny-usb.c +++ b/drivers/i2c/busses/i2c-tiny-usb.c | |||
@@ -13,6 +13,8 @@ | |||
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #include <linux/errno.h> | 14 | #include <linux/errno.h> |
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/slab.h> | ||
17 | #include <linux/types.h> | ||
16 | 18 | ||
17 | /* include interfaces to usb layer */ | 19 | /* include interfaces to usb layer */ |
18 | #include <linux/usb.h> | 20 | #include <linux/usb.h> |
@@ -30,11 +32,13 @@ | |||
30 | #define CMD_I2C_IO_BEGIN (1<<0) | 32 | #define CMD_I2C_IO_BEGIN (1<<0) |
31 | #define CMD_I2C_IO_END (1<<1) | 33 | #define CMD_I2C_IO_END (1<<1) |
32 | 34 | ||
33 | /* i2c bit delay, default is 10us -> 100kHz */ | 35 | /* i2c bit delay, default is 10us -> 100kHz max |
34 | static int delay = 10; | 36 | (in practice, due to additional delays in the i2c bitbanging |
35 | module_param(delay, int, 0); | 37 | code this results in a i2c clock of about 50kHz) */ |
36 | MODULE_PARM_DESC(delay, "bit delay in microseconds, " | 38 | static unsigned short delay = 10; |
37 | "e.g. 10 for 100kHz (default is 100kHz)"); | 39 | module_param(delay, ushort, 0); |
40 | MODULE_PARM_DESC(delay, "bit delay in microseconds " | ||
41 | "(default is 10us for 100kHz max)"); | ||
38 | 42 | ||
39 | static int usb_read(struct i2c_adapter *adapter, int cmd, | 43 | static int usb_read(struct i2c_adapter *adapter, int cmd, |
40 | int value, int index, void *data, int len); | 44 | int value, int index, void *data, int len); |
@@ -109,7 +113,7 @@ static int usb_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num) | |||
109 | 113 | ||
110 | static u32 usb_func(struct i2c_adapter *adapter) | 114 | static u32 usb_func(struct i2c_adapter *adapter) |
111 | { | 115 | { |
112 | u32 func; | 116 | __le32 func; |
113 | 117 | ||
114 | /* get functionality from adapter */ | 118 | /* get functionality from adapter */ |
115 | if (usb_read(adapter, CMD_GET_FUNC, 0, 0, &func, sizeof(func)) != | 119 | if (usb_read(adapter, CMD_GET_FUNC, 0, 0, &func, sizeof(func)) != |
@@ -118,7 +122,7 @@ static u32 usb_func(struct i2c_adapter *adapter) | |||
118 | return 0; | 122 | return 0; |
119 | } | 123 | } |
120 | 124 | ||
121 | return func; | 125 | return le32_to_cpu(func); |
122 | } | 126 | } |
123 | 127 | ||
124 | /* This is the actual algorithm we define */ | 128 | /* This is the actual algorithm we define */ |
@@ -136,7 +140,7 @@ static const struct i2c_algorithm usb_algorithm = { | |||
136 | * Future Technology Devices International Ltd., later a pair was | 140 | * Future Technology Devices International Ltd., later a pair was |
137 | * bought from EZPrototypes | 141 | * bought from EZPrototypes |
138 | */ | 142 | */ |
139 | static struct usb_device_id i2c_tiny_usb_table [] = { | 143 | static const struct usb_device_id i2c_tiny_usb_table[] = { |
140 | { USB_DEVICE(0x0403, 0xc631) }, /* FTDI */ | 144 | { USB_DEVICE(0x0403, 0xc631) }, /* FTDI */ |
141 | { USB_DEVICE(0x1c40, 0x0534) }, /* EZPrototypes */ | 145 | { USB_DEVICE(0x1c40, 0x0534) }, /* EZPrototypes */ |
142 | { } /* Terminating entry */ | 146 | { } /* Terminating entry */ |
@@ -216,8 +220,7 @@ static int i2c_tiny_usb_probe(struct usb_interface *interface, | |||
216 | "i2c-tiny-usb at bus %03d device %03d", | 220 | "i2c-tiny-usb at bus %03d device %03d", |
217 | dev->usb_dev->bus->busnum, dev->usb_dev->devnum); | 221 | dev->usb_dev->bus->busnum, dev->usb_dev->devnum); |
218 | 222 | ||
219 | if (usb_write(&dev->adapter, CMD_SET_DELAY, | 223 | if (usb_write(&dev->adapter, CMD_SET_DELAY, delay, 0, NULL, 0) != 0) { |
220 | cpu_to_le16(delay), 0, NULL, 0) != 0) { | ||
221 | dev_err(&dev->adapter.dev, | 224 | dev_err(&dev->adapter.dev, |
222 | "failure setting delay to %dus\n", delay); | 225 | "failure setting delay to %dus\n", delay); |
223 | retval = -EIO; | 226 | retval = -EIO; |