diff options
author | Alan Cox <alan@redhat.com> | 2008-07-22 06:16:21 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-22 16:03:27 -0400 |
commit | 4da1a17dbc5211ac90264cfc4f0e076c8bdc1732 (patch) | |
tree | 228c904448774592a2394924ff4540c84c391a42 /drivers/usb | |
parent | 880af9db2c35c5fedaef0de89473f202329934db (diff) |
tty-usb-mos7720: Coding style
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/serial/mos7720.c | 227 |
1 files changed, 116 insertions, 111 deletions
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index d47f0814ce2d..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 | ||
@@ -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,20 +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 tty_struct *tty, | 320 | static int mos7720_open(struct tty_struct *tty, |
324 | struct usb_serial_port *port, struct file * filp) | 321 | struct usb_serial_port *port, struct file *filp) |
325 | { | 322 | { |
326 | struct usb_serial *serial; | 323 | struct usb_serial *serial; |
327 | struct usb_serial_port *port0; | 324 | struct usb_serial_port *port0; |
@@ -352,7 +349,7 @@ static int mos7720_open(struct tty_struct *tty, | |||
352 | 349 | ||
353 | /* Initialising the write urb pool */ | 350 | /* Initialising the write urb pool */ |
354 | for (j = 0; j < NUM_URBS; ++j) { | 351 | for (j = 0; j < NUM_URBS; ++j) { |
355 | urb = usb_alloc_urb(0,GFP_KERNEL); | 352 | urb = usb_alloc_urb(0, GFP_KERNEL); |
356 | mos7720_port->write_urb_pool[j] = urb; | 353 | mos7720_port->write_urb_pool[j] = urb; |
357 | 354 | ||
358 | if (urb == NULL) { | 355 | if (urb == NULL) { |
@@ -386,7 +383,7 @@ static int mos7720_open(struct tty_struct *tty, | |||
386 | */ | 383 | */ |
387 | port_number = port->number - port->serial->minor; | 384 | port_number = port->number - port->serial->minor; |
388 | 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); |
389 | dbg("SS::%p LSR:%x\n",mos7720_port, data); | 386 | dbg("SS::%p LSR:%x\n", mos7720_port, data); |
390 | 387 | ||
391 | dbg("Check:Sending Command .........."); | 388 | dbg("Check:Sending Command .........."); |
392 | 389 | ||
@@ -403,10 +400,10 @@ static int mos7720_open(struct tty_struct *tty, | |||
403 | data = 0xCF; | 400 | data = 0xCF; |
404 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x02, &data); | 401 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x02, &data); |
405 | data = 0x03; | 402 | data = 0x03; |
406 | mos7720_port->shadowLCR = data; | 403 | mos7720_port->shadowLCR = data; |
407 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data); | 404 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data); |
408 | data = 0x0b; | 405 | data = 0x0b; |
409 | mos7720_port->shadowMCR = data; | 406 | mos7720_port->shadowMCR = data; |
410 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); | 407 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); |
411 | data = 0x0b; | 408 | data = 0x0b; |
412 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); | 409 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); |
@@ -421,7 +418,8 @@ static int mos7720_open(struct tty_struct *tty, | |||
421 | data = 0x03; | 418 | data = 0x03; |
422 | 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); |
423 | data = 0x00; | 420 | data = 0x00; |
424 | 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); | ||
425 | */ | 423 | */ |
426 | data = 0x00; | 424 | data = 0x00; |
427 | send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, 0x08, &data); | 425 | send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, 0x08, &data); |
@@ -430,14 +428,14 @@ static int mos7720_open(struct tty_struct *tty, | |||
430 | send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data); | 428 | send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data); |
431 | 429 | ||
432 | data = 0x83; | 430 | data = 0x83; |
433 | mos7720_port->shadowLCR = data; | 431 | mos7720_port->shadowLCR = data; |
434 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data); | 432 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data); |
435 | data = 0x0c; | 433 | data = 0x0c; |
436 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x00, &data); | 434 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x00, &data); |
437 | data = 0x00; | 435 | data = 0x00; |
438 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data); | 436 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data); |
439 | data = 0x03; | 437 | data = 0x03; |
440 | mos7720_port->shadowLCR = data; | 438 | mos7720_port->shadowLCR = data; |
441 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data); | 439 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data); |
442 | data = 0x0c; | 440 | data = 0x0c; |
443 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data); | 441 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data); |
@@ -464,15 +462,15 @@ static int mos7720_open(struct tty_struct *tty, | |||
464 | 462 | ||
465 | /* set up our interrupt urb */ | 463 | /* set up our interrupt urb */ |
466 | usb_fill_int_urb(port0->interrupt_in_urb, serial->dev, | 464 | usb_fill_int_urb(port0->interrupt_in_urb, serial->dev, |
467 | usb_rcvintpipe(serial->dev, | 465 | usb_rcvintpipe(serial->dev, |
468 | port->interrupt_in_endpointAddress), | 466 | port->interrupt_in_endpointAddress), |
469 | port0->interrupt_in_buffer, | 467 | port0->interrupt_in_buffer, |
470 | port0->interrupt_in_urb->transfer_buffer_length, | 468 | port0->interrupt_in_urb->transfer_buffer_length, |
471 | mos7720_interrupt_callback, mos7720_port, | 469 | mos7720_interrupt_callback, mos7720_port, |
472 | port0->interrupt_in_urb->interval); | 470 | port0->interrupt_in_urb->interval); |
473 | 471 | ||
474 | /* start interrupt read for this mos7720 this interrupt * | 472 | /* start interrupt read for this mos7720 this interrupt * |
475 | * will continue as long as the mos7720 is connected */ | 473 | * will continue as long as the mos7720 is connected */ |
476 | dbg("Submit URB over !!!"); | 474 | dbg("Submit URB over !!!"); |
477 | response = usb_submit_urb(port0->interrupt_in_urb, GFP_KERNEL); | 475 | response = usb_submit_urb(port0->interrupt_in_urb, GFP_KERNEL); |
478 | if (response) | 476 | if (response) |
@@ -484,14 +482,14 @@ static int mos7720_open(struct tty_struct *tty, | |||
484 | /* set up our bulk in urb */ | 482 | /* set up our bulk in urb */ |
485 | usb_fill_bulk_urb(port->read_urb, serial->dev, | 483 | usb_fill_bulk_urb(port->read_urb, serial->dev, |
486 | usb_rcvbulkpipe(serial->dev, | 484 | usb_rcvbulkpipe(serial->dev, |
487 | port->bulk_in_endpointAddress), | 485 | port->bulk_in_endpointAddress), |
488 | port->bulk_in_buffer, | 486 | port->bulk_in_buffer, |
489 | port->read_urb->transfer_buffer_length, | 487 | port->read_urb->transfer_buffer_length, |
490 | mos7720_bulk_in_callback, mos7720_port); | 488 | mos7720_bulk_in_callback, mos7720_port); |
491 | response = usb_submit_urb(port->read_urb, GFP_KERNEL); | 489 | response = usb_submit_urb(port->read_urb, GFP_KERNEL); |
492 | if (response) | 490 | if (response) |
493 | dev_err(&port->dev, | 491 | dev_err(&port->dev, "%s - Error %d submitting read urb\n", |
494 | "%s - Error %d submitting read urb\n", __func__, response); | 492 | __func__, response); |
495 | 493 | ||
496 | /* initialize our icount structure */ | 494 | /* initialize our icount structure */ |
497 | memset(&(mos7720_port->icount), 0x00, sizeof(mos7720_port->icount)); | 495 | memset(&(mos7720_port->icount), 0x00, sizeof(mos7720_port->icount)); |
@@ -530,7 +528,8 @@ static int mos7720_chars_in_buffer(struct tty_struct *tty) | |||
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); |
@@ -576,12 +575,12 @@ static void mos7720_close(struct tty_struct *tty, | |||
576 | * been disconnected */ | 575 | * been disconnected */ |
577 | if (!serial->disconnected) { | 576 | if (!serial->disconnected) { |
578 | data = 0x00; | 577 | data = 0x00; |
579 | send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor, | 578 | send_mos_cmd(serial, MOS_WRITE, |
580 | 0x04, &data); | 579 | port->number - port->serial->minor, 0x04, &data); |
581 | 580 | ||
582 | data = 0x00; | 581 | data = 0x00; |
583 | send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor, | 582 | send_mos_cmd(serial, MOS_WRITE, |
584 | 0x01, &data); | 583 | port->number - port->serial->minor, 0x01, &data); |
585 | } | 584 | } |
586 | mutex_unlock(&serial->disc_mutex); | 585 | mutex_unlock(&serial->disc_mutex); |
587 | mos7720_port->open = 0; | 586 | mos7720_port->open = 0; |
@@ -592,7 +591,7 @@ static void mos7720_close(struct tty_struct *tty, | |||
592 | static void mos7720_break(struct tty_struct *tty, int break_state) | 591 | static void mos7720_break(struct tty_struct *tty, int break_state) |
593 | { | 592 | { |
594 | struct usb_serial_port *port = tty->driver_data; | 593 | struct usb_serial_port *port = tty->driver_data; |
595 | unsigned char data; | 594 | unsigned char data; |
596 | struct usb_serial *serial; | 595 | struct usb_serial *serial; |
597 | struct moschip_port *mos7720_port; | 596 | struct moschip_port *mos7720_port; |
598 | 597 | ||
@@ -640,7 +639,8 @@ static int mos7720_write_room(struct tty_struct *tty) | |||
640 | 639 | ||
641 | /* FIXME: Locking */ | 640 | /* FIXME: Locking */ |
642 | for (i = 0; i < NUM_URBS; ++i) { | 641 | for (i = 0; i < NUM_URBS; ++i) { |
643 | 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) | ||
644 | room += URB_TRANSFER_BUFFER_SIZE; | 644 | room += URB_TRANSFER_BUFFER_SIZE; |
645 | } | 645 | } |
646 | 646 | ||
@@ -675,9 +675,10 @@ static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
675 | urb = NULL; | 675 | urb = NULL; |
676 | 676 | ||
677 | for (i = 0; i < NUM_URBS; ++i) { | 677 | for (i = 0; i < NUM_URBS; ++i) { |
678 | 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) { | ||
679 | urb = mos7720_port->write_urb_pool[i]; | 680 | urb = mos7720_port->write_urb_pool[i]; |
680 | dbg("URB:%d",i); | 681 | dbg("URB:%d", i); |
681 | break; | 682 | break; |
682 | } | 683 | } |
683 | } | 684 | } |
@@ -695,7 +696,7 @@ static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
695 | goto exit; | 696 | goto exit; |
696 | } | 697 | } |
697 | } | 698 | } |
698 | transfer_size = min (count, URB_TRANSFER_BUFFER_SIZE); | 699 | transfer_size = min(count, URB_TRANSFER_BUFFER_SIZE); |
699 | 700 | ||
700 | memcpy(urb->transfer_buffer, current_position, transfer_size); | 701 | memcpy(urb->transfer_buffer, current_position, transfer_size); |
701 | usb_serial_debug_data(debug, &port->dev, __func__, transfer_size, | 702 | usb_serial_debug_data(debug, &port->dev, __func__, transfer_size, |
@@ -704,12 +705,12 @@ static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
704 | /* fill urb with data and submit */ | 705 | /* fill urb with data and submit */ |
705 | usb_fill_bulk_urb(urb, serial->dev, | 706 | usb_fill_bulk_urb(urb, serial->dev, |
706 | usb_sndbulkpipe(serial->dev, | 707 | usb_sndbulkpipe(serial->dev, |
707 | port->bulk_out_endpointAddress), | 708 | port->bulk_out_endpointAddress), |
708 | urb->transfer_buffer, transfer_size, | 709 | urb->transfer_buffer, transfer_size, |
709 | mos7720_bulk_out_data_callback, mos7720_port); | 710 | mos7720_bulk_out_data_callback, mos7720_port); |
710 | 711 | ||
711 | /* send it down the pipe */ | 712 | /* send it down the pipe */ |
712 | status = usb_submit_urb(urb,GFP_ATOMIC); | 713 | status = usb_submit_urb(urb, GFP_ATOMIC); |
713 | if (status) { | 714 | if (status) { |
714 | err("%s - usb_submit_urb(write bulk) failed with status = %d", | 715 | err("%s - usb_submit_urb(write bulk) failed with status = %d", |
715 | __func__, status); | 716 | __func__, status); |
@@ -810,9 +811,9 @@ static int set_higher_rates(struct moschip_port *mos7720_port, | |||
810 | port = mos7720_port->port; | 811 | port = mos7720_port->port; |
811 | serial = port->serial; | 812 | serial = port->serial; |
812 | 813 | ||
813 | /*********************************************** | 814 | /*********************************************** |
814 | * Init Sequence for higher rates | 815 | * Init Sequence for higher rates |
815 | ***********************************************/ | 816 | ***********************************************/ |
816 | dbg("Sending Setting Commands .........."); | 817 | dbg("Sending Setting Commands .........."); |
817 | port_number = port->number - port->serial->minor; | 818 | port_number = port->number - port->serial->minor; |
818 | 819 | ||
@@ -823,7 +824,7 @@ static int set_higher_rates(struct moschip_port *mos7720_port, | |||
823 | data = 0x0CF; | 824 | data = 0x0CF; |
824 | send_mos_cmd(serial, MOS_WRITE, port->number, 0x02, &data); | 825 | send_mos_cmd(serial, MOS_WRITE, port->number, 0x02, &data); |
825 | data = 0x00b; | 826 | data = 0x00b; |
826 | mos7720_port->shadowMCR = data; | 827 | mos7720_port->shadowMCR = data; |
827 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); | 828 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); |
828 | data = 0x00b; | 829 | data = 0x00b; |
829 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); | 830 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); |
@@ -834,12 +835,12 @@ static int set_higher_rates(struct moschip_port *mos7720_port, | |||
834 | send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data); | 835 | send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data); |
835 | 836 | ||
836 | 837 | ||
837 | /*********************************************** | 838 | /*********************************************** |
838 | * Set for higher rates * | 839 | * Set for higher rates * |
839 | ***********************************************/ | 840 | ***********************************************/ |
840 | 841 | ||
841 | data = baud * 0x10; | 842 | data = baud * 0x10; |
842 | 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); |
843 | 844 | ||
844 | data = 0x003; | 845 | data = 0x003; |
845 | send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, 0x08, &data); | 846 | send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, 0x08, &data); |
@@ -847,34 +848,33 @@ static int set_higher_rates(struct moschip_port *mos7720_port, | |||
847 | send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data); | 848 | send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data); |
848 | 849 | ||
849 | data = 0x02b; | 850 | data = 0x02b; |
850 | mos7720_port->shadowMCR = data; | 851 | mos7720_port->shadowMCR = data; |
851 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); | 852 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); |
852 | data = 0x02b; | 853 | data = 0x02b; |
853 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); | 854 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); |
854 | 855 | ||
855 | /*********************************************** | 856 | /*********************************************** |
856 | * Set DLL/DLM | 857 | * Set DLL/DLM |
857 | ***********************************************/ | 858 | ***********************************************/ |
858 | 859 | ||
859 | data = mos7720_port->shadowLCR | UART_LCR_DLAB; | 860 | data = mos7720_port->shadowLCR | UART_LCR_DLAB; |
860 | mos7720_port->shadowLCR = data; | 861 | mos7720_port->shadowLCR = data; |
861 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data); | 862 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data); |
862 | 863 | ||
863 | data = 0x001; /* DLL */ | 864 | data = 0x001; /* DLL */ |
864 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x00, &data); | 865 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x00, &data); |
865 | data = 0x000; /* DLM */ | 866 | data = 0x000; /* DLM */ |
866 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data); | 867 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data); |
867 | 868 | ||
868 | data = mos7720_port->shadowLCR & ~UART_LCR_DLAB; | 869 | data = mos7720_port->shadowLCR & ~UART_LCR_DLAB; |
869 | mos7720_port->shadowLCR = data; | 870 | mos7720_port->shadowLCR = data; |
870 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data); | 871 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data); |
871 | 872 | ||
872 | return 0; | 873 | return 0; |
873 | } | 874 | } |
874 | 875 | ||
875 | /* baud rate information */ | 876 | /* baud rate information */ |
876 | struct divisor_table_entry | 877 | struct divisor_table_entry { |
877 | { | ||
878 | __u32 baudrate; | 878 | __u32 baudrate; |
879 | __u16 divisor; | 879 | __u16 divisor; |
880 | }; | 880 | }; |
@@ -923,8 +923,8 @@ static int calc_baud_rate_divisor(int baudrate, int *divisor) | |||
923 | } | 923 | } |
924 | } | 924 | } |
925 | 925 | ||
926 | /* After trying for all the standard baud rates * | 926 | /* After trying for all the standard baud rates * |
927 | * Try calculating the divisor for this baud rate */ | 927 | * Try calculating the divisor for this baud rate */ |
928 | if (baudrate > 75 && baudrate < 230400) { | 928 | if (baudrate > 75 && baudrate < 230400) { |
929 | /* get the divisor */ | 929 | /* get the divisor */ |
930 | custom = (__u16)(230400L / baudrate); | 930 | custom = (__u16)(230400L / baudrate); |
@@ -936,7 +936,7 @@ static int calc_baud_rate_divisor(int baudrate, int *divisor) | |||
936 | custom++; | 936 | custom++; |
937 | *divisor = custom; | 937 | *divisor = custom; |
938 | 938 | ||
939 | dbg("Baud %d = %d",baudrate, custom); | 939 | dbg("Baud %d = %d", baudrate, custom); |
940 | return 0; | 940 | return 0; |
941 | } | 941 | } |
942 | 942 | ||
@@ -970,29 +970,29 @@ static int send_cmd_write_baud_rate(struct moschip_port *mos7720_port, | |||
970 | number = port->number - port->serial->minor; | 970 | number = port->number - port->serial->minor; |
971 | dbg("%s - port = %d, baud = %d", __func__, port->number, baudrate); | 971 | dbg("%s - port = %d, baud = %d", __func__, port->number, baudrate); |
972 | 972 | ||
973 | /* Calculate the Divisor */ | 973 | /* Calculate the Divisor */ |
974 | status = calc_baud_rate_divisor(baudrate, &divisor); | 974 | status = calc_baud_rate_divisor(baudrate, &divisor); |
975 | if (status) { | 975 | if (status) { |
976 | err("%s - bad baud rate", __func__); | 976 | err("%s - bad baud rate", __func__); |
977 | return status; | 977 | return status; |
978 | } | 978 | } |
979 | 979 | ||
980 | /* Enable access to divisor latch */ | 980 | /* Enable access to divisor latch */ |
981 | data = mos7720_port->shadowLCR | UART_LCR_DLAB; | 981 | data = mos7720_port->shadowLCR | UART_LCR_DLAB; |
982 | mos7720_port->shadowLCR = data; | 982 | mos7720_port->shadowLCR = data; |
983 | send_mos_cmd(serial, MOS_WRITE, number, UART_LCR, &data); | 983 | send_mos_cmd(serial, MOS_WRITE, number, UART_LCR, &data); |
984 | 984 | ||
985 | /* Write the divisor */ | 985 | /* Write the divisor */ |
986 | data = ((unsigned char)(divisor & 0xff)); | 986 | data = ((unsigned char)(divisor & 0xff)); |
987 | send_mos_cmd(serial, MOS_WRITE, number, 0x00, &data); | 987 | send_mos_cmd(serial, MOS_WRITE, number, 0x00, &data); |
988 | 988 | ||
989 | data = ((unsigned char)((divisor & 0xff00) >> 8)); | 989 | data = ((unsigned char)((divisor & 0xff00) >> 8)); |
990 | send_mos_cmd(serial, MOS_WRITE, number, 0x01, &data); | 990 | send_mos_cmd(serial, MOS_WRITE, number, 0x01, &data); |
991 | 991 | ||
992 | /* Disable access to divisor latch */ | 992 | /* Disable access to divisor latch */ |
993 | data = mos7720_port->shadowLCR & ~UART_LCR_DLAB; | 993 | data = mos7720_port->shadowLCR & ~UART_LCR_DLAB; |
994 | mos7720_port->shadowLCR = data; | 994 | mos7720_port->shadowLCR = data; |
995 | send_mos_cmd(serial, MOS_WRITE, number, 0x03, &data); | 995 | send_mos_cmd(serial, MOS_WRITE, number, 0x03, &data); |
996 | 996 | ||
997 | return status; | 997 | return status; |
998 | } | 998 | } |
@@ -1095,29 +1095,31 @@ static void change_port_settings(struct tty_struct *tty, | |||
1095 | #define LCR_PAR_MASK 0x38 /* Mask for parity field */ | 1095 | #define LCR_PAR_MASK 0x38 /* Mask for parity field */ |
1096 | 1096 | ||
1097 | /* Update the LCR with the correct value */ | 1097 | /* Update the LCR with the correct value */ |
1098 | 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); | ||
1099 | mos7720_port->shadowLCR |= (lData | lParity | lStop); | 1100 | mos7720_port->shadowLCR |= (lData | lParity | lStop); |
1100 | 1101 | ||
1101 | 1102 | ||
1102 | /* Disable Interrupts */ | 1103 | /* Disable Interrupts */ |
1103 | data = 0x00; | 1104 | data = 0x00; |
1104 | 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); | ||
1105 | 1107 | ||
1106 | data = 0x00; | 1108 | data = 0x00; |
1107 | send_mos_cmd(serial, MOS_WRITE, port_number, UART_FCR, &data); | 1109 | send_mos_cmd(serial, MOS_WRITE, port_number, UART_FCR, &data); |
1108 | 1110 | ||
1109 | data = 0xcf; | 1111 | data = 0xcf; |
1110 | send_mos_cmd(serial, MOS_WRITE, port_number, UART_FCR, &data); | 1112 | send_mos_cmd(serial, MOS_WRITE, port_number, UART_FCR, &data); |
1111 | 1113 | ||
1112 | /* Send the updated LCR value to the mos7720 */ | 1114 | /* Send the updated LCR value to the mos7720 */ |
1113 | data = mos7720_port->shadowLCR; | 1115 | data = mos7720_port->shadowLCR; |
1114 | send_mos_cmd(serial, MOS_WRITE, port_number, UART_LCR, &data); | 1116 | send_mos_cmd(serial, MOS_WRITE, port_number, UART_LCR, &data); |
1115 | 1117 | ||
1116 | data = 0x00b; | 1118 | data = 0x00b; |
1117 | mos7720_port->shadowMCR = data; | 1119 | mos7720_port->shadowMCR = data; |
1118 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); | 1120 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); |
1119 | data = 0x00b; | 1121 | data = 0x00b; |
1120 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); | 1122 | send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data); |
1121 | 1123 | ||
1122 | /* set up the MCR register and send it to the mos7720 */ | 1124 | /* set up the MCR register and send it to the mos7720 */ |
1123 | mos7720_port->shadowMCR = UART_MCR_OUT2; | 1125 | mos7720_port->shadowMCR = UART_MCR_OUT2; |
@@ -1126,9 +1128,8 @@ static void change_port_settings(struct tty_struct *tty, | |||
1126 | 1128 | ||
1127 | if (cflag & CRTSCTS) { | 1129 | if (cflag & CRTSCTS) { |
1128 | mos7720_port->shadowMCR |= (UART_MCR_XONANY); | 1130 | mos7720_port->shadowMCR |= (UART_MCR_XONANY); |
1129 | 1131 | /* To set hardware flow control to the specified * | |
1130 | /* To set hardware flow control to the specified * | 1132 | * serial port, in SP1/2_CONTROL_REG */ |
1131 | * serial port, in SP1/2_CONTROL_REG */ | ||
1132 | if (port->number) { | 1133 | if (port->number) { |
1133 | data = 0x001; | 1134 | data = 0x001; |
1134 | send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, | 1135 | send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, |
@@ -1207,7 +1208,7 @@ static void mos7720_set_termios(struct tty_struct *tty, | |||
1207 | return; | 1208 | return; |
1208 | } | 1209 | } |
1209 | 1210 | ||
1210 | dbg("%s\n","setting termios - ASPIRE"); | 1211 | dbg("%s\n", "setting termios - ASPIRE"); |
1211 | 1212 | ||
1212 | cflag = tty->termios->c_cflag; | 1213 | cflag = tty->termios->c_cflag; |
1213 | 1214 | ||
@@ -1224,12 +1225,12 @@ static void mos7720_set_termios(struct tty_struct *tty, | |||
1224 | /* change the port settings to the new ones specified */ | 1225 | /* change the port settings to the new ones specified */ |
1225 | change_port_settings(tty, mos7720_port, old_termios); | 1226 | change_port_settings(tty, mos7720_port, old_termios); |
1226 | 1227 | ||
1227 | if(!port->read_urb) { | 1228 | if (!port->read_urb) { |
1228 | dbg("%s","URB KILLED !!!!!\n"); | 1229 | dbg("%s", "URB KILLED !!!!!\n"); |
1229 | return; | 1230 | return; |
1230 | } | 1231 | } |
1231 | 1232 | ||
1232 | if(port->read_urb->status != -EINPROGRESS) { | 1233 | if (port->read_urb->status != -EINPROGRESS) { |
1233 | port->read_urb->dev = serial->dev; | 1234 | port->read_urb->dev = serial->dev; |
1234 | status = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 1235 | status = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
1235 | if (status) | 1236 | if (status) |
@@ -1249,8 +1250,8 @@ static void mos7720_set_termios(struct tty_struct *tty, | |||
1249 | * transmit holding register is empty. This functionality | 1250 | * transmit holding register is empty. This functionality |
1250 | * allows an RS485 driver to be written in user space. | 1251 | * allows an RS485 driver to be written in user space. |
1251 | */ | 1252 | */ |
1252 | static int get_lsr_info(struct tty_struct *tty, struct moschip_port *mos7720_port, | 1253 | static int get_lsr_info(struct tty_struct *tty, |
1253 | unsigned int __user *value) | 1254 | struct moschip_port *mos7720_port, unsigned int __user *value) |
1254 | { | 1255 | { |
1255 | int count; | 1256 | int count; |
1256 | unsigned int result = 0; | 1257 | unsigned int result = 0; |
@@ -1301,7 +1302,7 @@ static int set_modem_info(struct moschip_port *mos7720_port, unsigned int cmd, | |||
1301 | if (mos7720_port == NULL) | 1302 | if (mos7720_port == NULL) |
1302 | return -1; | 1303 | return -1; |
1303 | 1304 | ||
1304 | port = (struct usb_serial_port*)mos7720_port->port; | 1305 | port = (struct usb_serial_port *)mos7720_port->port; |
1305 | mcr = mos7720_port->shadowMCR; | 1306 | mcr = mos7720_port->shadowMCR; |
1306 | 1307 | ||
1307 | if (copy_from_user(&arg, value, sizeof(int))) | 1308 | if (copy_from_user(&arg, value, sizeof(int))) |
@@ -1382,7 +1383,7 @@ static int get_serial_info(struct moschip_port *mos7720_port, | |||
1382 | tmp.port = mos7720_port->port->number; | 1383 | tmp.port = mos7720_port->port->number; |
1383 | tmp.irq = 0; | 1384 | tmp.irq = 0; |
1384 | tmp.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ; | 1385 | tmp.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ; |
1385 | tmp.xmit_fifo_size = NUM_URBS * URB_TRANSFER_BUFFER_SIZE; | 1386 | tmp.xmit_fifo_size = NUM_URBS * URB_TRANSFER_BUFFER_SIZE; |
1386 | tmp.baud_base = 9600; | 1387 | tmp.baud_base = 9600; |
1387 | tmp.close_delay = 5*HZ; | 1388 | tmp.close_delay = 5*HZ; |
1388 | tmp.closing_wait = 30*HZ; | 1389 | tmp.closing_wait = 30*HZ; |
@@ -1417,15 +1418,16 @@ static int mos7720_ioctl(struct tty_struct *tty, struct file *file, | |||
1417 | 1418 | ||
1418 | case TIOCSERGETLSR: | 1419 | case TIOCSERGETLSR: |
1419 | dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); | 1420 | dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); |
1420 | return get_lsr_info(tty, mos7720_port, (unsigned int __user *)arg); | 1421 | return get_lsr_info(tty, mos7720_port, |
1422 | (unsigned int __user *)arg); | ||
1421 | return 0; | 1423 | return 0; |
1422 | 1424 | ||
1423 | /* FIXME: These should be using the mode methods */ | 1425 | /* FIXME: These should be using the mode methods */ |
1424 | case TIOCMBIS: | 1426 | case TIOCMBIS: |
1425 | case TIOCMBIC: | 1427 | case TIOCMBIC: |
1426 | case TIOCMSET: | 1428 | case TIOCMSET: |
1427 | dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __func__, | 1429 | dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", |
1428 | port->number); | 1430 | __func__, port->number); |
1429 | return set_modem_info(mos7720_port, cmd, | 1431 | return set_modem_info(mos7720_port, cmd, |
1430 | (unsigned int __user *)arg); | 1432 | (unsigned int __user *)arg); |
1431 | 1433 | ||
@@ -1452,7 +1454,7 @@ static int mos7720_ioctl(struct tty_struct *tty, struct file *file, | |||
1452 | if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || | 1454 | if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || |
1453 | ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || | 1455 | ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || |
1454 | ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) || | 1456 | ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) || |
1455 | ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts)) ) { | 1457 | ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts))) { |
1456 | return 0; | 1458 | return 0; |
1457 | } | 1459 | } |
1458 | cprev = cnow; | 1460 | cprev = cnow; |
@@ -1475,7 +1477,7 @@ static int mos7720_ioctl(struct tty_struct *tty, struct file *file, | |||
1475 | icount.buf_overrun = cnow.buf_overrun; | 1477 | icount.buf_overrun = cnow.buf_overrun; |
1476 | 1478 | ||
1477 | dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, | 1479 | dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, |
1478 | port->number, icount.rx, icount.tx ); | 1480 | port->number, icount.rx, icount.tx); |
1479 | if (copy_to_user((void __user *)arg, &icount, sizeof(icount))) | 1481 | if (copy_to_user((void __user *)arg, &icount, sizeof(icount))) |
1480 | return -EFAULT; | 1482 | return -EFAULT; |
1481 | return 0; | 1483 | return 0; |
@@ -1526,7 +1528,8 @@ static int mos7720_startup(struct usb_serial *serial) | |||
1526 | /* Initialize all port interrupt end point to port 0 int | 1528 | /* Initialize all port interrupt end point to port 0 int |
1527 | * endpoint. Our device has only one interrupt endpoint | 1529 | * endpoint. Our device has only one interrupt endpoint |
1528 | * comman to all ports */ | 1530 | * comman to all ports */ |
1529 | 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; | ||
1530 | 1533 | ||
1531 | mos7720_port->port = serial->port[i]; | 1534 | mos7720_port->port = serial->port[i]; |
1532 | usb_set_serial_port_data(serial->port[i], mos7720_port); | 1535 | usb_set_serial_port_data(serial->port[i], mos7720_port); |
@@ -1538,13 +1541,15 @@ static int mos7720_startup(struct usb_serial *serial) | |||
1538 | 1541 | ||
1539 | /* setting configuration feature to one */ | 1542 | /* setting configuration feature to one */ |
1540 | usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | 1543 | usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), |
1541 | (__u8)0x03, 0x00,0x01,0x00, NULL, 0x00, 5*HZ); | 1544 | (__u8)0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5*HZ); |
1542 | 1545 | ||
1543 | send_mos_cmd(serial,MOS_READ,0x00, UART_LSR, &data); // LSR For Port 1 | 1546 | /* LSR For Port 1 */ |
1544 | dbg("LSR:%x",data); | 1547 | send_mos_cmd(serial, MOS_READ, 0x00, UART_LSR, &data); |
1548 | dbg("LSR:%x", data); | ||
1545 | 1549 | ||
1546 | send_mos_cmd(serial,MOS_READ,0x01, UART_LSR, &data); // LSR For Port 2 | 1550 | /* LSR For Port 2 */ |
1547 | dbg("LSR:%x",data); | 1551 | send_mos_cmd(serial, MOS_READ, 0x01, UART_LSR, &data); |
1552 | dbg("LSR:%x", data); | ||
1548 | 1553 | ||
1549 | return 0; | 1554 | return 0; |
1550 | } | 1555 | } |
@@ -1554,7 +1559,7 @@ static void mos7720_shutdown(struct usb_serial *serial) | |||
1554 | int i; | 1559 | int i; |
1555 | 1560 | ||
1556 | /* free private structure allocated for serial port */ | 1561 | /* free private structure allocated for serial port */ |
1557 | for (i=0; i < serial->num_ports; ++i) { | 1562 | for (i = 0; i < serial->num_ports; ++i) { |
1558 | kfree(usb_get_serial_port_data(serial->port[i])); | 1563 | kfree(usb_get_serial_port_data(serial->port[i])); |
1559 | usb_set_serial_port_data(serial->port[i], NULL); | 1564 | usb_set_serial_port_data(serial->port[i], NULL); |
1560 | } | 1565 | } |
@@ -1634,8 +1639,8 @@ module_init(moschip7720_init); | |||
1634 | module_exit(moschip7720_exit); | 1639 | module_exit(moschip7720_exit); |
1635 | 1640 | ||
1636 | /* Module information */ | 1641 | /* Module information */ |
1637 | MODULE_AUTHOR( DRIVER_AUTHOR ); | 1642 | MODULE_AUTHOR(DRIVER_AUTHOR); |
1638 | MODULE_DESCRIPTION( DRIVER_DESC ); | 1643 | MODULE_DESCRIPTION(DRIVER_DESC); |
1639 | MODULE_LICENSE("GPL"); | 1644 | MODULE_LICENSE("GPL"); |
1640 | 1645 | ||
1641 | module_param(debug, bool, S_IRUGO | S_IWUSR); | 1646 | module_param(debug, bool, S_IRUGO | S_IWUSR); |