diff options
Diffstat (limited to 'drivers/usb/serial/mos7720.c')
-rw-r--r-- | drivers/usb/serial/mos7720.c | 308 |
1 files changed, 148 insertions, 160 deletions
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index 50f1fe263338..7c4917d77c0a 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <linux/serial_reg.h> | 33 | #include <linux/serial_reg.h> |
34 | #include <linux/usb.h> | 34 | #include <linux/usb.h> |
35 | #include <linux/usb/serial.h> | 35 | #include <linux/usb/serial.h> |
36 | #include <asm/uaccess.h> | 36 | #include <linux/uaccess.h> |
37 | 37 | ||
38 | 38 | ||
39 | /* | 39 | /* |
@@ -64,8 +64,7 @@ | |||
64 | #define URB_TRANSFER_BUFFER_SIZE 32 /* URB Size */ | 64 | #define URB_TRANSFER_BUFFER_SIZE 32 /* URB Size */ |
65 | 65 | ||
66 | /* This structure holds all of the local port information */ | 66 | /* This structure holds all of the local port information */ |
67 | struct moschip_port | 67 | struct moschip_port { |
68 | { | ||
69 | __u8 shadowLCR; /* last LCR value received */ | 68 | __u8 shadowLCR; /* last LCR value received */ |
70 | __u8 shadowMCR; /* last MCR value received */ | 69 | __u8 shadowMCR; /* last MCR value received */ |
71 | __u8 shadowMSR; /* last MSR value received */ | 70 | __u8 shadowMSR; /* last MSR value received */ |
@@ -76,8 +75,7 @@ struct moschip_port | |||
76 | }; | 75 | }; |
77 | 76 | ||
78 | /* This structure holds all of the individual serial device information */ | 77 | /* This structure holds all of the individual serial device information */ |
79 | struct moschip_serial | 78 | struct moschip_serial { |
80 | { | ||
81 | int interrupt_started; | 79 | int interrupt_started; |
82 | }; | 80 | }; |
83 | 81 | ||
@@ -88,7 +86,7 @@ static int debug; | |||
88 | #define MOSCHIP_DEVICE_ID_7715 0x7715 | 86 | #define MOSCHIP_DEVICE_ID_7715 0x7715 |
89 | 87 | ||
90 | static struct usb_device_id moschip_port_id_table [] = { | 88 | static struct usb_device_id moschip_port_id_table [] = { |
91 | { USB_DEVICE(USB_VENDOR_ID_MOSCHIP,MOSCHIP_DEVICE_ID_7720) }, | 89 | { USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7720) }, |
92 | { } /* terminating entry */ | 90 | { } /* terminating entry */ |
93 | }; | 91 | }; |
94 | MODULE_DEVICE_TABLE(usb, moschip_port_id_table); | 92 | MODULE_DEVICE_TABLE(usb, moschip_port_id_table); |
@@ -108,7 +106,7 @@ static void mos7720_interrupt_callback(struct urb *urb) | |||
108 | __u8 sp1; | 106 | __u8 sp1; |
109 | __u8 sp2; | 107 | __u8 sp2; |
110 | 108 | ||
111 | dbg("%s"," : Entering\n"); | 109 | dbg("%s", " : Entering\n"); |
112 | 110 | ||
113 | switch (status) { | 111 | switch (status) { |
114 | case 0: | 112 | case 0: |
@@ -208,7 +206,7 @@ static void mos7720_bulk_in_callback(struct urb *urb) | |||
208 | 206 | ||
209 | mos7720_port = urb->context; | 207 | mos7720_port = urb->context; |
210 | if (!mos7720_port) { | 208 | if (!mos7720_port) { |
211 | dbg("%s","NULL mos7720_port pointer \n"); | 209 | dbg("%s", "NULL mos7720_port pointer \n"); |
212 | return ; | 210 | return ; |
213 | } | 211 | } |
214 | 212 | ||
@@ -218,7 +216,7 @@ static void mos7720_bulk_in_callback(struct urb *urb) | |||
218 | 216 | ||
219 | data = urb->transfer_buffer; | 217 | data = urb->transfer_buffer; |
220 | 218 | ||
221 | tty = port->tty; | 219 | tty = port->port.tty; |
222 | if (tty && urb->actual_length) { | 220 | if (tty && urb->actual_length) { |
223 | tty_buffer_request_room(tty, urb->actual_length); | 221 | tty_buffer_request_room(tty, urb->actual_length); |
224 | tty_insert_flip_string(tty, data, urb->actual_length); | 222 | tty_insert_flip_string(tty, data, urb->actual_length); |
@@ -264,7 +262,7 @@ static void mos7720_bulk_out_data_callback(struct urb *urb) | |||
264 | 262 | ||
265 | dbg("Entering ........."); | 263 | dbg("Entering ........."); |
266 | 264 | ||
267 | tty = mos7720_port->port->tty; | 265 | tty = mos7720_port->port->port.tty; |
268 | 266 | ||
269 | if (tty && mos7720_port->open) | 267 | if (tty && mos7720_port->open) |
270 | tty_wakeup(tty); | 268 | tty_wakeup(tty); |
@@ -284,17 +282,16 @@ static int send_mos_cmd(struct usb_serial *serial, __u8 request, __u16 value, | |||
284 | __u16 size = 0x0000; | 282 | __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) |
288 | value = value*0x100+0x100; | 286 | value = value*0x100+0x100; |
289 | } else { | 287 | else |
290 | value = value*0x100+0x200; | 288 | value = value*0x100+0x200; |
291 | } | ||
292 | } else { | 289 | } else { |
293 | value = 0x0000; | 290 | value = 0x0000; |
294 | if ((product == MOSCHIP_DEVICE_ID_7715) && | 291 | if ((product == MOSCHIP_DEVICE_ID_7715) && |
295 | (index != 0x08)) { | 292 | (index != 0x08)) { |
296 | dbg("serial->product== MOSCHIP_DEVICE_ID_7715"); | 293 | dbg("serial->product== MOSCHIP_DEVICE_ID_7715"); |
297 | //index = 0x01 ; | 294 | /* index = 0x01 ; */ |
298 | } | 295 | } |
299 | } | 296 | } |
300 | 297 | ||
@@ -308,19 +305,20 @@ static int send_mos_cmd(struct usb_serial *serial, __u8 request, __u16 value, | |||
308 | request = (__u8)MOS_READ; | 305 | request = (__u8)MOS_READ; |
309 | requesttype = (__u8)0xC0; | 306 | requesttype = (__u8)0xC0; |
310 | size = 0x01; | 307 | size = 0x01; |
311 | pipe = usb_rcvctrlpipe(serial->dev,0); | 308 | pipe = usb_rcvctrlpipe(serial->dev, 0); |
312 | } | 309 | } |
313 | 310 | ||
314 | status = usb_control_msg(serial->dev, pipe, request, requesttype, | 311 | status = usb_control_msg(serial->dev, pipe, request, requesttype, |
315 | value, index, data, size, MOS_WDR_TIMEOUT); | 312 | value, index, data, size, MOS_WDR_TIMEOUT); |
316 | 313 | ||
317 | if (status < 0) | 314 | if (status < 0) |
318 | dbg("Command Write failed Value %x index %x\n",value,index); | 315 | dbg("Command Write failed Value %x index %x\n", value, index); |
319 | 316 | ||
320 | return status; | 317 | return status; |
321 | } | 318 | } |
322 | 319 | ||
323 | static int mos7720_open(struct usb_serial_port *port, struct file * filp) | 320 | static int mos7720_open(struct tty_struct *tty, |
321 | struct usb_serial_port *port, struct file *filp) | ||
324 | { | 322 | { |
325 | struct usb_serial *serial; | 323 | struct usb_serial *serial; |
326 | struct usb_serial_port *port0; | 324 | struct usb_serial_port *port0; |
@@ -351,7 +349,7 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp) | |||
351 | 349 | ||
352 | /* Initialising the write urb pool */ | 350 | /* Initialising the write urb pool */ |
353 | for (j = 0; j < NUM_URBS; ++j) { | 351 | for (j = 0; j < NUM_URBS; ++j) { |
354 | urb = usb_alloc_urb(0,GFP_KERNEL); | 352 | urb = usb_alloc_urb(0, GFP_KERNEL); |
355 | mos7720_port->write_urb_pool[j] = urb; | 353 | mos7720_port->write_urb_pool[j] = urb; |
356 | 354 | ||
357 | if (urb == NULL) { | 355 | if (urb == NULL) { |
@@ -385,7 +383,7 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp) | |||
385 | */ | 383 | */ |
386 | port_number = port->number - port->serial->minor; | 384 | port_number = port->number - port->serial->minor; |
387 | send_mos_cmd(port->serial, MOS_READ, port_number, UART_LSR, &data); | 385 | send_mos_cmd(port->serial, MOS_READ, port_number, UART_LSR, &data); |
388 | dbg("SS::%p LSR:%x\n",mos7720_port, data); | 386 | dbg("SS::%p LSR:%x\n", mos7720_port, data); |
389 | 387 | ||
390 | dbg("Check:Sending Command .........."); | 388 | dbg("Check:Sending Command .........."); |
391 | 389 | ||
@@ -402,10 +400,10 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp) | |||
402 | data = 0xCF; | 400 | data = 0xCF; |
403 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x02, &data); | 401 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x02, &data); |
404 | data = 0x03; | 402 | data = 0x03; |
405 | mos7720_port->shadowLCR = data; | 403 | mos7720_port->shadowLCR = data; |
406 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data); | 404 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data); |
407 | data = 0x0b; | 405 | data = 0x0b; |
408 | mos7720_port->shadowMCR = data; | 406 | mos7720_port->shadowMCR = data; |
409 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); | 407 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); |
410 | data = 0x0b; | 408 | data = 0x0b; |
411 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); | 409 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); |
@@ -420,7 +418,8 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp) | |||
420 | data = 0x03; | 418 | data = 0x03; |
421 | send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, port_number + 1, &data); | 419 | send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, port_number + 1, &data); |
422 | data = 0x00; | 420 | data = 0x00; |
423 | send_mos_cmd(port->serial, MOS_WRITE, MOS_MAX_PORT, port_number + 1, &data); | 421 | send_mos_cmd(port->serial, MOS_WRITE, MOS_MAX_PORT, |
422 | port_number + 1, &data); | ||
424 | */ | 423 | */ |
425 | data = 0x00; | 424 | data = 0x00; |
426 | send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, 0x08, &data); | 425 | send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, 0x08, &data); |
@@ -429,28 +428,26 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp) | |||
429 | send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data); | 428 | send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data); |
430 | 429 | ||
431 | data = 0x83; | 430 | data = 0x83; |
432 | mos7720_port->shadowLCR = data; | 431 | mos7720_port->shadowLCR = data; |
433 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data); | 432 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data); |
434 | data = 0x0c; | 433 | data = 0x0c; |
435 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x00, &data); | 434 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x00, &data); |
436 | data = 0x00; | 435 | data = 0x00; |
437 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data); | 436 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data); |
438 | data = 0x03; | 437 | data = 0x03; |
439 | mos7720_port->shadowLCR = data; | 438 | mos7720_port->shadowLCR = data; |
440 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data); | 439 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data); |
441 | data = 0x0c; | 440 | data = 0x0c; |
442 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data); | 441 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data); |
443 | data = 0x0c; | 442 | data = 0x0c; |
444 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data); | 443 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data); |
445 | 444 | ||
446 | //Matrix | ||
447 | |||
448 | /* force low_latency on so that our tty_push actually forces * | 445 | /* force low_latency on so that our tty_push actually forces * |
449 | * the data through,otherwise it is scheduled, and with * | 446 | * the data through,otherwise it is scheduled, and with * |
450 | * high data rates (like with OHCI) data can get lost. */ | 447 | * high data rates (like with OHCI) data can get lost. */ |
451 | 448 | ||
452 | if (port->tty) | 449 | if (tty) |
453 | port->tty->low_latency = 1; | 450 | tty->low_latency = 1; |
454 | 451 | ||
455 | /* see if we've set up our endpoint info yet * | 452 | /* see if we've set up our endpoint info yet * |
456 | * (can't set it up in mos7720_startup as the * | 453 | * (can't set it up in mos7720_startup as the * |
@@ -465,15 +462,15 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp) | |||
465 | 462 | ||
466 | /* set up our interrupt urb */ | 463 | /* set up our interrupt urb */ |
467 | usb_fill_int_urb(port0->interrupt_in_urb, serial->dev, | 464 | usb_fill_int_urb(port0->interrupt_in_urb, serial->dev, |
468 | usb_rcvintpipe(serial->dev, | 465 | usb_rcvintpipe(serial->dev, |
469 | port->interrupt_in_endpointAddress), | 466 | port->interrupt_in_endpointAddress), |
470 | port0->interrupt_in_buffer, | 467 | port0->interrupt_in_buffer, |
471 | port0->interrupt_in_urb->transfer_buffer_length, | 468 | port0->interrupt_in_urb->transfer_buffer_length, |
472 | mos7720_interrupt_callback, mos7720_port, | 469 | mos7720_interrupt_callback, mos7720_port, |
473 | port0->interrupt_in_urb->interval); | 470 | port0->interrupt_in_urb->interval); |
474 | 471 | ||
475 | /* start interrupt read for this mos7720 this interrupt * | 472 | /* start interrupt read for this mos7720 this interrupt * |
476 | * will continue as long as the mos7720 is connected */ | 473 | * will continue as long as the mos7720 is connected */ |
477 | dbg("Submit URB over !!!"); | 474 | dbg("Submit URB over !!!"); |
478 | response = usb_submit_urb(port0->interrupt_in_urb, GFP_KERNEL); | 475 | response = usb_submit_urb(port0->interrupt_in_urb, GFP_KERNEL); |
479 | if (response) | 476 | if (response) |
@@ -485,14 +482,14 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp) | |||
485 | /* set up our bulk in urb */ | 482 | /* set up our bulk in urb */ |
486 | usb_fill_bulk_urb(port->read_urb, serial->dev, | 483 | usb_fill_bulk_urb(port->read_urb, serial->dev, |
487 | usb_rcvbulkpipe(serial->dev, | 484 | usb_rcvbulkpipe(serial->dev, |
488 | port->bulk_in_endpointAddress), | 485 | port->bulk_in_endpointAddress), |
489 | port->bulk_in_buffer, | 486 | port->bulk_in_buffer, |
490 | port->read_urb->transfer_buffer_length, | 487 | port->read_urb->transfer_buffer_length, |
491 | mos7720_bulk_in_callback, mos7720_port); | 488 | mos7720_bulk_in_callback, mos7720_port); |
492 | response = usb_submit_urb(port->read_urb, GFP_KERNEL); | 489 | response = usb_submit_urb(port->read_urb, GFP_KERNEL); |
493 | if (response) | 490 | if (response) |
494 | dev_err(&port->dev, | 491 | dev_err(&port->dev, "%s - Error %d submitting read urb\n", |
495 | "%s - Error %d submitting read urb\n", __func__, response); | 492 | __func__, response); |
496 | 493 | ||
497 | /* initialize our icount structure */ | 494 | /* initialize our icount structure */ |
498 | memset(&(mos7720_port->icount), 0x00, sizeof(mos7720_port->icount)); | 495 | memset(&(mos7720_port->icount), 0x00, sizeof(mos7720_port->icount)); |
@@ -515,8 +512,9 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp) | |||
515 | * system, | 512 | * system, |
516 | * Otherwise we return a negative error number. | 513 | * Otherwise we return a negative error number. |
517 | */ | 514 | */ |
518 | static int mos7720_chars_in_buffer(struct usb_serial_port *port) | 515 | static int mos7720_chars_in_buffer(struct tty_struct *tty) |
519 | { | 516 | { |
517 | struct usb_serial_port *port = tty->driver_data; | ||
520 | int i; | 518 | int i; |
521 | int chars = 0; | 519 | int chars = 0; |
522 | struct moschip_port *mos7720_port; | 520 | struct moschip_port *mos7720_port; |
@@ -530,14 +528,16 @@ static int mos7720_chars_in_buffer(struct usb_serial_port *port) | |||
530 | } | 528 | } |
531 | 529 | ||
532 | for (i = 0; i < NUM_URBS; ++i) { | 530 | for (i = 0; i < NUM_URBS; ++i) { |
533 | if (mos7720_port->write_urb_pool[i] && mos7720_port->write_urb_pool[i]->status == -EINPROGRESS) | 531 | if (mos7720_port->write_urb_pool[i] && |
532 | mos7720_port->write_urb_pool[i]->status == -EINPROGRESS) | ||
534 | chars += URB_TRANSFER_BUFFER_SIZE; | 533 | chars += URB_TRANSFER_BUFFER_SIZE; |
535 | } | 534 | } |
536 | dbg("%s - returns %d", __func__, chars); | 535 | dbg("%s - returns %d", __func__, chars); |
537 | return chars; | 536 | return chars; |
538 | } | 537 | } |
539 | 538 | ||
540 | static void mos7720_close(struct usb_serial_port *port, struct file *filp) | 539 | static void mos7720_close(struct tty_struct *tty, |
540 | struct usb_serial_port *port, struct file *filp) | ||
541 | { | 541 | { |
542 | struct usb_serial *serial; | 542 | struct usb_serial *serial; |
543 | struct moschip_port *mos7720_port; | 543 | struct moschip_port *mos7720_port; |
@@ -575,12 +575,12 @@ static void mos7720_close(struct usb_serial_port *port, struct file *filp) | |||
575 | * been disconnected */ | 575 | * been disconnected */ |
576 | if (!serial->disconnected) { | 576 | if (!serial->disconnected) { |
577 | data = 0x00; | 577 | data = 0x00; |
578 | send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor, | 578 | send_mos_cmd(serial, MOS_WRITE, |
579 | 0x04, &data); | 579 | port->number - port->serial->minor, 0x04, &data); |
580 | 580 | ||
581 | data = 0x00; | 581 | data = 0x00; |
582 | send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor, | 582 | send_mos_cmd(serial, MOS_WRITE, |
583 | 0x01, &data); | 583 | port->number - port->serial->minor, 0x01, &data); |
584 | } | 584 | } |
585 | mutex_unlock(&serial->disc_mutex); | 585 | mutex_unlock(&serial->disc_mutex); |
586 | mos7720_port->open = 0; | 586 | mos7720_port->open = 0; |
@@ -588,9 +588,10 @@ static void mos7720_close(struct usb_serial_port *port, struct file *filp) | |||
588 | dbg("Leaving %s", __func__); | 588 | dbg("Leaving %s", __func__); |
589 | } | 589 | } |
590 | 590 | ||
591 | static void mos7720_break(struct usb_serial_port *port, int break_state) | 591 | static void mos7720_break(struct tty_struct *tty, int break_state) |
592 | { | 592 | { |
593 | unsigned char data; | 593 | struct usb_serial_port *port = tty->driver_data; |
594 | unsigned char data; | ||
594 | struct usb_serial *serial; | 595 | struct usb_serial *serial; |
595 | struct moschip_port *mos7720_port; | 596 | struct moschip_port *mos7720_port; |
596 | 597 | ||
@@ -621,8 +622,9 @@ static void mos7720_break(struct usb_serial_port *port, int break_state) | |||
621 | * If successful, we return the amount of room that we have for this port | 622 | * If successful, we return the amount of room that we have for this port |
622 | * Otherwise we return a negative error number. | 623 | * Otherwise we return a negative error number. |
623 | */ | 624 | */ |
624 | static int mos7720_write_room(struct usb_serial_port *port) | 625 | static int mos7720_write_room(struct tty_struct *tty) |
625 | { | 626 | { |
627 | struct usb_serial_port *port = tty->driver_data; | ||
626 | struct moschip_port *mos7720_port; | 628 | struct moschip_port *mos7720_port; |
627 | int room = 0; | 629 | int room = 0; |
628 | int i; | 630 | int i; |
@@ -637,7 +639,8 @@ static int mos7720_write_room(struct usb_serial_port *port) | |||
637 | 639 | ||
638 | /* FIXME: Locking */ | 640 | /* FIXME: Locking */ |
639 | for (i = 0; i < NUM_URBS; ++i) { | 641 | for (i = 0; i < NUM_URBS; ++i) { |
640 | if (mos7720_port->write_urb_pool[i] && mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) | 642 | if (mos7720_port->write_urb_pool[i] && |
643 | mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) | ||
641 | room += URB_TRANSFER_BUFFER_SIZE; | 644 | room += URB_TRANSFER_BUFFER_SIZE; |
642 | } | 645 | } |
643 | 646 | ||
@@ -645,8 +648,8 @@ static int mos7720_write_room(struct usb_serial_port *port) | |||
645 | return room; | 648 | return room; |
646 | } | 649 | } |
647 | 650 | ||
648 | static int mos7720_write(struct usb_serial_port *port, | 651 | static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port, |
649 | const unsigned char *data, int count) | 652 | const unsigned char *data, int count) |
650 | { | 653 | { |
651 | int status; | 654 | int status; |
652 | int i; | 655 | int i; |
@@ -672,9 +675,10 @@ static int mos7720_write(struct usb_serial_port *port, | |||
672 | urb = NULL; | 675 | urb = NULL; |
673 | 676 | ||
674 | for (i = 0; i < NUM_URBS; ++i) { | 677 | for (i = 0; i < NUM_URBS; ++i) { |
675 | if (mos7720_port->write_urb_pool[i] && mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) { | 678 | if (mos7720_port->write_urb_pool[i] && |
679 | mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) { | ||
676 | urb = mos7720_port->write_urb_pool[i]; | 680 | urb = mos7720_port->write_urb_pool[i]; |
677 | dbg("URB:%d",i); | 681 | dbg("URB:%d", i); |
678 | break; | 682 | break; |
679 | } | 683 | } |
680 | } | 684 | } |
@@ -692,7 +696,7 @@ static int mos7720_write(struct usb_serial_port *port, | |||
692 | goto exit; | 696 | goto exit; |
693 | } | 697 | } |
694 | } | 698 | } |
695 | transfer_size = min (count, URB_TRANSFER_BUFFER_SIZE); | 699 | transfer_size = min(count, URB_TRANSFER_BUFFER_SIZE); |
696 | 700 | ||
697 | memcpy(urb->transfer_buffer, current_position, transfer_size); | 701 | memcpy(urb->transfer_buffer, current_position, transfer_size); |
698 | usb_serial_debug_data(debug, &port->dev, __func__, transfer_size, | 702 | usb_serial_debug_data(debug, &port->dev, __func__, transfer_size, |
@@ -701,12 +705,12 @@ static int mos7720_write(struct usb_serial_port *port, | |||
701 | /* fill urb with data and submit */ | 705 | /* fill urb with data and submit */ |
702 | usb_fill_bulk_urb(urb, serial->dev, | 706 | usb_fill_bulk_urb(urb, serial->dev, |
703 | usb_sndbulkpipe(serial->dev, | 707 | usb_sndbulkpipe(serial->dev, |
704 | port->bulk_out_endpointAddress), | 708 | port->bulk_out_endpointAddress), |
705 | urb->transfer_buffer, transfer_size, | 709 | urb->transfer_buffer, transfer_size, |
706 | mos7720_bulk_out_data_callback, mos7720_port); | 710 | mos7720_bulk_out_data_callback, mos7720_port); |
707 | 711 | ||
708 | /* send it down the pipe */ | 712 | /* send it down the pipe */ |
709 | status = usb_submit_urb(urb,GFP_ATOMIC); | 713 | status = usb_submit_urb(urb, GFP_ATOMIC); |
710 | if (status) { | 714 | if (status) { |
711 | err("%s - usb_submit_urb(write bulk) failed with status = %d", | 715 | err("%s - usb_submit_urb(write bulk) failed with status = %d", |
712 | __func__, status); | 716 | __func__, status); |
@@ -719,10 +723,10 @@ exit: | |||
719 | return bytes_sent; | 723 | return bytes_sent; |
720 | } | 724 | } |
721 | 725 | ||
722 | static void mos7720_throttle(struct usb_serial_port *port) | 726 | static void mos7720_throttle(struct tty_struct *tty) |
723 | { | 727 | { |
728 | struct usb_serial_port *port = tty->driver_data; | ||
724 | struct moschip_port *mos7720_port; | 729 | struct moschip_port *mos7720_port; |
725 | struct tty_struct *tty; | ||
726 | int status; | 730 | int status; |
727 | 731 | ||
728 | dbg("%s- port %d\n", __func__, port->number); | 732 | dbg("%s- port %d\n", __func__, port->number); |
@@ -739,16 +743,10 @@ static void mos7720_throttle(struct usb_serial_port *port) | |||
739 | 743 | ||
740 | dbg("%s: Entering ..........", __func__); | 744 | dbg("%s: Entering ..........", __func__); |
741 | 745 | ||
742 | tty = port->tty; | ||
743 | if (!tty) { | ||
744 | dbg("%s - no tty available", __func__); | ||
745 | return; | ||
746 | } | ||
747 | |||
748 | /* if we are implementing XON/XOFF, send the stop character */ | 746 | /* if we are implementing XON/XOFF, send the stop character */ |
749 | if (I_IXOFF(tty)) { | 747 | if (I_IXOFF(tty)) { |
750 | unsigned char stop_char = STOP_CHAR(tty); | 748 | unsigned char stop_char = STOP_CHAR(tty); |
751 | status = mos7720_write(port, &stop_char, 1); | 749 | status = mos7720_write(tty, port, &stop_char, 1); |
752 | if (status <= 0) | 750 | if (status <= 0) |
753 | return; | 751 | return; |
754 | } | 752 | } |
@@ -764,11 +762,11 @@ static void mos7720_throttle(struct usb_serial_port *port) | |||
764 | } | 762 | } |
765 | } | 763 | } |
766 | 764 | ||
767 | static void mos7720_unthrottle(struct usb_serial_port *port) | 765 | static void mos7720_unthrottle(struct tty_struct *tty) |
768 | { | 766 | { |
769 | struct tty_struct *tty; | 767 | struct usb_serial_port *port = tty->driver_data; |
770 | int status; | ||
771 | struct moschip_port *mos7720_port = usb_get_serial_port_data(port); | 768 | struct moschip_port *mos7720_port = usb_get_serial_port_data(port); |
769 | int status; | ||
772 | 770 | ||
773 | if (mos7720_port == NULL) | 771 | if (mos7720_port == NULL) |
774 | return; | 772 | return; |
@@ -780,16 +778,10 @@ static void mos7720_unthrottle(struct usb_serial_port *port) | |||
780 | 778 | ||
781 | dbg("%s: Entering ..........", __func__); | 779 | dbg("%s: Entering ..........", __func__); |
782 | 780 | ||
783 | tty = port->tty; | ||
784 | if (!tty) { | ||
785 | dbg("%s - no tty available", __func__); | ||
786 | return; | ||
787 | } | ||
788 | |||
789 | /* if we are implementing XON/XOFF, send the start character */ | 781 | /* if we are implementing XON/XOFF, send the start character */ |
790 | if (I_IXOFF(tty)) { | 782 | if (I_IXOFF(tty)) { |
791 | unsigned char start_char = START_CHAR(tty); | 783 | unsigned char start_char = START_CHAR(tty); |
792 | status = mos7720_write(port, &start_char, 1); | 784 | status = mos7720_write(tty, port, &start_char, 1); |
793 | if (status <= 0) | 785 | if (status <= 0) |
794 | return; | 786 | return; |
795 | } | 787 | } |
@@ -819,9 +811,9 @@ static int set_higher_rates(struct moschip_port *mos7720_port, | |||
819 | port = mos7720_port->port; | 811 | port = mos7720_port->port; |
820 | serial = port->serial; | 812 | serial = port->serial; |
821 | 813 | ||
822 | /*********************************************** | 814 | /*********************************************** |
823 | * Init Sequence for higher rates | 815 | * Init Sequence for higher rates |
824 | ***********************************************/ | 816 | ***********************************************/ |
825 | dbg("Sending Setting Commands .........."); | 817 | dbg("Sending Setting Commands .........."); |
826 | port_number = port->number - port->serial->minor; | 818 | port_number = port->number - port->serial->minor; |
827 | 819 | ||
@@ -832,7 +824,7 @@ static int set_higher_rates(struct moschip_port *mos7720_port, | |||
832 | data = 0x0CF; | 824 | data = 0x0CF; |
833 | send_mos_cmd(serial, MOS_WRITE, port->number, 0x02, &data); | 825 | send_mos_cmd(serial, MOS_WRITE, port->number, 0x02, &data); |
834 | data = 0x00b; | 826 | data = 0x00b; |
835 | mos7720_port->shadowMCR = data; | 827 | mos7720_port->shadowMCR = data; |
836 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); | 828 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); |
837 | data = 0x00b; | 829 | data = 0x00b; |
838 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); | 830 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); |
@@ -843,12 +835,12 @@ static int set_higher_rates(struct moschip_port *mos7720_port, | |||
843 | send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data); | 835 | send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data); |
844 | 836 | ||
845 | 837 | ||
846 | /*********************************************** | 838 | /*********************************************** |
847 | * Set for higher rates * | 839 | * Set for higher rates * |
848 | ***********************************************/ | 840 | ***********************************************/ |
849 | 841 | ||
850 | data = baud * 0x10; | 842 | data = baud * 0x10; |
851 | send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, port_number + 1,&data); | 843 | send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, port_number + 1, &data); |
852 | 844 | ||
853 | data = 0x003; | 845 | data = 0x003; |
854 | send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, 0x08, &data); | 846 | send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, 0x08, &data); |
@@ -856,34 +848,33 @@ static int set_higher_rates(struct moschip_port *mos7720_port, | |||
856 | send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data); | 848 | send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data); |
857 | 849 | ||
858 | data = 0x02b; | 850 | data = 0x02b; |
859 | mos7720_port->shadowMCR = data; | 851 | mos7720_port->shadowMCR = data; |
860 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); | 852 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); |
861 | data = 0x02b; | 853 | data = 0x02b; |
862 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); | 854 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); |
863 | 855 | ||
864 | /*********************************************** | 856 | /*********************************************** |
865 | * Set DLL/DLM | 857 | * Set DLL/DLM |
866 | ***********************************************/ | 858 | ***********************************************/ |
867 | 859 | ||
868 | data = mos7720_port->shadowLCR | UART_LCR_DLAB; | 860 | data = mos7720_port->shadowLCR | UART_LCR_DLAB; |
869 | mos7720_port->shadowLCR = data; | 861 | mos7720_port->shadowLCR = data; |
870 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data); | 862 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data); |
871 | 863 | ||
872 | data = 0x001; /* DLL */ | 864 | data = 0x001; /* DLL */ |
873 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x00, &data); | 865 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x00, &data); |
874 | data = 0x000; /* DLM */ | 866 | data = 0x000; /* DLM */ |
875 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data); | 867 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data); |
876 | 868 | ||
877 | data = mos7720_port->shadowLCR & ~UART_LCR_DLAB; | 869 | data = mos7720_port->shadowLCR & ~UART_LCR_DLAB; |
878 | mos7720_port->shadowLCR = data; | 870 | mos7720_port->shadowLCR = data; |
879 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data); | 871 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data); |
880 | 872 | ||
881 | return 0; | 873 | return 0; |
882 | } | 874 | } |
883 | 875 | ||
884 | /* baud rate information */ | 876 | /* baud rate information */ |
885 | struct divisor_table_entry | 877 | struct divisor_table_entry { |
886 | { | ||
887 | __u32 baudrate; | 878 | __u32 baudrate; |
888 | __u16 divisor; | 879 | __u16 divisor; |
889 | }; | 880 | }; |
@@ -932,8 +923,8 @@ static int calc_baud_rate_divisor(int baudrate, int *divisor) | |||
932 | } | 923 | } |
933 | } | 924 | } |
934 | 925 | ||
935 | /* After trying for all the standard baud rates * | 926 | /* After trying for all the standard baud rates * |
936 | * Try calculating the divisor for this baud rate */ | 927 | * Try calculating the divisor for this baud rate */ |
937 | if (baudrate > 75 && baudrate < 230400) { | 928 | if (baudrate > 75 && baudrate < 230400) { |
938 | /* get the divisor */ | 929 | /* get the divisor */ |
939 | custom = (__u16)(230400L / baudrate); | 930 | custom = (__u16)(230400L / baudrate); |
@@ -945,7 +936,7 @@ static int calc_baud_rate_divisor(int baudrate, int *divisor) | |||
945 | custom++; | 936 | custom++; |
946 | *divisor = custom; | 937 | *divisor = custom; |
947 | 938 | ||
948 | dbg("Baud %d = %d",baudrate, custom); | 939 | dbg("Baud %d = %d", baudrate, custom); |
949 | return 0; | 940 | return 0; |
950 | } | 941 | } |
951 | 942 | ||
@@ -979,29 +970,29 @@ static int send_cmd_write_baud_rate(struct moschip_port *mos7720_port, | |||
979 | number = port->number - port->serial->minor; | 970 | number = port->number - port->serial->minor; |
980 | dbg("%s - port = %d, baud = %d", __func__, port->number, baudrate); | 971 | dbg("%s - port = %d, baud = %d", __func__, port->number, baudrate); |
981 | 972 | ||
982 | /* Calculate the Divisor */ | 973 | /* Calculate the Divisor */ |
983 | status = calc_baud_rate_divisor(baudrate, &divisor); | 974 | status = calc_baud_rate_divisor(baudrate, &divisor); |
984 | if (status) { | 975 | if (status) { |
985 | err("%s - bad baud rate", __func__); | 976 | err("%s - bad baud rate", __func__); |
986 | return status; | 977 | return status; |
987 | } | 978 | } |
988 | 979 | ||
989 | /* Enable access to divisor latch */ | 980 | /* Enable access to divisor latch */ |
990 | data = mos7720_port->shadowLCR | UART_LCR_DLAB; | 981 | data = mos7720_port->shadowLCR | UART_LCR_DLAB; |
991 | mos7720_port->shadowLCR = data; | 982 | mos7720_port->shadowLCR = data; |
992 | send_mos_cmd(serial, MOS_WRITE, number, UART_LCR, &data); | 983 | send_mos_cmd(serial, MOS_WRITE, number, UART_LCR, &data); |
993 | 984 | ||
994 | /* Write the divisor */ | 985 | /* Write the divisor */ |
995 | data = ((unsigned char)(divisor & 0xff)); | 986 | data = ((unsigned char)(divisor & 0xff)); |
996 | send_mos_cmd(serial, MOS_WRITE, number, 0x00, &data); | 987 | send_mos_cmd(serial, MOS_WRITE, number, 0x00, &data); |
997 | 988 | ||
998 | data = ((unsigned char)((divisor & 0xff00) >> 8)); | 989 | data = ((unsigned char)((divisor & 0xff00) >> 8)); |
999 | send_mos_cmd(serial, MOS_WRITE, number, 0x01, &data); | 990 | send_mos_cmd(serial, MOS_WRITE, number, 0x01, &data); |
1000 | 991 | ||
1001 | /* Disable access to divisor latch */ | 992 | /* Disable access to divisor latch */ |
1002 | data = mos7720_port->shadowLCR & ~UART_LCR_DLAB; | 993 | data = mos7720_port->shadowLCR & ~UART_LCR_DLAB; |
1003 | mos7720_port->shadowLCR = data; | 994 | mos7720_port->shadowLCR = data; |
1004 | send_mos_cmd(serial, MOS_WRITE, number, 0x03, &data); | 995 | send_mos_cmd(serial, MOS_WRITE, number, 0x03, &data); |
1005 | 996 | ||
1006 | return status; | 997 | return status; |
1007 | } | 998 | } |
@@ -1011,12 +1002,12 @@ static int send_cmd_write_baud_rate(struct moschip_port *mos7720_port, | |||
1011 | * This routine is called to set the UART on the device to match | 1002 | * This routine is called to set the UART on the device to match |
1012 | * the specified new settings. | 1003 | * the specified new settings. |
1013 | */ | 1004 | */ |
1014 | static void change_port_settings(struct moschip_port *mos7720_port, | 1005 | static void change_port_settings(struct tty_struct *tty, |
1006 | struct moschip_port *mos7720_port, | ||
1015 | struct ktermios *old_termios) | 1007 | struct ktermios *old_termios) |
1016 | { | 1008 | { |
1017 | struct usb_serial_port *port; | 1009 | struct usb_serial_port *port; |
1018 | struct usb_serial *serial; | 1010 | struct usb_serial *serial; |
1019 | struct tty_struct *tty; | ||
1020 | int baud; | 1011 | int baud; |
1021 | unsigned cflag; | 1012 | unsigned cflag; |
1022 | unsigned iflag; | 1013 | unsigned iflag; |
@@ -1042,8 +1033,6 @@ static void change_port_settings(struct moschip_port *mos7720_port, | |||
1042 | return; | 1033 | return; |
1043 | } | 1034 | } |
1044 | 1035 | ||
1045 | tty = mos7720_port->port->tty; | ||
1046 | |||
1047 | dbg("%s: Entering ..........", __func__); | 1036 | dbg("%s: Entering ..........", __func__); |
1048 | 1037 | ||
1049 | lData = UART_LCR_WLEN8; | 1038 | lData = UART_LCR_WLEN8; |
@@ -1106,29 +1095,31 @@ static void change_port_settings(struct moschip_port *mos7720_port, | |||
1106 | #define LCR_PAR_MASK 0x38 /* Mask for parity field */ | 1095 | #define LCR_PAR_MASK 0x38 /* Mask for parity field */ |
1107 | 1096 | ||
1108 | /* Update the LCR with the correct value */ | 1097 | /* Update the LCR with the correct value */ |
1109 | mos7720_port->shadowLCR &= ~(LCR_BITS_MASK | LCR_STOP_MASK | LCR_PAR_MASK); | 1098 | mos7720_port->shadowLCR &= |
1099 | ~(LCR_BITS_MASK | LCR_STOP_MASK | LCR_PAR_MASK); | ||
1110 | mos7720_port->shadowLCR |= (lData | lParity | lStop); | 1100 | mos7720_port->shadowLCR |= (lData | lParity | lStop); |
1111 | 1101 | ||
1112 | 1102 | ||
1113 | /* Disable Interrupts */ | 1103 | /* Disable Interrupts */ |
1114 | data = 0x00; | 1104 | data = 0x00; |
1115 | send_mos_cmd(serial,MOS_WRITE,port->number - port->serial->minor, UART_IER, &data); | 1105 | send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor, |
1106 | UART_IER, &data); | ||
1116 | 1107 | ||
1117 | data = 0x00; | 1108 | data = 0x00; |
1118 | send_mos_cmd(serial, MOS_WRITE, port_number, UART_FCR, &data); | 1109 | send_mos_cmd(serial, MOS_WRITE, port_number, UART_FCR, &data); |
1119 | 1110 | ||
1120 | data = 0xcf; | 1111 | data = 0xcf; |
1121 | send_mos_cmd(serial, MOS_WRITE, port_number, UART_FCR, &data); | 1112 | send_mos_cmd(serial, MOS_WRITE, port_number, UART_FCR, &data); |
1122 | 1113 | ||
1123 | /* Send the updated LCR value to the mos7720 */ | 1114 | /* Send the updated LCR value to the mos7720 */ |
1124 | data = mos7720_port->shadowLCR; | 1115 | data = mos7720_port->shadowLCR; |
1125 | send_mos_cmd(serial, MOS_WRITE, port_number, UART_LCR, &data); | 1116 | send_mos_cmd(serial, MOS_WRITE, port_number, UART_LCR, &data); |
1126 | 1117 | ||
1127 | data = 0x00b; | 1118 | data = 0x00b; |
1128 | mos7720_port->shadowMCR = data; | 1119 | mos7720_port->shadowMCR = data; |
1129 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); | 1120 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); |
1130 | data = 0x00b; | 1121 | data = 0x00b; |
1131 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); | 1122 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); |
1132 | 1123 | ||
1133 | /* set up the MCR register and send it to the mos7720 */ | 1124 | /* set up the MCR register and send it to the mos7720 */ |
1134 | mos7720_port->shadowMCR = UART_MCR_OUT2; | 1125 | mos7720_port->shadowMCR = UART_MCR_OUT2; |
@@ -1137,9 +1128,8 @@ static void change_port_settings(struct moschip_port *mos7720_port, | |||
1137 | 1128 | ||
1138 | if (cflag & CRTSCTS) { | 1129 | if (cflag & CRTSCTS) { |
1139 | mos7720_port->shadowMCR |= (UART_MCR_XONANY); | 1130 | mos7720_port->shadowMCR |= (UART_MCR_XONANY); |
1140 | 1131 | /* To set hardware flow control to the specified * | |
1141 | /* To set hardware flow control to the specified * | 1132 | * serial port, in SP1/2_CONTROL_REG */ |
1142 | * serial port, in SP1/2_CONTROL_REG */ | ||
1143 | if (port->number) { | 1133 | if (port->number) { |
1144 | data = 0x001; | 1134 | data = 0x001; |
1145 | send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, | 1135 | send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, |
@@ -1198,14 +1188,13 @@ static void change_port_settings(struct moschip_port *mos7720_port, | |||
1198 | * this function is called by the tty driver when it wants to change the | 1188 | * this function is called by the tty driver when it wants to change the |
1199 | * termios structure. | 1189 | * termios structure. |
1200 | */ | 1190 | */ |
1201 | static void mos7720_set_termios(struct usb_serial_port *port, | 1191 | static void mos7720_set_termios(struct tty_struct *tty, |
1202 | struct ktermios *old_termios) | 1192 | struct usb_serial_port *port, struct ktermios *old_termios) |
1203 | { | 1193 | { |
1204 | int status; | 1194 | int status; |
1205 | unsigned int cflag; | 1195 | unsigned int cflag; |
1206 | struct usb_serial *serial; | 1196 | struct usb_serial *serial; |
1207 | struct moschip_port *mos7720_port; | 1197 | struct moschip_port *mos7720_port; |
1208 | struct tty_struct *tty; | ||
1209 | 1198 | ||
1210 | serial = port->serial; | 1199 | serial = port->serial; |
1211 | 1200 | ||
@@ -1214,15 +1203,12 @@ static void mos7720_set_termios(struct usb_serial_port *port, | |||
1214 | if (mos7720_port == NULL) | 1203 | if (mos7720_port == NULL) |
1215 | return; | 1204 | return; |
1216 | 1205 | ||
1217 | tty = port->tty; | ||
1218 | |||
1219 | |||
1220 | if (!mos7720_port->open) { | 1206 | if (!mos7720_port->open) { |
1221 | dbg("%s - port not opened", __func__); | 1207 | dbg("%s - port not opened", __func__); |
1222 | return; | 1208 | return; |
1223 | } | 1209 | } |
1224 | 1210 | ||
1225 | dbg("%s\n","setting termios - ASPIRE"); | 1211 | dbg("%s\n", "setting termios - ASPIRE"); |
1226 | 1212 | ||
1227 | cflag = tty->termios->c_cflag; | 1213 | cflag = tty->termios->c_cflag; |
1228 | 1214 | ||
@@ -1237,14 +1223,14 @@ static void mos7720_set_termios(struct usb_serial_port *port, | |||
1237 | dbg("%s - port %d", __func__, port->number); | 1223 | dbg("%s - port %d", __func__, port->number); |
1238 | 1224 | ||
1239 | /* change the port settings to the new ones specified */ | 1225 | /* change the port settings to the new ones specified */ |
1240 | change_port_settings(mos7720_port, old_termios); | 1226 | change_port_settings(tty, mos7720_port, old_termios); |
1241 | 1227 | ||
1242 | if(!port->read_urb) { | 1228 | if (!port->read_urb) { |
1243 | dbg("%s","URB KILLED !!!!!\n"); | 1229 | dbg("%s", "URB KILLED !!!!!\n"); |
1244 | return; | 1230 | return; |
1245 | } | 1231 | } |
1246 | 1232 | ||
1247 | if(port->read_urb->status != -EINPROGRESS) { | 1233 | if (port->read_urb->status != -EINPROGRESS) { |
1248 | port->read_urb->dev = serial->dev; | 1234 | port->read_urb->dev = serial->dev; |
1249 | status = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 1235 | status = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
1250 | if (status) | 1236 | if (status) |
@@ -1264,13 +1250,13 @@ static void mos7720_set_termios(struct usb_serial_port *port, | |||
1264 | * transmit holding register is empty. This functionality | 1250 | * transmit holding register is empty. This functionality |
1265 | * allows an RS485 driver to be written in user space. | 1251 | * allows an RS485 driver to be written in user space. |
1266 | */ | 1252 | */ |
1267 | static int get_lsr_info(struct moschip_port *mos7720_port, | 1253 | static int get_lsr_info(struct tty_struct *tty, |
1268 | unsigned int __user *value) | 1254 | struct moschip_port *mos7720_port, unsigned int __user *value) |
1269 | { | 1255 | { |
1270 | int count; | 1256 | int count; |
1271 | unsigned int result = 0; | 1257 | unsigned int result = 0; |
1272 | 1258 | ||
1273 | count = mos7720_chars_in_buffer(mos7720_port->port); | 1259 | count = mos7720_chars_in_buffer(tty); |
1274 | if (count == 0) { | 1260 | if (count == 0) { |
1275 | dbg("%s -- Empty", __func__); | 1261 | dbg("%s -- Empty", __func__); |
1276 | result = TIOCSER_TEMT; | 1262 | result = TIOCSER_TEMT; |
@@ -1290,7 +1276,7 @@ static int get_number_bytes_avail(struct moschip_port *mos7720_port, | |||
1290 | unsigned int __user *value) | 1276 | unsigned int __user *value) |
1291 | { | 1277 | { |
1292 | unsigned int result = 0; | 1278 | unsigned int result = 0; |
1293 | struct tty_struct *tty = mos7720_port->port->tty; | 1279 | struct tty_struct *tty = mos7720_port->port->port.tty; |
1294 | 1280 | ||
1295 | if (!tty) | 1281 | if (!tty) |
1296 | return -ENOIOCTLCMD; | 1282 | return -ENOIOCTLCMD; |
@@ -1316,7 +1302,7 @@ static int set_modem_info(struct moschip_port *mos7720_port, unsigned int cmd, | |||
1316 | if (mos7720_port == NULL) | 1302 | if (mos7720_port == NULL) |
1317 | return -1; | 1303 | return -1; |
1318 | 1304 | ||
1319 | port = (struct usb_serial_port*)mos7720_port->port; | 1305 | port = (struct usb_serial_port *)mos7720_port->port; |
1320 | mcr = mos7720_port->shadowMCR; | 1306 | mcr = mos7720_port->shadowMCR; |
1321 | 1307 | ||
1322 | if (copy_from_user(&arg, value, sizeof(int))) | 1308 | if (copy_from_user(&arg, value, sizeof(int))) |
@@ -1397,7 +1383,7 @@ static int get_serial_info(struct moschip_port *mos7720_port, | |||
1397 | tmp.port = mos7720_port->port->number; | 1383 | tmp.port = mos7720_port->port->number; |
1398 | tmp.irq = 0; | 1384 | tmp.irq = 0; |
1399 | tmp.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ; | 1385 | tmp.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ; |
1400 | tmp.xmit_fifo_size = NUM_URBS * URB_TRANSFER_BUFFER_SIZE; | 1386 | tmp.xmit_fifo_size = NUM_URBS * URB_TRANSFER_BUFFER_SIZE; |
1401 | tmp.baud_base = 9600; | 1387 | tmp.baud_base = 9600; |
1402 | tmp.close_delay = 5*HZ; | 1388 | tmp.close_delay = 5*HZ; |
1403 | tmp.closing_wait = 30*HZ; | 1389 | tmp.closing_wait = 30*HZ; |
@@ -1407,9 +1393,10 @@ static int get_serial_info(struct moschip_port *mos7720_port, | |||
1407 | return 0; | 1393 | return 0; |
1408 | } | 1394 | } |
1409 | 1395 | ||
1410 | static int mos7720_ioctl(struct usb_serial_port *port, struct file *file, | 1396 | static int mos7720_ioctl(struct tty_struct *tty, struct file *file, |
1411 | unsigned int cmd, unsigned long arg) | 1397 | unsigned int cmd, unsigned long arg) |
1412 | { | 1398 | { |
1399 | struct usb_serial_port *port = tty->driver_data; | ||
1413 | struct moschip_port *mos7720_port; | 1400 | struct moschip_port *mos7720_port; |
1414 | struct async_icount cnow; | 1401 | struct async_icount cnow; |
1415 | struct async_icount cprev; | 1402 | struct async_icount cprev; |
@@ -1431,14 +1418,16 @@ static int mos7720_ioctl(struct usb_serial_port *port, struct file *file, | |||
1431 | 1418 | ||
1432 | case TIOCSERGETLSR: | 1419 | case TIOCSERGETLSR: |
1433 | dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); | 1420 | dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); |
1434 | return get_lsr_info(mos7720_port, (unsigned int __user *)arg); | 1421 | return get_lsr_info(tty, mos7720_port, |
1422 | (unsigned int __user *)arg); | ||
1435 | return 0; | 1423 | return 0; |
1436 | 1424 | ||
1425 | /* FIXME: These should be using the mode methods */ | ||
1437 | case TIOCMBIS: | 1426 | case TIOCMBIS: |
1438 | case TIOCMBIC: | 1427 | case TIOCMBIC: |
1439 | case TIOCMSET: | 1428 | case TIOCMSET: |
1440 | dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __func__, | 1429 | dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", |
1441 | port->number); | 1430 | __func__, port->number); |
1442 | return set_modem_info(mos7720_port, cmd, | 1431 | return set_modem_info(mos7720_port, cmd, |
1443 | (unsigned int __user *)arg); | 1432 | (unsigned int __user *)arg); |
1444 | 1433 | ||
@@ -1452,10 +1441,6 @@ static int mos7720_ioctl(struct usb_serial_port *port, struct file *file, | |||
1452 | return get_serial_info(mos7720_port, | 1441 | return get_serial_info(mos7720_port, |
1453 | (struct serial_struct __user *)arg); | 1442 | (struct serial_struct __user *)arg); |
1454 | 1443 | ||
1455 | case TIOCSSERIAL: | ||
1456 | dbg("%s (%d) TIOCSSERIAL", __func__, port->number); | ||
1457 | break; | ||
1458 | |||
1459 | case TIOCMIWAIT: | 1444 | case TIOCMIWAIT: |
1460 | dbg("%s (%d) TIOCMIWAIT", __func__, port->number); | 1445 | dbg("%s (%d) TIOCMIWAIT", __func__, port->number); |
1461 | cprev = mos7720_port->icount; | 1446 | cprev = mos7720_port->icount; |
@@ -1469,7 +1454,7 @@ static int mos7720_ioctl(struct usb_serial_port *port, struct file *file, | |||
1469 | if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || | 1454 | if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || |
1470 | ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || | 1455 | ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || |
1471 | ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) || | 1456 | ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) || |
1472 | ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts)) ) { | 1457 | ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts))) { |
1473 | return 0; | 1458 | return 0; |
1474 | } | 1459 | } |
1475 | cprev = cnow; | 1460 | cprev = cnow; |
@@ -1492,7 +1477,7 @@ static int mos7720_ioctl(struct usb_serial_port *port, struct file *file, | |||
1492 | icount.buf_overrun = cnow.buf_overrun; | 1477 | icount.buf_overrun = cnow.buf_overrun; |
1493 | 1478 | ||
1494 | dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, | 1479 | dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, |
1495 | port->number, icount.rx, icount.tx ); | 1480 | port->number, icount.rx, icount.tx); |
1496 | if (copy_to_user((void __user *)arg, &icount, sizeof(icount))) | 1481 | if (copy_to_user((void __user *)arg, &icount, sizeof(icount))) |
1497 | return -EFAULT; | 1482 | return -EFAULT; |
1498 | return 0; | 1483 | return 0; |
@@ -1543,7 +1528,8 @@ static int mos7720_startup(struct usb_serial *serial) | |||
1543 | /* Initialize all port interrupt end point to port 0 int | 1528 | /* Initialize all port interrupt end point to port 0 int |
1544 | * endpoint. Our device has only one interrupt endpoint | 1529 | * endpoint. Our device has only one interrupt endpoint |
1545 | * comman to all ports */ | 1530 | * comman to all ports */ |
1546 | serial->port[i]->interrupt_in_endpointAddress = serial->port[0]->interrupt_in_endpointAddress; | 1531 | serial->port[i]->interrupt_in_endpointAddress = |
1532 | serial->port[0]->interrupt_in_endpointAddress; | ||
1547 | 1533 | ||
1548 | mos7720_port->port = serial->port[i]; | 1534 | mos7720_port->port = serial->port[i]; |
1549 | usb_set_serial_port_data(serial->port[i], mos7720_port); | 1535 | usb_set_serial_port_data(serial->port[i], mos7720_port); |
@@ -1555,13 +1541,15 @@ static int mos7720_startup(struct usb_serial *serial) | |||
1555 | 1541 | ||
1556 | /* setting configuration feature to one */ | 1542 | /* setting configuration feature to one */ |
1557 | usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | 1543 | usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), |
1558 | (__u8)0x03, 0x00,0x01,0x00, NULL, 0x00, 5*HZ); | 1544 | (__u8)0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5*HZ); |
1559 | 1545 | ||
1560 | send_mos_cmd(serial,MOS_READ,0x00, UART_LSR, &data); // LSR For Port 1 | 1546 | /* LSR For Port 1 */ |
1561 | dbg("LSR:%x",data); | 1547 | send_mos_cmd(serial, MOS_READ, 0x00, UART_LSR, &data); |
1548 | dbg("LSR:%x", data); | ||
1562 | 1549 | ||
1563 | send_mos_cmd(serial,MOS_READ,0x01, UART_LSR, &data); // LSR For Port 2 | 1550 | /* LSR For Port 2 */ |
1564 | dbg("LSR:%x",data); | 1551 | send_mos_cmd(serial, MOS_READ, 0x01, UART_LSR, &data); |
1552 | dbg("LSR:%x", data); | ||
1565 | 1553 | ||
1566 | return 0; | 1554 | return 0; |
1567 | } | 1555 | } |
@@ -1571,7 +1559,7 @@ static void mos7720_shutdown(struct usb_serial *serial) | |||
1571 | int i; | 1559 | int i; |
1572 | 1560 | ||
1573 | /* free private structure allocated for serial port */ | 1561 | /* free private structure allocated for serial port */ |
1574 | for (i=0; i < serial->num_ports; ++i) { | 1562 | for (i = 0; i < serial->num_ports; ++i) { |
1575 | kfree(usb_get_serial_port_data(serial->port[i])); | 1563 | kfree(usb_get_serial_port_data(serial->port[i])); |
1576 | usb_set_serial_port_data(serial->port[i], NULL); | 1564 | usb_set_serial_port_data(serial->port[i], NULL); |
1577 | } | 1565 | } |
@@ -1651,8 +1639,8 @@ module_init(moschip7720_init); | |||
1651 | module_exit(moschip7720_exit); | 1639 | module_exit(moschip7720_exit); |
1652 | 1640 | ||
1653 | /* Module information */ | 1641 | /* Module information */ |
1654 | MODULE_AUTHOR( DRIVER_AUTHOR ); | 1642 | MODULE_AUTHOR(DRIVER_AUTHOR); |
1655 | MODULE_DESCRIPTION( DRIVER_DESC ); | 1643 | MODULE_DESCRIPTION(DRIVER_DESC); |
1656 | MODULE_LICENSE("GPL"); | 1644 | MODULE_LICENSE("GPL"); |
1657 | 1645 | ||
1658 | module_param(debug, bool, S_IRUGO | S_IWUSR); | 1646 | module_param(debug, bool, S_IRUGO | S_IWUSR); |