aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses/i2c-diolan-u2c.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/busses/i2c-diolan-u2c.c')
-rw-r--r--drivers/i2c/busses/i2c-diolan-u2c.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/drivers/i2c/busses/i2c-diolan-u2c.c b/drivers/i2c/busses/i2c-diolan-u2c.c
index dae3ddfe7619..721f7ebf9a3b 100644
--- a/drivers/i2c/busses/i2c-diolan-u2c.c
+++ b/drivers/i2c/busses/i2c-diolan-u2c.c
@@ -25,8 +25,6 @@
25#define USB_VENDOR_ID_DIOLAN 0x0abf 25#define USB_VENDOR_ID_DIOLAN 0x0abf
26#define USB_DEVICE_ID_DIOLAN_U2C 0x3370 26#define USB_DEVICE_ID_DIOLAN_U2C 0x3370
27 27
28#define DIOLAN_OUT_EP 0x02
29#define DIOLAN_IN_EP 0x84
30 28
31/* commands via USB, must match command ids in the firmware */ 29/* commands via USB, must match command ids in the firmware */
32#define CMD_I2C_READ 0x01 30#define CMD_I2C_READ 0x01
@@ -84,6 +82,7 @@
84struct i2c_diolan_u2c { 82struct i2c_diolan_u2c {
85 u8 obuffer[DIOLAN_OUTBUF_LEN]; /* output buffer */ 83 u8 obuffer[DIOLAN_OUTBUF_LEN]; /* output buffer */
86 u8 ibuffer[DIOLAN_INBUF_LEN]; /* input buffer */ 84 u8 ibuffer[DIOLAN_INBUF_LEN]; /* input buffer */
85 int ep_in, ep_out; /* Endpoints */
87 struct usb_device *usb_dev; /* the usb device for this device */ 86 struct usb_device *usb_dev; /* the usb device for this device */
88 struct usb_interface *interface;/* the interface for this device */ 87 struct usb_interface *interface;/* the interface for this device */
89 struct i2c_adapter adapter; /* i2c related things */ 88 struct i2c_adapter adapter; /* i2c related things */
@@ -109,7 +108,7 @@ static int diolan_usb_transfer(struct i2c_diolan_u2c *dev)
109 return -EINVAL; 108 return -EINVAL;
110 109
111 ret = usb_bulk_msg(dev->usb_dev, 110 ret = usb_bulk_msg(dev->usb_dev,
112 usb_sndbulkpipe(dev->usb_dev, DIOLAN_OUT_EP), 111 usb_sndbulkpipe(dev->usb_dev, dev->ep_out),
113 dev->obuffer, dev->olen, &actual, 112 dev->obuffer, dev->olen, &actual,
114 DIOLAN_USB_TIMEOUT); 113 DIOLAN_USB_TIMEOUT);
115 if (!ret) { 114 if (!ret) {
@@ -118,7 +117,7 @@ static int diolan_usb_transfer(struct i2c_diolan_u2c *dev)
118 117
119 tmpret = usb_bulk_msg(dev->usb_dev, 118 tmpret = usb_bulk_msg(dev->usb_dev,
120 usb_rcvbulkpipe(dev->usb_dev, 119 usb_rcvbulkpipe(dev->usb_dev,
121 DIOLAN_IN_EP), 120 dev->ep_in),
122 dev->ibuffer, 121 dev->ibuffer,
123 sizeof(dev->ibuffer), &actual, 122 sizeof(dev->ibuffer), &actual,
124 DIOLAN_USB_TIMEOUT); 123 DIOLAN_USB_TIMEOUT);
@@ -210,7 +209,7 @@ static void diolan_flush_input(struct i2c_diolan_u2c *dev)
210 int ret; 209 int ret;
211 210
212 ret = usb_bulk_msg(dev->usb_dev, 211 ret = usb_bulk_msg(dev->usb_dev,
213 usb_rcvbulkpipe(dev->usb_dev, DIOLAN_IN_EP), 212 usb_rcvbulkpipe(dev->usb_dev, dev->ep_in),
214 dev->ibuffer, sizeof(dev->ibuffer), &actual, 213 dev->ibuffer, sizeof(dev->ibuffer), &actual,
215 DIOLAN_USB_TIMEOUT); 214 DIOLAN_USB_TIMEOUT);
216 if (ret < 0 || actual == 0) 215 if (ret < 0 || actual == 0)
@@ -445,9 +444,14 @@ static void diolan_u2c_free(struct i2c_diolan_u2c *dev)
445static int diolan_u2c_probe(struct usb_interface *interface, 444static int diolan_u2c_probe(struct usb_interface *interface,
446 const struct usb_device_id *id) 445 const struct usb_device_id *id)
447{ 446{
447 struct usb_host_interface *hostif = interface->cur_altsetting;
448 struct i2c_diolan_u2c *dev; 448 struct i2c_diolan_u2c *dev;
449 int ret; 449 int ret;
450 450
451 if (hostif->desc.bInterfaceNumber != 0
452 || hostif->desc.bNumEndpoints < 2)
453 return -ENODEV;
454
451 /* allocate memory for our device state and initialize it */ 455 /* allocate memory for our device state and initialize it */
452 dev = kzalloc(sizeof(*dev), GFP_KERNEL); 456 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
453 if (dev == NULL) { 457 if (dev == NULL) {
@@ -455,6 +459,8 @@ static int diolan_u2c_probe(struct usb_interface *interface,
455 ret = -ENOMEM; 459 ret = -ENOMEM;
456 goto error; 460 goto error;
457 } 461 }
462 dev->ep_out = hostif->endpoint[0].desc.bEndpointAddress;
463 dev->ep_in = hostif->endpoint[1].desc.bEndpointAddress;
458 464
459 dev->usb_dev = usb_get_dev(interface_to_usbdev(interface)); 465 dev->usb_dev = usb_get_dev(interface_to_usbdev(interface));
460 dev->interface = interface; 466 dev->interface = interface;