diff options
-rw-r--r-- | drivers/usb/serial/mos7720.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index 763e32a44be0..e081dc0d21de 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c | |||
@@ -275,13 +275,11 @@ static void mos7720_bulk_out_data_callback(struct urb *urb) | |||
275 | * this function will be used for sending command to device | 275 | * this function will be used for sending command to device |
276 | */ | 276 | */ |
277 | static int send_mos_cmd(struct usb_serial *serial, __u8 request, __u16 value, | 277 | static int send_mos_cmd(struct usb_serial *serial, __u8 request, __u16 value, |
278 | __u16 index, void *data) | 278 | __u16 index, u8 *data) |
279 | { | 279 | { |
280 | int status; | 280 | int status; |
281 | unsigned int pipe; | 281 | u8 *buf; |
282 | u16 product = le16_to_cpu(serial->dev->descriptor.idProduct); | 282 | u16 product = le16_to_cpu(serial->dev->descriptor.idProduct); |
283 | __u8 requesttype; | ||
284 | __u16 size = 0x0000; | ||
285 | 283 | ||
286 | if (value < MOS_MAX_PORT) { | 284 | if (value < MOS_MAX_PORT) { |
287 | if (product == MOSCHIP_DEVICE_ID_7715) | 285 | if (product == MOSCHIP_DEVICE_ID_7715) |
@@ -298,21 +296,23 @@ static int send_mos_cmd(struct usb_serial *serial, __u8 request, __u16 value, | |||
298 | } | 296 | } |
299 | 297 | ||
300 | if (request == MOS_WRITE) { | 298 | if (request == MOS_WRITE) { |
301 | request = (__u8)MOS_WRITE; | 299 | value = value + *data; |
302 | requesttype = (__u8)0x40; | 300 | status = usb_control_msg(serial->dev, |
303 | value = value + (__u16)*((unsigned char *)data); | 301 | usb_sndctrlpipe(serial->dev, 0), MOS_WRITE, |
304 | data = NULL; | 302 | 0x40, value, index, NULL, 0, MOS_WDR_TIMEOUT); |
305 | pipe = usb_sndctrlpipe(serial->dev, 0); | ||
306 | } else { | 303 | } else { |
307 | request = (__u8)MOS_READ; | 304 | buf = kmalloc(1, GFP_KERNEL); |
308 | requesttype = (__u8)0xC0; | 305 | if (!buf) { |
309 | size = 0x01; | 306 | status = -ENOMEM; |
310 | pipe = usb_rcvctrlpipe(serial->dev, 0); | 307 | goto out; |
308 | } | ||
309 | status = usb_control_msg(serial->dev, | ||
310 | usb_rcvctrlpipe(serial->dev, 0), MOS_READ, | ||
311 | 0xc0, value, index, buf, 1, MOS_WDR_TIMEOUT); | ||
312 | *data = *buf; | ||
313 | kfree(buf); | ||
311 | } | 314 | } |
312 | 315 | out: | |
313 | status = usb_control_msg(serial->dev, pipe, request, requesttype, | ||
314 | value, index, data, size, MOS_WDR_TIMEOUT); | ||
315 | |||
316 | if (status < 0) | 316 | if (status < 0) |
317 | dbg("Command Write failed Value %x index %x\n", value, index); | 317 | dbg("Command Write failed Value %x index %x\n", value, index); |
318 | 318 | ||