aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/mos7840.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/serial/mos7840.c')
-rw-r--r--drivers/usb/serial/mos7840.c478
1 files changed, 183 insertions, 295 deletions
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 402c32d7accb..d6d4eeca8c68 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -252,8 +252,6 @@ struct moschip_port {
252 struct timer_list led_timer2; /* Timer for LED off */ 252 struct timer_list led_timer2; /* Timer for LED off */
253}; 253};
254 254
255static bool debug;
256
257/* 255/*
258 * mos7840_set_reg_sync 256 * mos7840_set_reg_sync
259 * To set the Control register by calling usb_fill_control_urb function 257 * To set the Control register by calling usb_fill_control_urb function
@@ -265,7 +263,7 @@ static int mos7840_set_reg_sync(struct usb_serial_port *port, __u16 reg,
265{ 263{
266 struct usb_device *dev = port->serial->dev; 264 struct usb_device *dev = port->serial->dev;
267 val = val & 0x00ff; 265 val = val & 0x00ff;
268 dbg("mos7840_set_reg_sync offset is %x, value %x", reg, val); 266 dev_dbg(&port->dev, "mos7840_set_reg_sync offset is %x, value %x\n", reg, val);
269 267
270 return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), MCS_WRREQ, 268 return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), MCS_WRREQ,
271 MCS_WR_RTYPE, val, reg, NULL, 0, 269 MCS_WR_RTYPE, val, reg, NULL, 0,
@@ -293,7 +291,7 @@ static int mos7840_get_reg_sync(struct usb_serial_port *port, __u16 reg,
293 MCS_RD_RTYPE, 0, reg, buf, VENDOR_READ_LENGTH, 291 MCS_RD_RTYPE, 0, reg, buf, VENDOR_READ_LENGTH,
294 MOS_WDR_TIMEOUT); 292 MOS_WDR_TIMEOUT);
295 *val = buf[0]; 293 *val = buf[0];
296 dbg("mos7840_get_reg_sync offset is %x, return val %x", reg, *val); 294 dev_dbg(&port->dev, "%s offset is %x, return val %x\n", __func__, reg, *val);
297 295
298 kfree(buf); 296 kfree(buf);
299 return ret; 297 return ret;
@@ -316,21 +314,16 @@ static int mos7840_set_uart_reg(struct usb_serial_port *port, __u16 reg,
316 if (port->serial->num_ports == 4) { 314 if (port->serial->num_ports == 4) {
317 val |= (((__u16) port->number - 315 val |= (((__u16) port->number -
318 (__u16) (port->serial->minor)) + 1) << 8; 316 (__u16) (port->serial->minor)) + 1) << 8;
319 dbg("mos7840_set_uart_reg application number is %x", val);
320 } else { 317 } else {
321 if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) { 318 if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) {
322 val |= (((__u16) port->number - 319 val |= (((__u16) port->number -
323 (__u16) (port->serial->minor)) + 1) << 8; 320 (__u16) (port->serial->minor)) + 1) << 8;
324 dbg("mos7840_set_uart_reg application number is %x",
325 val);
326 } else { 321 } else {
327 val |= 322 val |= (((__u16) port->number -
328 (((__u16) port->number -
329 (__u16) (port->serial->minor)) + 2) << 8; 323 (__u16) (port->serial->minor)) + 2) << 8;
330 dbg("mos7840_set_uart_reg application number is %x",
331 val);
332 } 324 }
333 } 325 }
326 dev_dbg(&port->dev, "%s application number is %x\n", __func__, val);
334 return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), MCS_WRREQ, 327 return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), MCS_WRREQ,
335 MCS_WR_RTYPE, val, reg, NULL, 0, 328 MCS_WR_RTYPE, val, reg, NULL, 0,
336 MOS_WDR_TIMEOUT); 329 MOS_WDR_TIMEOUT);
@@ -354,27 +347,21 @@ static int mos7840_get_uart_reg(struct usb_serial_port *port, __u16 reg,
354 if (!buf) 347 if (!buf)
355 return -ENOMEM; 348 return -ENOMEM;
356 349
357 /* dbg("application number is %4x",
358 (((__u16)port->number - (__u16)(port->serial->minor))+1)<<8); */
359 /* Wval is same as application number */ 350 /* Wval is same as application number */
360 if (port->serial->num_ports == 4) { 351 if (port->serial->num_ports == 4) {
361 Wval = 352 Wval =
362 (((__u16) port->number - (__u16) (port->serial->minor)) + 353 (((__u16) port->number - (__u16) (port->serial->minor)) +
363 1) << 8; 354 1) << 8;
364 dbg("mos7840_get_uart_reg application number is %x", Wval);
365 } else { 355 } else {
366 if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) { 356 if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) {
367 Wval = (((__u16) port->number - 357 Wval = (((__u16) port->number -
368 (__u16) (port->serial->minor)) + 1) << 8; 358 (__u16) (port->serial->minor)) + 1) << 8;
369 dbg("mos7840_get_uart_reg application number is %x",
370 Wval);
371 } else { 359 } else {
372 Wval = (((__u16) port->number - 360 Wval = (((__u16) port->number -
373 (__u16) (port->serial->minor)) + 2) << 8; 361 (__u16) (port->serial->minor)) + 2) << 8;
374 dbg("mos7840_get_uart_reg application number is %x",
375 Wval);
376 } 362 }
377 } 363 }
364 dev_dbg(&port->dev, "%s application number is %x\n", __func__, Wval);
378 ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ, 365 ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ,
379 MCS_RD_RTYPE, Wval, reg, buf, VENDOR_READ_LENGTH, 366 MCS_RD_RTYPE, Wval, reg, buf, VENDOR_READ_LENGTH,
380 MOS_WDR_TIMEOUT); 367 MOS_WDR_TIMEOUT);
@@ -384,14 +371,13 @@ static int mos7840_get_uart_reg(struct usb_serial_port *port, __u16 reg,
384 return ret; 371 return ret;
385} 372}
386 373
387static void mos7840_dump_serial_port(struct moschip_port *mos7840_port) 374static void mos7840_dump_serial_port(struct usb_serial_port *port,
375 struct moschip_port *mos7840_port)
388{ 376{
389 377
390 dbg("***************************************"); 378 dev_dbg(&port->dev, "SpRegOffset is %2x\n", mos7840_port->SpRegOffset);
391 dbg("SpRegOffset is %2x", mos7840_port->SpRegOffset); 379 dev_dbg(&port->dev, "ControlRegOffset is %2x\n", mos7840_port->ControlRegOffset);
392 dbg("ControlRegOffset is %2x", mos7840_port->ControlRegOffset); 380 dev_dbg(&port->dev, "DCRRegOffset is %2x\n", mos7840_port->DcrRegOffset);
393 dbg("DCRRegOffset is %2x", mos7840_port->DcrRegOffset);
394 dbg("***************************************");
395 381
396} 382}
397 383
@@ -450,8 +436,6 @@ static void mos7840_handle_new_lsr(struct moschip_port *port, __u8 new_lsr)
450{ 436{
451 struct async_icount *icount; 437 struct async_icount *icount;
452 438
453 dbg("%s - %02x", __func__, new_lsr);
454
455 if (new_lsr & SERIAL_LSR_BI) { 439 if (new_lsr & SERIAL_LSR_BI) {
456 /* 440 /*
457 * Parity and Framing errors only count if they 441 * Parity and Framing errors only count if they
@@ -492,6 +476,7 @@ static void mos7840_control_callback(struct urb *urb)
492{ 476{
493 unsigned char *data; 477 unsigned char *data;
494 struct moschip_port *mos7840_port; 478 struct moschip_port *mos7840_port;
479 struct device *dev = &urb->dev->dev;
495 __u8 regval = 0x0; 480 __u8 regval = 0x0;
496 int result = 0; 481 int result = 0;
497 int status = urb->status; 482 int status = urb->status;
@@ -506,21 +491,19 @@ static void mos7840_control_callback(struct urb *urb)
506 case -ENOENT: 491 case -ENOENT:
507 case -ESHUTDOWN: 492 case -ESHUTDOWN:
508 /* this urb is terminated, clean up */ 493 /* this urb is terminated, clean up */
509 dbg("%s - urb shutting down with status: %d", __func__, 494 dev_dbg(dev, "%s - urb shutting down with status: %d\n", __func__, status);
510 status);
511 return; 495 return;
512 default: 496 default:
513 dbg("%s - nonzero urb status received: %d", __func__, 497 dev_dbg(dev, "%s - nonzero urb status received: %d\n", __func__, status);
514 status);
515 goto exit; 498 goto exit;
516 } 499 }
517 500
518 dbg("%s urb buffer size is %d", __func__, urb->actual_length); 501 dev_dbg(dev, "%s urb buffer size is %d\n", __func__, urb->actual_length);
519 dbg("%s mos7840_port->MsrLsr is %d port %d", __func__, 502 dev_dbg(dev, "%s mos7840_port->MsrLsr is %d port %d\n", __func__,
520 mos7840_port->MsrLsr, mos7840_port->port_num); 503 mos7840_port->MsrLsr, mos7840_port->port_num);
521 data = urb->transfer_buffer; 504 data = urb->transfer_buffer;
522 regval = (__u8) data[0]; 505 regval = (__u8) data[0];
523 dbg("%s data is %x", __func__, regval); 506 dev_dbg(dev, "%s data is %x\n", __func__, regval);
524 if (mos7840_port->MsrLsr == 0) 507 if (mos7840_port->MsrLsr == 0)
525 mos7840_handle_new_msr(mos7840_port, regval); 508 mos7840_handle_new_msr(mos7840_port, regval);
526 else if (mos7840_port->MsrLsr == 1) 509 else if (mos7840_port->MsrLsr == 1)
@@ -532,8 +515,7 @@ exit:
532 result = usb_submit_urb(mos7840_port->int_urb, GFP_ATOMIC); 515 result = usb_submit_urb(mos7840_port->int_urb, GFP_ATOMIC);
533 spin_unlock(&mos7840_port->pool_lock); 516 spin_unlock(&mos7840_port->pool_lock);
534 if (result) { 517 if (result) {
535 dev_err(&urb->dev->dev, 518 dev_err(dev, "%s - Error %d submitting interrupt urb\n",
536 "%s - Error %d submitting interrupt urb\n",
537 __func__, result); 519 __func__, result);
538 } 520 }
539} 521}
@@ -570,12 +552,12 @@ static void mos7840_set_led_callback(struct urb *urb)
570 case -ENOENT: 552 case -ENOENT:
571 case -ESHUTDOWN: 553 case -ESHUTDOWN:
572 /* This urb is terminated, clean up */ 554 /* This urb is terminated, clean up */
573 dbg("%s - urb shutting down with status: %d", __func__, 555 dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d",
574 urb->status); 556 __func__, urb->status);
575 break; 557 break;
576 default: 558 default:
577 dbg("%s - nonzero urb status received: %d", __func__, 559 dev_dbg(&urb->dev->dev, "%s - nonzero urb status received: %d",
578 urb->status); 560 __func__, urb->status);
579 } 561 }
580} 562}
581 563
@@ -650,12 +632,12 @@ static void mos7840_interrupt_callback(struct urb *urb)
650 case -ENOENT: 632 case -ENOENT:
651 case -ESHUTDOWN: 633 case -ESHUTDOWN:
652 /* this urb is terminated, clean up */ 634 /* this urb is terminated, clean up */
653 dbg("%s - urb shutting down with status: %d", __func__, 635 dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n",
654 status); 636 __func__, status);
655 return; 637 return;
656 default: 638 default:
657 dbg("%s - nonzero urb status received: %d", __func__, 639 dev_dbg(&urb->dev->dev, "%s - nonzero urb status received: %d\n",
658 status); 640 __func__, status);
659 goto exit; 641 goto exit;
660 } 642 }
661 643
@@ -672,7 +654,7 @@ static void mos7840_interrupt_callback(struct urb *urb)
672 * Byte 5 FIFO status for both */ 654 * Byte 5 FIFO status for both */
673 655
674 if (length && length > 5) { 656 if (length && length > 5) {
675 dbg("%s", "Wrong data !!!"); 657 dev_dbg(&urb->dev->dev, "%s", "Wrong data !!!\n");
676 return; 658 return;
677 } 659 }
678 660
@@ -689,17 +671,17 @@ static void mos7840_interrupt_callback(struct urb *urb)
689 (__u16) (serial->minor)) + 1) << 8; 671 (__u16) (serial->minor)) + 1) << 8;
690 if (mos7840_port->open) { 672 if (mos7840_port->open) {
691 if (sp[i] & 0x01) { 673 if (sp[i] & 0x01) {
692 dbg("SP%d No Interrupt !!!", i); 674 dev_dbg(&urb->dev->dev, "SP%d No Interrupt !!!\n", i);
693 } else { 675 } else {
694 switch (sp[i] & 0x0f) { 676 switch (sp[i] & 0x0f) {
695 case SERIAL_IIR_RLS: 677 case SERIAL_IIR_RLS:
696 dbg("Serial Port %d: Receiver status error or ", i); 678 dev_dbg(&urb->dev->dev, "Serial Port %d: Receiver status error or \n", i);
697 dbg("address bit detected in 9-bit mode"); 679 dev_dbg(&urb->dev->dev, "address bit detected in 9-bit mode\n");
698 mos7840_port->MsrLsr = 1; 680 mos7840_port->MsrLsr = 1;
699 wreg = LINE_STATUS_REGISTER; 681 wreg = LINE_STATUS_REGISTER;
700 break; 682 break;
701 case SERIAL_IIR_MS: 683 case SERIAL_IIR_MS:
702 dbg("Serial Port %d: Modem status change", i); 684 dev_dbg(&urb->dev->dev, "Serial Port %d: Modem status change\n", i);
703 mos7840_port->MsrLsr = 0; 685 mos7840_port->MsrLsr = 0;
704 wreg = MODEM_STATUS_REGISTER; 686 wreg = MODEM_STATUS_REGISTER;
705 break; 687 break;
@@ -731,11 +713,11 @@ static int mos7840_port_paranoia_check(struct usb_serial_port *port,
731 const char *function) 713 const char *function)
732{ 714{
733 if (!port) { 715 if (!port) {
734 dbg("%s - port == NULL", function); 716 pr_debug("%s - port == NULL\n", function);
735 return -1; 717 return -1;
736 } 718 }
737 if (!port->serial) { 719 if (!port->serial) {
738 dbg("%s - port->serial == NULL", function); 720 pr_debug("%s - port->serial == NULL\n", function);
739 return -1; 721 return -1;
740 } 722 }
741 723
@@ -747,11 +729,11 @@ static int mos7840_serial_paranoia_check(struct usb_serial *serial,
747 const char *function) 729 const char *function)
748{ 730{
749 if (!serial) { 731 if (!serial) {
750 dbg("%s - serial == NULL", function); 732 pr_debug("%s - serial == NULL\n", function);
751 return -1; 733 return -1;
752 } 734 }
753 if (!serial->type) { 735 if (!serial->type) {
754 dbg("%s - serial->type == NULL!", function); 736 pr_debug("%s - serial->type == NULL!\n", function);
755 return -1; 737 return -1;
756 } 738 }
757 739
@@ -790,49 +772,44 @@ static void mos7840_bulk_in_callback(struct urb *urb)
790 int status = urb->status; 772 int status = urb->status;
791 773
792 mos7840_port = urb->context; 774 mos7840_port = urb->context;
793 if (!mos7840_port) { 775 if (!mos7840_port)
794 dbg("%s", "NULL mos7840_port pointer");
795 return; 776 return;
796 }
797 777
798 if (status) { 778 if (status) {
799 dbg("nonzero read bulk status received: %d", status); 779 dev_dbg(&urb->dev->dev, "nonzero read bulk status received: %d\n", status);
800 mos7840_port->read_urb_busy = false; 780 mos7840_port->read_urb_busy = false;
801 return; 781 return;
802 } 782 }
803 783
804 port = (struct usb_serial_port *)mos7840_port->port; 784 port = mos7840_port->port;
805 if (mos7840_port_paranoia_check(port, __func__)) { 785 if (mos7840_port_paranoia_check(port, __func__)) {
806 dbg("%s", "Port Paranoia failed");
807 mos7840_port->read_urb_busy = false; 786 mos7840_port->read_urb_busy = false;
808 return; 787 return;
809 } 788 }
810 789
811 serial = mos7840_get_usb_serial(port, __func__); 790 serial = mos7840_get_usb_serial(port, __func__);
812 if (!serial) { 791 if (!serial) {
813 dbg("%s", "Bad serial pointer");
814 mos7840_port->read_urb_busy = false; 792 mos7840_port->read_urb_busy = false;
815 return; 793 return;
816 } 794 }
817 795
818 data = urb->transfer_buffer; 796 data = urb->transfer_buffer;
797 usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data);
819 798
820 if (urb->actual_length) { 799 if (urb->actual_length) {
821 tty = tty_port_tty_get(&mos7840_port->port->port); 800 tty = tty_port_tty_get(&mos7840_port->port->port);
822 if (tty) { 801 if (tty) {
823 tty_insert_flip_string(tty, data, urb->actual_length); 802 tty_insert_flip_string(tty, data, urb->actual_length);
824 dbg(" %s ", data);
825 tty_flip_buffer_push(tty); 803 tty_flip_buffer_push(tty);
826 tty_kref_put(tty); 804 tty_kref_put(tty);
827 } 805 }
828 mos7840_port->icount.rx += urb->actual_length; 806 mos7840_port->icount.rx += urb->actual_length;
829 smp_wmb(); 807 smp_wmb();
830 dbg("mos7840_port->icount.rx is %d:", 808 dev_dbg(&port->dev, "mos7840_port->icount.rx is %d:\n", mos7840_port->icount.rx);
831 mos7840_port->icount.rx);
832 } 809 }
833 810
834 if (!mos7840_port->read_urb) { 811 if (!mos7840_port->read_urb) {
835 dbg("%s", "URB KILLED !!!"); 812 dev_dbg(&port->dev, "%s", "URB KILLED !!!\n");
836 mos7840_port->read_urb_busy = false; 813 mos7840_port->read_urb_busy = false;
837 return; 814 return;
838 } 815 }
@@ -850,7 +827,7 @@ static void mos7840_bulk_in_callback(struct urb *urb)
850 retval = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC); 827 retval = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC);
851 828
852 if (retval) { 829 if (retval) {
853 dbg("usb_submit_urb(read bulk) failed, retval = %d", retval); 830 dev_dbg(&port->dev, "usb_submit_urb(read bulk) failed, retval = %d\n", retval);
854 mos7840_port->read_urb_busy = false; 831 mos7840_port->read_urb_busy = false;
855 } 832 }
856} 833}
@@ -864,11 +841,13 @@ static void mos7840_bulk_in_callback(struct urb *urb)
864static void mos7840_bulk_out_data_callback(struct urb *urb) 841static void mos7840_bulk_out_data_callback(struct urb *urb)
865{ 842{
866 struct moschip_port *mos7840_port; 843 struct moschip_port *mos7840_port;
844 struct usb_serial_port *port;
867 struct tty_struct *tty; 845 struct tty_struct *tty;
868 int status = urb->status; 846 int status = urb->status;
869 int i; 847 int i;
870 848
871 mos7840_port = urb->context; 849 mos7840_port = urb->context;
850 port = mos7840_port->port;
872 spin_lock(&mos7840_port->pool_lock); 851 spin_lock(&mos7840_port->pool_lock);
873 for (i = 0; i < NUM_URBS; i++) { 852 for (i = 0; i < NUM_URBS; i++) {
874 if (urb == mos7840_port->write_urb_pool[i]) { 853 if (urb == mos7840_port->write_urb_pool[i]) {
@@ -879,16 +858,14 @@ static void mos7840_bulk_out_data_callback(struct urb *urb)
879 spin_unlock(&mos7840_port->pool_lock); 858 spin_unlock(&mos7840_port->pool_lock);
880 859
881 if (status) { 860 if (status) {
882 dbg("nonzero write bulk status received:%d", status); 861 dev_dbg(&port->dev, "nonzero write bulk status received:%d\n", status);
883 return; 862 return;
884 } 863 }
885 864
886 if (mos7840_port_paranoia_check(mos7840_port->port, __func__)) { 865 if (mos7840_port_paranoia_check(port, __func__))
887 dbg("%s", "Port Paranoia failed");
888 return; 866 return;
889 }
890 867
891 tty = tty_port_tty_get(&mos7840_port->port->port); 868 tty = tty_port_tty_get(&port->port);
892 if (tty && mos7840_port->open) 869 if (tty && mos7840_port->open)
893 tty_wakeup(tty); 870 tty_wakeup(tty);
894 tty_kref_put(tty); 871 tty_kref_put(tty);
@@ -929,17 +906,13 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
929 struct moschip_port *mos7840_port; 906 struct moschip_port *mos7840_port;
930 struct moschip_port *port0; 907 struct moschip_port *port0;
931 908
932 if (mos7840_port_paranoia_check(port, __func__)) { 909 if (mos7840_port_paranoia_check(port, __func__))
933 dbg("%s", "Port Paranoia failed");
934 return -ENODEV; 910 return -ENODEV;
935 }
936 911
937 serial = port->serial; 912 serial = port->serial;
938 913
939 if (mos7840_serial_paranoia_check(serial, __func__)) { 914 if (mos7840_serial_paranoia_check(serial, __func__))
940 dbg("%s", "Serial Paranoia failed");
941 return -ENODEV; 915 return -ENODEV;
942 }
943 916
944 mos7840_port = mos7840_get_port_private(port); 917 mos7840_port = mos7840_get_port_private(port);
945 port0 = mos7840_get_port_private(serial->port[0]); 918 port0 = mos7840_get_port_private(serial->port[0]);
@@ -990,20 +963,20 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
990 Data = 0x0; 963 Data = 0x0;
991 status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, &Data); 964 status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, &Data);
992 if (status < 0) { 965 if (status < 0) {
993 dbg("Reading Spreg failed"); 966 dev_dbg(&port->dev, "Reading Spreg failed\n");
994 return -1; 967 return -1;
995 } 968 }
996 Data |= 0x80; 969 Data |= 0x80;
997 status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data); 970 status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data);
998 if (status < 0) { 971 if (status < 0) {
999 dbg("writing Spreg failed"); 972 dev_dbg(&port->dev, "writing Spreg failed\n");
1000 return -1; 973 return -1;
1001 } 974 }
1002 975
1003 Data &= ~0x80; 976 Data &= ~0x80;
1004 status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data); 977 status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data);
1005 if (status < 0) { 978 if (status < 0) {
1006 dbg("writing Spreg failed"); 979 dev_dbg(&port->dev, "writing Spreg failed\n");
1007 return -1; 980 return -1;
1008 } 981 }
1009 /* End of block to be checked */ 982 /* End of block to be checked */
@@ -1012,7 +985,7 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
1012 status = mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset, 985 status = mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset,
1013 &Data); 986 &Data);
1014 if (status < 0) { 987 if (status < 0) {
1015 dbg("Reading Controlreg failed"); 988 dev_dbg(&port->dev, "Reading Controlreg failed\n");
1016 return -1; 989 return -1;
1017 } 990 }
1018 Data |= 0x08; /* Driver done bit */ 991 Data |= 0x08; /* Driver done bit */
@@ -1020,7 +993,7 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
1020 status = mos7840_set_reg_sync(port, 993 status = mos7840_set_reg_sync(port,
1021 mos7840_port->ControlRegOffset, Data); 994 mos7840_port->ControlRegOffset, Data);
1022 if (status < 0) { 995 if (status < 0) {
1023 dbg("writing Controlreg failed"); 996 dev_dbg(&port->dev, "writing Controlreg failed\n");
1024 return -1; 997 return -1;
1025 } 998 }
1026 /* do register settings here */ 999 /* do register settings here */
@@ -1031,21 +1004,21 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
1031 Data = 0x00; 1004 Data = 0x00;
1032 status = mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data); 1005 status = mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data);
1033 if (status < 0) { 1006 if (status < 0) {
1034 dbg("disabling interrupts failed"); 1007 dev_dbg(&port->dev, "disabling interrupts failed\n");
1035 return -1; 1008 return -1;
1036 } 1009 }
1037 /* Set FIFO_CONTROL_REGISTER to the default value */ 1010 /* Set FIFO_CONTROL_REGISTER to the default value */
1038 Data = 0x00; 1011 Data = 0x00;
1039 status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data); 1012 status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data);
1040 if (status < 0) { 1013 if (status < 0) {
1041 dbg("Writing FIFO_CONTROL_REGISTER failed"); 1014 dev_dbg(&port->dev, "Writing FIFO_CONTROL_REGISTER failed\n");
1042 return -1; 1015 return -1;
1043 } 1016 }
1044 1017
1045 Data = 0xcf; 1018 Data = 0xcf;
1046 status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data); 1019 status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data);
1047 if (status < 0) { 1020 if (status < 0) {
1048 dbg("Writing FIFO_CONTROL_REGISTER failed"); 1021 dev_dbg(&port->dev, "Writing FIFO_CONTROL_REGISTER failed\n");
1049 return -1; 1022 return -1;
1050 } 1023 }
1051 1024
@@ -1142,12 +1115,12 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
1142 * (can't set it up in mos7840_startup as the * 1115 * (can't set it up in mos7840_startup as the *
1143 * structures were not set up at that time.) */ 1116 * structures were not set up at that time.) */
1144 1117
1145 dbg("port number is %d", port->number); 1118 dev_dbg(&port->dev, "port number is %d\n", port->number);
1146 dbg("serial number is %d", port->serial->minor); 1119 dev_dbg(&port->dev, "serial number is %d\n", port->serial->minor);
1147 dbg("Bulkin endpoint is %d", port->bulk_in_endpointAddress); 1120 dev_dbg(&port->dev, "Bulkin endpoint is %d\n", port->bulk_in_endpointAddress);
1148 dbg("BulkOut endpoint is %d", port->bulk_out_endpointAddress); 1121 dev_dbg(&port->dev, "BulkOut endpoint is %d\n", port->bulk_out_endpointAddress);
1149 dbg("Interrupt endpoint is %d", port->interrupt_in_endpointAddress); 1122 dev_dbg(&port->dev, "Interrupt endpoint is %d\n", port->interrupt_in_endpointAddress);
1150 dbg("port's number in the device is %d", mos7840_port->port_num); 1123 dev_dbg(&port->dev, "port's number in the device is %d\n", mos7840_port->port_num);
1151 mos7840_port->read_urb = port->read_urb; 1124 mos7840_port->read_urb = port->read_urb;
1152 1125
1153 /* set up our bulk in urb */ 1126 /* set up our bulk in urb */
@@ -1171,8 +1144,7 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
1171 mos7840_bulk_in_callback, mos7840_port); 1144 mos7840_bulk_in_callback, mos7840_port);
1172 } 1145 }
1173 1146
1174 dbg("mos7840_open: bulkin endpoint is %d", 1147 dev_dbg(&port->dev, "%s: bulkin endpoint is %d\n", __func__, port->bulk_in_endpointAddress);
1175 port->bulk_in_endpointAddress);
1176 mos7840_port->read_urb_busy = true; 1148 mos7840_port->read_urb_busy = true;
1177 response = usb_submit_urb(mos7840_port->read_urb, GFP_KERNEL); 1149 response = usb_submit_urb(mos7840_port->read_urb, GFP_KERNEL);
1178 if (response) { 1150 if (response) {
@@ -1197,9 +1169,6 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
1197 mos7840_port->icount.tx = 0; 1169 mos7840_port->icount.tx = 0;
1198 mos7840_port->icount.rx = 0; 1170 mos7840_port->icount.rx = 0;
1199 1171
1200 dbg("usb_serial serial:%p mos7840_port:%p\n usb_serial_port port:%p",
1201 serial, mos7840_port, port);
1202
1203 return 0; 1172 return 0;
1204} 1173}
1205 1174
@@ -1221,10 +1190,8 @@ static int mos7840_chars_in_buffer(struct tty_struct *tty)
1221 unsigned long flags; 1190 unsigned long flags;
1222 struct moschip_port *mos7840_port; 1191 struct moschip_port *mos7840_port;
1223 1192
1224 if (mos7840_port_paranoia_check(port, __func__)) { 1193 if (mos7840_port_paranoia_check(port, __func__))
1225 dbg("%s", "Invalid port");
1226 return 0; 1194 return 0;
1227 }
1228 1195
1229 mos7840_port = mos7840_get_port_private(port); 1196 mos7840_port = mos7840_get_port_private(port);
1230 if (mos7840_port == NULL) 1197 if (mos7840_port == NULL)
@@ -1238,7 +1205,7 @@ static int mos7840_chars_in_buffer(struct tty_struct *tty)
1238 } 1205 }
1239 } 1206 }
1240 spin_unlock_irqrestore(&mos7840_port->pool_lock, flags); 1207 spin_unlock_irqrestore(&mos7840_port->pool_lock, flags);
1241 dbg("%s - returns %d", __func__, chars); 1208 dev_dbg(&port->dev, "%s - returns %d\n", __func__, chars);
1242 return chars; 1209 return chars;
1243 1210
1244} 1211}
@@ -1256,16 +1223,12 @@ static void mos7840_close(struct usb_serial_port *port)
1256 int j; 1223 int j;
1257 __u16 Data; 1224 __u16 Data;
1258 1225
1259 if (mos7840_port_paranoia_check(port, __func__)) { 1226 if (mos7840_port_paranoia_check(port, __func__))
1260 dbg("%s", "Port Paranoia failed");
1261 return; 1227 return;
1262 }
1263 1228
1264 serial = mos7840_get_usb_serial(port, __func__); 1229 serial = mos7840_get_usb_serial(port, __func__);
1265 if (!serial) { 1230 if (!serial)
1266 dbg("%s", "Serial Paranoia failed");
1267 return; 1231 return;
1268 }
1269 1232
1270 mos7840_port = mos7840_get_port_private(port); 1233 mos7840_port = mos7840_get_port_private(port);
1271 port0 = mos7840_get_port_private(serial->port[0]); 1234 port0 = mos7840_get_port_private(serial->port[0]);
@@ -1291,27 +1254,26 @@ static void mos7840_close(struct usb_serial_port *port)
1291 * and interrupt read if they exists */ 1254 * and interrupt read if they exists */
1292 if (serial->dev) { 1255 if (serial->dev) {
1293 if (mos7840_port->write_urb) { 1256 if (mos7840_port->write_urb) {
1294 dbg("%s", "Shutdown bulk write"); 1257 dev_dbg(&port->dev, "%s", "Shutdown bulk write\n");
1295 usb_kill_urb(mos7840_port->write_urb); 1258 usb_kill_urb(mos7840_port->write_urb);
1296 } 1259 }
1297 if (mos7840_port->read_urb) { 1260 if (mos7840_port->read_urb) {
1298 dbg("%s", "Shutdown bulk read"); 1261 dev_dbg(&port->dev, "%s", "Shutdown bulk read\n");
1299 usb_kill_urb(mos7840_port->read_urb); 1262 usb_kill_urb(mos7840_port->read_urb);
1300 mos7840_port->read_urb_busy = false; 1263 mos7840_port->read_urb_busy = false;
1301 } 1264 }
1302 if ((&mos7840_port->control_urb)) { 1265 if ((&mos7840_port->control_urb)) {
1303 dbg("%s", "Shutdown control read"); 1266 dev_dbg(&port->dev, "%s", "Shutdown control read\n");
1304 /*/ usb_kill_urb (mos7840_port->control_urb); */ 1267 /*/ usb_kill_urb (mos7840_port->control_urb); */
1305 } 1268 }
1306 } 1269 }
1307/* if(mos7840_port->ctrl_buf != NULL) */ 1270/* if(mos7840_port->ctrl_buf != NULL) */
1308/* kfree(mos7840_port->ctrl_buf); */ 1271/* kfree(mos7840_port->ctrl_buf); */
1309 port0->open_ports--; 1272 port0->open_ports--;
1310 dbg("mos7840_num_open_ports in close%d:in port%d", 1273 dev_dbg(&port->dev, "%s in close%d:in port%d\n", __func__, port0->open_ports, port->number);
1311 port0->open_ports, port->number);
1312 if (port0->open_ports == 0) { 1274 if (port0->open_ports == 0) {
1313 if (serial->port[0]->interrupt_in_urb) { 1275 if (serial->port[0]->interrupt_in_urb) {
1314 dbg("%s", "Shutdown interrupt_in_urb"); 1276 dev_dbg(&port->dev, "Shutdown interrupt_in_urb\n");
1315 usb_kill_urb(serial->port[0]->interrupt_in_urb); 1277 usb_kill_urb(serial->port[0]->interrupt_in_urb);
1316 } 1278 }
1317 } 1279 }
@@ -1363,7 +1325,7 @@ static void mos7840_block_until_chase_response(struct tty_struct *tty,
1363 /* No activity.. count down section */ 1325 /* No activity.. count down section */
1364 wait--; 1326 wait--;
1365 if (wait == 0) { 1327 if (wait == 0) {
1366 dbg("%s - TIMEOUT", __func__); 1328 dev_dbg(&mos7840_port->port->dev, "%s - TIMEOUT\n", __func__);
1367 return; 1329 return;
1368 } else { 1330 } else {
1369 /* Reset timeout value back to seconds */ 1331 /* Reset timeout value back to seconds */
@@ -1384,16 +1346,12 @@ static void mos7840_break(struct tty_struct *tty, int break_state)
1384 struct usb_serial *serial; 1346 struct usb_serial *serial;
1385 struct moschip_port *mos7840_port; 1347 struct moschip_port *mos7840_port;
1386 1348
1387 if (mos7840_port_paranoia_check(port, __func__)) { 1349 if (mos7840_port_paranoia_check(port, __func__))
1388 dbg("%s", "Port Paranoia failed");
1389 return; 1350 return;
1390 }
1391 1351
1392 serial = mos7840_get_usb_serial(port, __func__); 1352 serial = mos7840_get_usb_serial(port, __func__);
1393 if (!serial) { 1353 if (!serial)
1394 dbg("%s", "Serial Paranoia failed");
1395 return; 1354 return;
1396 }
1397 1355
1398 mos7840_port = mos7840_get_port_private(port); 1356 mos7840_port = mos7840_get_port_private(port);
1399 1357
@@ -1411,8 +1369,7 @@ static void mos7840_break(struct tty_struct *tty, int break_state)
1411 1369
1412 /* FIXME: no locking on shadowLCR anywhere in driver */ 1370 /* FIXME: no locking on shadowLCR anywhere in driver */
1413 mos7840_port->shadowLCR = data; 1371 mos7840_port->shadowLCR = data;
1414 dbg("mcs7840_break mos7840_port->shadowLCR is %x", 1372 dev_dbg(&port->dev, "%s mos7840_port->shadowLCR is %x\n", __func__, mos7840_port->shadowLCR);
1415 mos7840_port->shadowLCR);
1416 mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, 1373 mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER,
1417 mos7840_port->shadowLCR); 1374 mos7840_port->shadowLCR);
1418} 1375}
@@ -1433,17 +1390,12 @@ static int mos7840_write_room(struct tty_struct *tty)
1433 unsigned long flags; 1390 unsigned long flags;
1434 struct moschip_port *mos7840_port; 1391 struct moschip_port *mos7840_port;
1435 1392
1436 if (mos7840_port_paranoia_check(port, __func__)) { 1393 if (mos7840_port_paranoia_check(port, __func__))
1437 dbg("%s", "Invalid port");
1438 dbg("%s", " mos7840_write_room:leaving ...........");
1439 return -1; 1394 return -1;
1440 }
1441 1395
1442 mos7840_port = mos7840_get_port_private(port); 1396 mos7840_port = mos7840_get_port_private(port);
1443 if (mos7840_port == NULL) { 1397 if (mos7840_port == NULL)
1444 dbg("%s", "mos7840_break:leaving ...........");
1445 return -1; 1398 return -1;
1446 }
1447 1399
1448 spin_lock_irqsave(&mos7840_port->pool_lock, flags); 1400 spin_lock_irqsave(&mos7840_port->pool_lock, flags);
1449 for (i = 0; i < NUM_URBS; ++i) { 1401 for (i = 0; i < NUM_URBS; ++i) {
@@ -1453,7 +1405,7 @@ static int mos7840_write_room(struct tty_struct *tty)
1453 spin_unlock_irqrestore(&mos7840_port->pool_lock, flags); 1405 spin_unlock_irqrestore(&mos7840_port->pool_lock, flags);
1454 1406
1455 room = (room == 0) ? 0 : room - URB_TRANSFER_BUFFER_SIZE + 1; 1407 room = (room == 0) ? 0 : room - URB_TRANSFER_BUFFER_SIZE + 1;
1456 dbg("%s - returns %d", __func__, room); 1408 dev_dbg(&mos7840_port->port->dev, "%s - returns %d\n", __func__, room);
1457 return room; 1409 return room;
1458 1410
1459} 1411}
@@ -1486,9 +1438,8 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
1486 Data = 0x00; 1438 Data = 0x00;
1487 status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data); 1439 status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data);
1488 mos7840_port->shadowLCR = Data; 1440 mos7840_port->shadowLCR = Data;
1489 dbg("mos7840_write: LINE_CONTROL_REGISTER is %x", Data); 1441 dev_dbg(&port->dev, "%s: LINE_CONTROL_REGISTER is %x\n", __func__, Data);
1490 dbg("mos7840_write: mos7840_port->shadowLCR is %x", 1442 dev_dbg(&port->dev, "%s: mos7840_port->shadowLCR is %x\n", __func__, mos7840_port->shadowLCR);
1491 mos7840_port->shadowLCR);
1492 1443
1493 /* Data = 0x03; */ 1444 /* Data = 0x03; */
1494 /* status = mos7840_set_uart_reg(port,LINE_CONTROL_REGISTER,Data); */ 1445 /* status = mos7840_set_uart_reg(port,LINE_CONTROL_REGISTER,Data); */
@@ -1501,34 +1452,27 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
1501 /* status = mos7840_set_uart_reg(port,DIVISOR_LATCH_LSB,Data); */ 1452 /* status = mos7840_set_uart_reg(port,DIVISOR_LATCH_LSB,Data); */
1502 Data = 0x00; 1453 Data = 0x00;
1503 status = mos7840_get_uart_reg(port, DIVISOR_LATCH_LSB, &Data); 1454 status = mos7840_get_uart_reg(port, DIVISOR_LATCH_LSB, &Data);
1504 dbg("mos7840_write:DLL value is %x", Data); 1455 dev_dbg(&port->dev, "%s: DLL value is %x\n", __func__, Data);
1505 1456
1506 Data = 0x0; 1457 Data = 0x0;
1507 status = mos7840_get_uart_reg(port, DIVISOR_LATCH_MSB, &Data); 1458 status = mos7840_get_uart_reg(port, DIVISOR_LATCH_MSB, &Data);
1508 dbg("mos7840_write:DLM value is %x", Data); 1459 dev_dbg(&port->dev, "%s: DLM value is %x\n", __func__, Data);
1509 1460
1510 Data = Data & ~SERIAL_LCR_DLAB; 1461 Data = Data & ~SERIAL_LCR_DLAB;
1511 dbg("mos7840_write: mos7840_port->shadowLCR is %x", 1462 dev_dbg(&port->dev, "%s: mos7840_port->shadowLCR is %x\n", __func__, mos7840_port->shadowLCR);
1512 mos7840_port->shadowLCR);
1513 status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data); 1463 status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
1514#endif 1464#endif
1515 1465
1516 if (mos7840_port_paranoia_check(port, __func__)) { 1466 if (mos7840_port_paranoia_check(port, __func__))
1517 dbg("%s", "Port Paranoia failed");
1518 return -1; 1467 return -1;
1519 }
1520 1468
1521 serial = port->serial; 1469 serial = port->serial;
1522 if (mos7840_serial_paranoia_check(serial, __func__)) { 1470 if (mos7840_serial_paranoia_check(serial, __func__))
1523 dbg("%s", "Serial Paranoia failed");
1524 return -1; 1471 return -1;
1525 }
1526 1472
1527 mos7840_port = mos7840_get_port_private(port); 1473 mos7840_port = mos7840_get_port_private(port);
1528 if (mos7840_port == NULL) { 1474 if (mos7840_port == NULL)
1529 dbg("%s", "mos7840_port is NULL");
1530 return -1; 1475 return -1;
1531 }
1532 1476
1533 /* try to find a free urb in the list */ 1477 /* try to find a free urb in the list */
1534 urb = NULL; 1478 urb = NULL;
@@ -1538,14 +1482,14 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
1538 if (!mos7840_port->busy[i]) { 1482 if (!mos7840_port->busy[i]) {
1539 mos7840_port->busy[i] = 1; 1483 mos7840_port->busy[i] = 1;
1540 urb = mos7840_port->write_urb_pool[i]; 1484 urb = mos7840_port->write_urb_pool[i];
1541 dbg("URB:%d", i); 1485 dev_dbg(&port->dev, "URB:%d\n", i);
1542 break; 1486 break;
1543 } 1487 }
1544 } 1488 }
1545 spin_unlock_irqrestore(&mos7840_port->pool_lock, flags); 1489 spin_unlock_irqrestore(&mos7840_port->pool_lock, flags);
1546 1490
1547 if (urb == NULL) { 1491 if (urb == NULL) {
1548 dbg("%s - no more free urbs", __func__); 1492 dev_dbg(&port->dev, "%s - no more free urbs\n", __func__);
1549 goto exit; 1493 goto exit;
1550 } 1494 }
1551 1495
@@ -1585,7 +1529,7 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
1585 } 1529 }
1586 1530
1587 data1 = urb->transfer_buffer; 1531 data1 = urb->transfer_buffer;
1588 dbg("bulkout endpoint is %d", port->bulk_out_endpointAddress); 1532 dev_dbg(&port->dev, "bulkout endpoint is %d\n", port->bulk_out_endpointAddress);
1589 1533
1590 /* Turn on LED */ 1534 /* Turn on LED */
1591 if (mos7840_port->has_led && !mos7840_port->led_flag) { 1535 if (mos7840_port->has_led && !mos7840_port->led_flag) {
@@ -1608,7 +1552,7 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
1608 bytes_sent = transfer_size; 1552 bytes_sent = transfer_size;
1609 mos7840_port->icount.tx += transfer_size; 1553 mos7840_port->icount.tx += transfer_size;
1610 smp_wmb(); 1554 smp_wmb();
1611 dbg("mos7840_port->icount.tx is %d:", mos7840_port->icount.tx); 1555 dev_dbg(&port->dev, "mos7840_port->icount.tx is %d:\n", mos7840_port->icount.tx);
1612exit: 1556exit:
1613 return bytes_sent; 1557 return bytes_sent;
1614 1558
@@ -1626,12 +1570,8 @@ static void mos7840_throttle(struct tty_struct *tty)
1626 struct moschip_port *mos7840_port; 1570 struct moschip_port *mos7840_port;
1627 int status; 1571 int status;
1628 1572
1629 if (mos7840_port_paranoia_check(port, __func__)) { 1573 if (mos7840_port_paranoia_check(port, __func__))
1630 dbg("%s", "Invalid port");
1631 return; 1574 return;
1632 }
1633
1634 dbg("- port %d", port->number);
1635 1575
1636 mos7840_port = mos7840_get_port_private(port); 1576 mos7840_port = mos7840_get_port_private(port);
1637 1577
@@ -1639,7 +1579,7 @@ static void mos7840_throttle(struct tty_struct *tty)
1639 return; 1579 return;
1640 1580
1641 if (!mos7840_port->open) { 1581 if (!mos7840_port->open) {
1642 dbg("%s", "port not opened"); 1582 dev_dbg(&port->dev, "%s", "port not opened\n");
1643 return; 1583 return;
1644 } 1584 }
1645 1585
@@ -1672,16 +1612,14 @@ static void mos7840_unthrottle(struct tty_struct *tty)
1672 int status; 1612 int status;
1673 struct moschip_port *mos7840_port = mos7840_get_port_private(port); 1613 struct moschip_port *mos7840_port = mos7840_get_port_private(port);
1674 1614
1675 if (mos7840_port_paranoia_check(port, __func__)) { 1615 if (mos7840_port_paranoia_check(port, __func__))
1676 dbg("%s", "Invalid port");
1677 return; 1616 return;
1678 }
1679 1617
1680 if (mos7840_port == NULL) 1618 if (mos7840_port == NULL)
1681 return; 1619 return;
1682 1620
1683 if (!mos7840_port->open) { 1621 if (!mos7840_port->open) {
1684 dbg("%s - port not opened", __func__); 1622 dev_dbg(&port->dev, "%s - port not opened\n", __func__);
1685 return; 1623 return;
1686 } 1624 }
1687 1625
@@ -1726,7 +1664,7 @@ static int mos7840_tiocmget(struct tty_struct *tty)
1726 | ((msr & MOS7840_MSR_RI) ? TIOCM_RI : 0) 1664 | ((msr & MOS7840_MSR_RI) ? TIOCM_RI : 0)
1727 | ((msr & MOS7840_MSR_DSR) ? TIOCM_DSR : 0); 1665 | ((msr & MOS7840_MSR_DSR) ? TIOCM_DSR : 0);
1728 1666
1729 dbg("%s - 0x%04X", __func__, result); 1667 dev_dbg(&port->dev, "%s - 0x%04X\n", __func__, result);
1730 1668
1731 return result; 1669 return result;
1732} 1670}
@@ -1764,7 +1702,7 @@ static int mos7840_tiocmset(struct tty_struct *tty,
1764 1702
1765 status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, mcr); 1703 status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, mcr);
1766 if (status < 0) { 1704 if (status < 0) {
1767 dbg("setting MODEM_CONTROL_REGISTER Failed"); 1705 dev_dbg(&port->dev, "setting MODEM_CONTROL_REGISTER Failed\n");
1768 return status; 1706 return status;
1769 } 1707 }
1770 1708
@@ -1776,10 +1714,11 @@ static int mos7840_tiocmset(struct tty_struct *tty,
1776 * this function calculates the proper baud rate divisor for the specified 1714 * this function calculates the proper baud rate divisor for the specified
1777 * baud rate. 1715 * baud rate.
1778 *****************************************************************************/ 1716 *****************************************************************************/
1779static int mos7840_calc_baud_rate_divisor(int baudRate, int *divisor, 1717static int mos7840_calc_baud_rate_divisor(struct usb_serial_port *port,
1718 int baudRate, int *divisor,
1780 __u16 *clk_sel_val) 1719 __u16 *clk_sel_val)
1781{ 1720{
1782 dbg("%s - %d", __func__, baudRate); 1721 dev_dbg(&port->dev, "%s - %d\n", __func__, baudRate);
1783 1722
1784 if (baudRate <= 115200) { 1723 if (baudRate <= 115200) {
1785 *divisor = 115200 / baudRate; 1724 *divisor = 115200 / baudRate;
@@ -1832,11 +1771,11 @@ static int mos7840_calc_baud_rate_divisor(int baudRate, int *divisor,
1832 custom++; 1771 custom++;
1833 *divisor = custom; 1772 *divisor = custom;
1834 1773
1835 dbg(" Baud %d = %d", baudrate, custom); 1774 dev_dbg(&port->dev, " Baud %d = %d\n", baudrate, custom);
1836 return 0; 1775 return 0;
1837 } 1776 }
1838 1777
1839 dbg("%s", " Baud calculation Failed..."); 1778 dev_dbg(&port->dev, "%s", " Baud calculation Failed...\n");
1840 return -1; 1779 return -1;
1841#endif 1780#endif
1842} 1781}
@@ -1860,21 +1799,17 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
1860 if (mos7840_port == NULL) 1799 if (mos7840_port == NULL)
1861 return -1; 1800 return -1;
1862 1801
1863 port = (struct usb_serial_port *)mos7840_port->port; 1802 port = mos7840_port->port;
1864 if (mos7840_port_paranoia_check(port, __func__)) { 1803 if (mos7840_port_paranoia_check(port, __func__))
1865 dbg("%s", "Invalid port");
1866 return -1; 1804 return -1;
1867 }
1868 1805
1869 if (mos7840_serial_paranoia_check(port->serial, __func__)) { 1806 if (mos7840_serial_paranoia_check(port->serial, __func__))
1870 dbg("%s", "Invalid Serial");
1871 return -1; 1807 return -1;
1872 }
1873 1808
1874 number = mos7840_port->port->number - mos7840_port->port->serial->minor; 1809 number = mos7840_port->port->number - mos7840_port->port->serial->minor;
1875 1810
1876 dbg("%s - port = %d, baud = %d", __func__, 1811 dev_dbg(&port->dev, "%s - port = %d, baud = %d\n", __func__,
1877 mos7840_port->port->number, baudRate); 1812 mos7840_port->port->number, baudRate);
1878 /* reset clk_uart_sel in spregOffset */ 1813 /* reset clk_uart_sel in spregOffset */
1879 if (baudRate > 115200) { 1814 if (baudRate > 115200) {
1880#ifdef HW_flow_control 1815#ifdef HW_flow_control
@@ -1885,7 +1820,7 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
1885 status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, 1820 status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
1886 Data); 1821 Data);
1887 if (status < 0) { 1822 if (status < 0) {
1888 dbg("Writing spreg failed in set_serial_baud"); 1823 dev_dbg(&port->dev, "Writing spreg failed in set_serial_baud\n");
1889 return -1; 1824 return -1;
1890 } 1825 }
1891#endif 1826#endif
@@ -1898,7 +1833,7 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
1898 status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, 1833 status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
1899 Data); 1834 Data);
1900 if (status < 0) { 1835 if (status < 0) {
1901 dbg("Writing spreg failed in set_serial_baud"); 1836 dev_dbg(&port->dev, "Writing spreg failed in set_serial_baud\n");
1902 return -1; 1837 return -1;
1903 } 1838 }
1904#endif 1839#endif
@@ -1908,19 +1843,19 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
1908 if (1) { /* baudRate <= 115200) */ 1843 if (1) { /* baudRate <= 115200) */
1909 clk_sel_val = 0x0; 1844 clk_sel_val = 0x0;
1910 Data = 0x0; 1845 Data = 0x0;
1911 status = mos7840_calc_baud_rate_divisor(baudRate, &divisor, 1846 status = mos7840_calc_baud_rate_divisor(port, baudRate, &divisor,
1912 &clk_sel_val); 1847 &clk_sel_val);
1913 status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, 1848 status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset,
1914 &Data); 1849 &Data);
1915 if (status < 0) { 1850 if (status < 0) {
1916 dbg("reading spreg failed in set_serial_baud"); 1851 dev_dbg(&port->dev, "reading spreg failed in set_serial_baud\n");
1917 return -1; 1852 return -1;
1918 } 1853 }
1919 Data = (Data & 0x8f) | clk_sel_val; 1854 Data = (Data & 0x8f) | clk_sel_val;
1920 status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, 1855 status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset,
1921 Data); 1856 Data);
1922 if (status < 0) { 1857 if (status < 0) {
1923 dbg("Writing spreg failed in set_serial_baud"); 1858 dev_dbg(&port->dev, "Writing spreg failed in set_serial_baud\n");
1924 return -1; 1859 return -1;
1925 } 1860 }
1926 /* Calculate the Divisor */ 1861 /* Calculate the Divisor */
@@ -1936,11 +1871,11 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
1936 1871
1937 /* Write the divisor */ 1872 /* Write the divisor */
1938 Data = (unsigned char)(divisor & 0xff); 1873 Data = (unsigned char)(divisor & 0xff);
1939 dbg("set_serial_baud Value to write DLL is %x", Data); 1874 dev_dbg(&port->dev, "set_serial_baud Value to write DLL is %x\n", Data);
1940 mos7840_set_uart_reg(port, DIVISOR_LATCH_LSB, Data); 1875 mos7840_set_uart_reg(port, DIVISOR_LATCH_LSB, Data);
1941 1876
1942 Data = (unsigned char)((divisor & 0xff00) >> 8); 1877 Data = (unsigned char)((divisor & 0xff00) >> 8);
1943 dbg("set_serial_baud Value to write DLM is %x", Data); 1878 dev_dbg(&port->dev, "set_serial_baud Value to write DLM is %x\n", Data);
1944 mos7840_set_uart_reg(port, DIVISOR_LATCH_MSB, Data); 1879 mos7840_set_uart_reg(port, DIVISOR_LATCH_MSB, Data);
1945 1880
1946 /* Disable access to divisor latch */ 1881 /* Disable access to divisor latch */
@@ -1975,24 +1910,18 @@ static void mos7840_change_port_settings(struct tty_struct *tty,
1975 if (mos7840_port == NULL) 1910 if (mos7840_port == NULL)
1976 return; 1911 return;
1977 1912
1978 port = (struct usb_serial_port *)mos7840_port->port; 1913 port = mos7840_port->port;
1979 1914
1980 if (mos7840_port_paranoia_check(port, __func__)) { 1915 if (mos7840_port_paranoia_check(port, __func__))
1981 dbg("%s", "Invalid port");
1982 return; 1916 return;
1983 }
1984 1917
1985 if (mos7840_serial_paranoia_check(port->serial, __func__)) { 1918 if (mos7840_serial_paranoia_check(port->serial, __func__))
1986 dbg("%s", "Invalid Serial");
1987 return; 1919 return;
1988 }
1989 1920
1990 serial = port->serial; 1921 serial = port->serial;
1991 1922
1992 dbg("%s - port %d", __func__, mos7840_port->port->number);
1993
1994 if (!mos7840_port->open) { 1923 if (!mos7840_port->open) {
1995 dbg("%s - port not opened", __func__); 1924 dev_dbg(&port->dev, "%s - port not opened\n", __func__);
1996 return; 1925 return;
1997 } 1926 }
1998 1927
@@ -2027,14 +1956,14 @@ static void mos7840_change_port_settings(struct tty_struct *tty,
2027 if (cflag & PARENB) { 1956 if (cflag & PARENB) {
2028 if (cflag & PARODD) { 1957 if (cflag & PARODD) {
2029 lParity = LCR_PAR_ODD; 1958 lParity = LCR_PAR_ODD;
2030 dbg("%s - parity = odd", __func__); 1959 dev_dbg(&port->dev, "%s - parity = odd\n", __func__);
2031 } else { 1960 } else {
2032 lParity = LCR_PAR_EVEN; 1961 lParity = LCR_PAR_EVEN;
2033 dbg("%s - parity = even", __func__); 1962 dev_dbg(&port->dev, "%s - parity = even\n", __func__);
2034 } 1963 }
2035 1964
2036 } else { 1965 } else {
2037 dbg("%s - parity = none", __func__); 1966 dev_dbg(&port->dev, "%s - parity = none\n", __func__);
2038 } 1967 }
2039 1968
2040 if (cflag & CMSPAR) 1969 if (cflag & CMSPAR)
@@ -2043,10 +1972,10 @@ static void mos7840_change_port_settings(struct tty_struct *tty,
2043 /* Change the Stop bit */ 1972 /* Change the Stop bit */
2044 if (cflag & CSTOPB) { 1973 if (cflag & CSTOPB) {
2045 lStop = LCR_STOP_2; 1974 lStop = LCR_STOP_2;
2046 dbg("%s - stop bits = 2", __func__); 1975 dev_dbg(&port->dev, "%s - stop bits = 2\n", __func__);
2047 } else { 1976 } else {
2048 lStop = LCR_STOP_1; 1977 lStop = LCR_STOP_1;
2049 dbg("%s - stop bits = 1", __func__); 1978 dev_dbg(&port->dev, "%s - stop bits = 1\n", __func__);
2050 } 1979 }
2051 1980
2052 /* Update the LCR with the correct value */ 1981 /* Update the LCR with the correct value */
@@ -2054,8 +1983,8 @@ static void mos7840_change_port_settings(struct tty_struct *tty,
2054 ~(LCR_BITS_MASK | LCR_STOP_MASK | LCR_PAR_MASK); 1983 ~(LCR_BITS_MASK | LCR_STOP_MASK | LCR_PAR_MASK);
2055 mos7840_port->shadowLCR |= (lData | lParity | lStop); 1984 mos7840_port->shadowLCR |= (lData | lParity | lStop);
2056 1985
2057 dbg("mos7840_change_port_settings mos7840_port->shadowLCR is %x", 1986 dev_dbg(&port->dev, "%s - mos7840_port->shadowLCR is %x\n", __func__,
2058 mos7840_port->shadowLCR); 1987 mos7840_port->shadowLCR);
2059 /* Disable Interrupts */ 1988 /* Disable Interrupts */
2060 Data = 0x00; 1989 Data = 0x00;
2061 mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data); 1990 mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data);
@@ -2096,11 +2025,11 @@ static void mos7840_change_port_settings(struct tty_struct *tty,
2096 2025
2097 if (!baud) { 2026 if (!baud) {
2098 /* pick a default, any default... */ 2027 /* pick a default, any default... */
2099 dbg("%s", "Picked default baud..."); 2028 dev_dbg(&port->dev, "%s", "Picked default baud...\n");
2100 baud = 9600; 2029 baud = 9600;
2101 } 2030 }
2102 2031
2103 dbg("%s - baud rate = %d", __func__, baud); 2032 dev_dbg(&port->dev, "%s - baud rate = %d\n", __func__, baud);
2104 status = mos7840_send_cmd_write_baud_rate(mos7840_port, baud); 2033 status = mos7840_send_cmd_write_baud_rate(mos7840_port, baud);
2105 2034
2106 /* Enable Interrupts */ 2035 /* Enable Interrupts */
@@ -2111,15 +2040,15 @@ static void mos7840_change_port_settings(struct tty_struct *tty,
2111 mos7840_port->read_urb_busy = true; 2040 mos7840_port->read_urb_busy = true;
2112 status = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC); 2041 status = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC);
2113 if (status) { 2042 if (status) {
2114 dbg("usb_submit_urb(read bulk) failed, status = %d", 2043 dev_dbg(&port->dev, "usb_submit_urb(read bulk) failed, status = %d\n",
2115 status); 2044 status);
2116 mos7840_port->read_urb_busy = false; 2045 mos7840_port->read_urb_busy = false;
2117 } 2046 }
2118 } 2047 }
2119 wake_up(&mos7840_port->delta_msr_wait); 2048 wake_up(&mos7840_port->delta_msr_wait);
2120 mos7840_port->delta_msr_cond = 1; 2049 mos7840_port->delta_msr_cond = 1;
2121 dbg("mos7840_change_port_settings mos7840_port->shadowLCR is End %x", 2050 dev_dbg(&port->dev, "%s - mos7840_port->shadowLCR is End %x\n", __func__,
2122 mos7840_port->shadowLCR); 2051 mos7840_port->shadowLCR);
2123} 2052}
2124 2053
2125/***************************************************************************** 2054/*****************************************************************************
@@ -2137,17 +2066,13 @@ static void mos7840_set_termios(struct tty_struct *tty,
2137 struct usb_serial *serial; 2066 struct usb_serial *serial;
2138 struct moschip_port *mos7840_port; 2067 struct moschip_port *mos7840_port;
2139 2068
2140 if (mos7840_port_paranoia_check(port, __func__)) { 2069 if (mos7840_port_paranoia_check(port, __func__))
2141 dbg("%s", "Invalid port");
2142 return; 2070 return;
2143 }
2144 2071
2145 serial = port->serial; 2072 serial = port->serial;
2146 2073
2147 if (mos7840_serial_paranoia_check(serial, __func__)) { 2074 if (mos7840_serial_paranoia_check(serial, __func__))
2148 dbg("%s", "Invalid Serial");
2149 return; 2075 return;
2150 }
2151 2076
2152 mos7840_port = mos7840_get_port_private(port); 2077 mos7840_port = mos7840_get_port_private(port);
2153 2078
@@ -2155,26 +2080,26 @@ static void mos7840_set_termios(struct tty_struct *tty,
2155 return; 2080 return;
2156 2081
2157 if (!mos7840_port->open) { 2082 if (!mos7840_port->open) {
2158 dbg("%s - port not opened", __func__); 2083 dev_dbg(&port->dev, "%s - port not opened\n", __func__);
2159 return; 2084 return;
2160 } 2085 }
2161 2086
2162 dbg("%s", "setting termios - "); 2087 dev_dbg(&port->dev, "%s", "setting termios - \n");
2163 2088
2164 cflag = tty->termios.c_cflag; 2089 cflag = tty->termios.c_cflag;
2165 2090
2166 dbg("%s - clfag %08x iflag %08x", __func__, 2091 dev_dbg(&port->dev, "%s - clfag %08x iflag %08x\n", __func__,
2167 tty->termios.c_cflag, RELEVANT_IFLAG(tty->termios.c_iflag)); 2092 tty->termios.c_cflag, RELEVANT_IFLAG(tty->termios.c_iflag));
2168 dbg("%s - old clfag %08x old iflag %08x", __func__, 2093 dev_dbg(&port->dev, "%s - old clfag %08x old iflag %08x\n", __func__,
2169 old_termios->c_cflag, RELEVANT_IFLAG(old_termios->c_iflag)); 2094 old_termios->c_cflag, RELEVANT_IFLAG(old_termios->c_iflag));
2170 dbg("%s - port %d", __func__, port->number); 2095 dev_dbg(&port->dev, "%s - port %d\n", __func__, port->number);
2171 2096
2172 /* change the port settings to the new ones specified */ 2097 /* change the port settings to the new ones specified */
2173 2098
2174 mos7840_change_port_settings(tty, mos7840_port, old_termios); 2099 mos7840_change_port_settings(tty, mos7840_port, old_termios);
2175 2100
2176 if (!mos7840_port->read_urb) { 2101 if (!mos7840_port->read_urb) {
2177 dbg("%s", "URB KILLED !!!!!"); 2102 dev_dbg(&port->dev, "%s", "URB KILLED !!!!!\n");
2178 return; 2103 return;
2179 } 2104 }
2180 2105
@@ -2182,7 +2107,7 @@ static void mos7840_set_termios(struct tty_struct *tty,
2182 mos7840_port->read_urb_busy = true; 2107 mos7840_port->read_urb_busy = true;
2183 status = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC); 2108 status = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC);
2184 if (status) { 2109 if (status) {
2185 dbg("usb_submit_urb(read bulk) failed, status = %d", 2110 dev_dbg(&port->dev, "usb_submit_urb(read bulk) failed, status = %d\n",
2186 status); 2111 status);
2187 mos7840_port->read_urb_busy = false; 2112 mos7840_port->read_urb_busy = false;
2188 } 2113 }
@@ -2207,10 +2132,8 @@ static int mos7840_get_lsr_info(struct tty_struct *tty,
2207 unsigned int result = 0; 2132 unsigned int result = 0;
2208 2133
2209 count = mos7840_chars_in_buffer(tty); 2134 count = mos7840_chars_in_buffer(tty);
2210 if (count == 0) { 2135 if (count == 0)
2211 dbg("%s -- Empty", __func__);
2212 result = TIOCSER_TEMT; 2136 result = TIOCSER_TEMT;
2213 }
2214 2137
2215 if (copy_to_user(value, &result, sizeof(int))) 2138 if (copy_to_user(value, &result, sizeof(int)))
2216 return -EFAULT; 2139 return -EFAULT;
@@ -2273,8 +2196,8 @@ static int mos7840_get_icount(struct tty_struct *tty,
2273 icount->brk = cnow.brk; 2196 icount->brk = cnow.brk;
2274 icount->buf_overrun = cnow.buf_overrun; 2197 icount->buf_overrun = cnow.buf_overrun;
2275 2198
2276 dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, 2199 dev_dbg(&port->dev, "%s TIOCGICOUNT RX=%d, TX=%d\n", __func__,
2277 port->number, icount->rx, icount->tx); 2200 icount->rx, icount->tx);
2278 return 0; 2201 return 0;
2279} 2202}
2280 2203
@@ -2293,35 +2216,33 @@ static int mos7840_ioctl(struct tty_struct *tty,
2293 struct async_icount cnow; 2216 struct async_icount cnow;
2294 struct async_icount cprev; 2217 struct async_icount cprev;
2295 2218
2296 if (mos7840_port_paranoia_check(port, __func__)) { 2219 if (mos7840_port_paranoia_check(port, __func__))
2297 dbg("%s", "Invalid port");
2298 return -1; 2220 return -1;
2299 }
2300 2221
2301 mos7840_port = mos7840_get_port_private(port); 2222 mos7840_port = mos7840_get_port_private(port);
2302 2223
2303 if (mos7840_port == NULL) 2224 if (mos7840_port == NULL)
2304 return -1; 2225 return -1;
2305 2226
2306 dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); 2227 dev_dbg(&port->dev, "%s - cmd = 0x%x\n", __func__, cmd);
2307 2228
2308 switch (cmd) { 2229 switch (cmd) {
2309 /* return number of bytes available */ 2230 /* return number of bytes available */
2310 2231
2311 case TIOCSERGETLSR: 2232 case TIOCSERGETLSR:
2312 dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); 2233 dev_dbg(&port->dev, "%s TIOCSERGETLSR\n", __func__);
2313 return mos7840_get_lsr_info(tty, argp); 2234 return mos7840_get_lsr_info(tty, argp);
2314 2235
2315 case TIOCGSERIAL: 2236 case TIOCGSERIAL:
2316 dbg("%s (%d) TIOCGSERIAL", __func__, port->number); 2237 dev_dbg(&port->dev, "%s TIOCGSERIAL\n", __func__);
2317 return mos7840_get_serial_info(mos7840_port, argp); 2238 return mos7840_get_serial_info(mos7840_port, argp);
2318 2239
2319 case TIOCSSERIAL: 2240 case TIOCSSERIAL:
2320 dbg("%s (%d) TIOCSSERIAL", __func__, port->number); 2241 dev_dbg(&port->dev, "%s TIOCSSERIAL\n", __func__);
2321 break; 2242 break;
2322 2243
2323 case TIOCMIWAIT: 2244 case TIOCMIWAIT:
2324 dbg("%s (%d) TIOCMIWAIT", __func__, port->number); 2245 dev_dbg(&port->dev, "%s TIOCMIWAIT\n", __func__);
2325 cprev = mos7840_port->icount; 2246 cprev = mos7840_port->icount;
2326 while (1) { 2247 while (1) {
2327 /* interruptible_sleep_on(&mos7840_port->delta_msr_wait); */ 2248 /* interruptible_sleep_on(&mos7840_port->delta_msr_wait); */
@@ -2437,11 +2358,6 @@ static int mos7840_startup(struct usb_serial *serial)
2437 int i, status; 2358 int i, status;
2438 __u16 Data; 2359 __u16 Data;
2439 2360
2440 if (!serial) {
2441 dbg("%s", "Invalid Handler");
2442 return -1;
2443 }
2444
2445 dev = serial->dev; 2361 dev = serial->dev;
2446 2362
2447 /* we set up the pointers to the endpoints in the mos7840_open * 2363 /* we set up the pointers to the endpoints in the mos7840_open *
@@ -2449,7 +2365,7 @@ static int mos7840_startup(struct usb_serial *serial)
2449 2365
2450 /* set up port private structures */ 2366 /* set up port private structures */
2451 for (i = 0; i < serial->num_ports; ++i) { 2367 for (i = 0; i < serial->num_ports; ++i) {
2452 dbg ("mos7840_startup: configuring port %d............", i); 2368 dev_dbg(&dev->dev, "mos7840_startup: configuring port %d............\n", i);
2453 mos7840_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL); 2369 mos7840_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL);
2454 if (mos7840_port == NULL) { 2370 if (mos7840_port == NULL) {
2455 dev_err(&dev->dev, "%s - Out of memory\n", __func__); 2371 dev_err(&dev->dev, "%s - Out of memory\n", __func__);
@@ -2470,10 +2386,10 @@ static int mos7840_startup(struct usb_serial *serial)
2470 * usb-serial.c:get_free_serial() and cannot therefore be used 2386 * usb-serial.c:get_free_serial() and cannot therefore be used
2471 * to index device instances */ 2387 * to index device instances */
2472 mos7840_port->port_num = i + 1; 2388 mos7840_port->port_num = i + 1;
2473 dbg ("serial->port[i]->number = %d", serial->port[i]->number); 2389 dev_dbg(&dev->dev, "serial->port[i]->number = %d\n", serial->port[i]->number);
2474 dbg ("serial->port[i]->serial->minor = %d", serial->port[i]->serial->minor); 2390 dev_dbg(&dev->dev, "serial->port[i]->serial->minor = %d\n", serial->port[i]->serial->minor);
2475 dbg ("mos7840_port->port_num = %d", mos7840_port->port_num); 2391 dev_dbg(&dev->dev, "mos7840_port->port_num = %d\n", mos7840_port->port_num);
2476 dbg ("serial->minor = %d", serial->minor); 2392 dev_dbg(&dev->dev, "serial->minor = %d\n", serial->minor);
2477 2393
2478 if (mos7840_port->port_num == 1) { 2394 if (mos7840_port->port_num == 1) {
2479 mos7840_port->SpRegOffset = 0x0; 2395 mos7840_port->SpRegOffset = 0x0;
@@ -2500,18 +2416,17 @@ static int mos7840_startup(struct usb_serial *serial)
2500 mos7840_port->ControlRegOffset = 0xd; 2416 mos7840_port->ControlRegOffset = 0xd;
2501 mos7840_port->DcrRegOffset = 0x1c; 2417 mos7840_port->DcrRegOffset = 0x1c;
2502 } 2418 }
2503 mos7840_dump_serial_port(mos7840_port); 2419 mos7840_dump_serial_port(serial->port[i], mos7840_port);
2504 mos7840_set_port_private(serial->port[i], mos7840_port); 2420 mos7840_set_port_private(serial->port[i], mos7840_port);
2505 2421
2506 /* enable rx_disable bit in control register */ 2422 /* enable rx_disable bit in control register */
2507 status = mos7840_get_reg_sync(serial->port[i], 2423 status = mos7840_get_reg_sync(serial->port[i],
2508 mos7840_port->ControlRegOffset, &Data); 2424 mos7840_port->ControlRegOffset, &Data);
2509 if (status < 0) { 2425 if (status < 0) {
2510 dbg("Reading ControlReg failed status-0x%x", status); 2426 dev_dbg(&dev->dev, "Reading ControlReg failed status-0x%x\n", status);
2511 break; 2427 break;
2512 } else 2428 } else
2513 dbg("ControlReg Reading success val is %x, status%d", 2429 dev_dbg(&dev->dev, "ControlReg Reading success val is %x, status%d\n", Data, status);
2514 Data, status);
2515 Data |= 0x08; /* setting driver done bit */ 2430 Data |= 0x08; /* setting driver done bit */
2516 Data |= 0x04; /* sp1_bit to have cts change reflect in 2431 Data |= 0x04; /* sp1_bit to have cts change reflect in
2517 modem status reg */ 2432 modem status reg */
@@ -2520,11 +2435,10 @@ static int mos7840_startup(struct usb_serial *serial)
2520 status = mos7840_set_reg_sync(serial->port[i], 2435 status = mos7840_set_reg_sync(serial->port[i],
2521 mos7840_port->ControlRegOffset, Data); 2436 mos7840_port->ControlRegOffset, Data);
2522 if (status < 0) { 2437 if (status < 0) {
2523 dbg("Writing ControlReg failed(rx_disable) status-0x%x", status); 2438 dev_dbg(&dev->dev, "Writing ControlReg failed(rx_disable) status-0x%x\n", status);
2524 break; 2439 break;
2525 } else 2440 } else
2526 dbg("ControlReg Writing success(rx_disable) status%d", 2441 dev_dbg(&dev->dev, "ControlReg Writing success(rx_disable) status%d\n", status);
2527 status);
2528 2442
2529 /* Write default values in DCR (i.e 0x01 in DCR0, 0x05 in DCR2 2443 /* Write default values in DCR (i.e 0x01 in DCR0, 0x05 in DCR2
2530 and 0x24 in DCR3 */ 2444 and 0x24 in DCR3 */
@@ -2532,61 +2446,57 @@ static int mos7840_startup(struct usb_serial *serial)
2532 status = mos7840_set_reg_sync(serial->port[i], 2446 status = mos7840_set_reg_sync(serial->port[i],
2533 (__u16) (mos7840_port->DcrRegOffset + 0), Data); 2447 (__u16) (mos7840_port->DcrRegOffset + 0), Data);
2534 if (status < 0) { 2448 if (status < 0) {
2535 dbg("Writing DCR0 failed status-0x%x", status); 2449 dev_dbg(&dev->dev, "Writing DCR0 failed status-0x%x\n", status);
2536 break; 2450 break;
2537 } else 2451 } else
2538 dbg("DCR0 Writing success status%d", status); 2452 dev_dbg(&dev->dev, "DCR0 Writing success status%d\n", status);
2539 2453
2540 Data = 0x05; 2454 Data = 0x05;
2541 status = mos7840_set_reg_sync(serial->port[i], 2455 status = mos7840_set_reg_sync(serial->port[i],
2542 (__u16) (mos7840_port->DcrRegOffset + 1), Data); 2456 (__u16) (mos7840_port->DcrRegOffset + 1), Data);
2543 if (status < 0) { 2457 if (status < 0) {
2544 dbg("Writing DCR1 failed status-0x%x", status); 2458 dev_dbg(&dev->dev, "Writing DCR1 failed status-0x%x\n", status);
2545 break; 2459 break;
2546 } else 2460 } else
2547 dbg("DCR1 Writing success status%d", status); 2461 dev_dbg(&dev->dev, "DCR1 Writing success status%d\n", status);
2548 2462
2549 Data = 0x24; 2463 Data = 0x24;
2550 status = mos7840_set_reg_sync(serial->port[i], 2464 status = mos7840_set_reg_sync(serial->port[i],
2551 (__u16) (mos7840_port->DcrRegOffset + 2), Data); 2465 (__u16) (mos7840_port->DcrRegOffset + 2), Data);
2552 if (status < 0) { 2466 if (status < 0) {
2553 dbg("Writing DCR2 failed status-0x%x", status); 2467 dev_dbg(&dev->dev, "Writing DCR2 failed status-0x%x\n", status);
2554 break; 2468 break;
2555 } else 2469 } else
2556 dbg("DCR2 Writing success status%d", status); 2470 dev_dbg(&dev->dev, "DCR2 Writing success status%d\n", status);
2557 2471
2558 /* write values in clkstart0x0 and clkmulti 0x20 */ 2472 /* write values in clkstart0x0 and clkmulti 0x20 */
2559 Data = 0x0; 2473 Data = 0x0;
2560 status = mos7840_set_reg_sync(serial->port[i], 2474 status = mos7840_set_reg_sync(serial->port[i],
2561 CLK_START_VALUE_REGISTER, Data); 2475 CLK_START_VALUE_REGISTER, Data);
2562 if (status < 0) { 2476 if (status < 0) {
2563 dbg("Writing CLK_START_VALUE_REGISTER failed status-0x%x", status); 2477 dev_dbg(&dev->dev, "Writing CLK_START_VALUE_REGISTER failed status-0x%x\n", status);
2564 break; 2478 break;
2565 } else 2479 } else
2566 dbg("CLK_START_VALUE_REGISTER Writing success status%d", status); 2480 dev_dbg(&dev->dev, "CLK_START_VALUE_REGISTER Writing success status%d\n", status);
2567 2481
2568 Data = 0x20; 2482 Data = 0x20;
2569 status = mos7840_set_reg_sync(serial->port[i], 2483 status = mos7840_set_reg_sync(serial->port[i],
2570 CLK_MULTI_REGISTER, Data); 2484 CLK_MULTI_REGISTER, Data);
2571 if (status < 0) { 2485 if (status < 0) {
2572 dbg("Writing CLK_MULTI_REGISTER failed status-0x%x", 2486 dev_dbg(&dev->dev, "Writing CLK_MULTI_REGISTER failed status-0x%x\n", status);
2573 status);
2574 goto error; 2487 goto error;
2575 } else 2488 } else
2576 dbg("CLK_MULTI_REGISTER Writing success status%d", 2489 dev_dbg(&dev->dev, "CLK_MULTI_REGISTER Writing success status%d\n", status);
2577 status);
2578 2490
2579 /* write value 0x0 to scratchpad register */ 2491 /* write value 0x0 to scratchpad register */
2580 Data = 0x00; 2492 Data = 0x00;
2581 status = mos7840_set_uart_reg(serial->port[i], 2493 status = mos7840_set_uart_reg(serial->port[i],
2582 SCRATCH_PAD_REGISTER, Data); 2494 SCRATCH_PAD_REGISTER, Data);
2583 if (status < 0) { 2495 if (status < 0) {
2584 dbg("Writing SCRATCH_PAD_REGISTER failed status-0x%x", 2496 dev_dbg(&dev->dev, "Writing SCRATCH_PAD_REGISTER failed status-0x%x\n", status);
2585 status);
2586 break; 2497 break;
2587 } else 2498 } else
2588 dbg("SCRATCH_PAD_REGISTER Writing success status%d", 2499 dev_dbg(&dev->dev, "SCRATCH_PAD_REGISTER Writing success status%d\n", status);
2589 status);
2590 2500
2591 /* Zero Length flag register */ 2501 /* Zero Length flag register */
2592 if ((mos7840_port->port_num != 1) 2502 if ((mos7840_port->port_num != 1)
@@ -2596,31 +2506,25 @@ static int mos7840_startup(struct usb_serial *serial)
2596 status = mos7840_set_reg_sync(serial->port[i], 2506 status = mos7840_set_reg_sync(serial->port[i],
2597 (__u16) (ZLP_REG1 + 2507 (__u16) (ZLP_REG1 +
2598 ((__u16)mos7840_port->port_num)), Data); 2508 ((__u16)mos7840_port->port_num)), Data);
2599 dbg("ZLIP offset %x", 2509 dev_dbg(&dev->dev, "ZLIP offset %x\n",
2600 (__u16) (ZLP_REG1 + 2510 (__u16)(ZLP_REG1 + ((__u16) mos7840_port->port_num)));
2601 ((__u16) mos7840_port->port_num)));
2602 if (status < 0) { 2511 if (status < 0) {
2603 dbg("Writing ZLP_REG%d failed status-0x%x", 2512 dev_dbg(&dev->dev, "Writing ZLP_REG%d failed status-0x%x\n", i + 2, status);
2604 i + 2, status);
2605 break; 2513 break;
2606 } else 2514 } else
2607 dbg("ZLP_REG%d Writing success status%d", 2515 dev_dbg(&dev->dev, "ZLP_REG%d Writing success status%d\n", i + 2, status);
2608 i + 2, status);
2609 } else { 2516 } else {
2610 Data = 0xff; 2517 Data = 0xff;
2611 status = mos7840_set_reg_sync(serial->port[i], 2518 status = mos7840_set_reg_sync(serial->port[i],
2612 (__u16) (ZLP_REG1 + 2519 (__u16) (ZLP_REG1 +
2613 ((__u16)mos7840_port->port_num) - 0x1), Data); 2520 ((__u16)mos7840_port->port_num) - 0x1), Data);
2614 dbg("ZLIP offset %x", 2521 dev_dbg(&dev->dev, "ZLIP offset %x\n",
2615 (__u16) (ZLP_REG1 + 2522 (__u16)(ZLP_REG1 + ((__u16) mos7840_port->port_num) - 0x1));
2616 ((__u16) mos7840_port->port_num) - 0x1));
2617 if (status < 0) { 2523 if (status < 0) {
2618 dbg("Writing ZLP_REG%d failed status-0x%x", 2524 dev_dbg(&dev->dev, "Writing ZLP_REG%d failed status-0x%x\n", i + 1, status);
2619 i + 1, status);
2620 break; 2525 break;
2621 } else 2526 } else
2622 dbg("ZLP_REG%d Writing success status%d", 2527 dev_dbg(&dev->dev, "ZLP_REG%d Writing success status%d\n", i + 1, status);
2623 i + 1, status);
2624 2528
2625 } 2529 }
2626 mos7840_port->control_urb = usb_alloc_urb(0, GFP_KERNEL); 2530 mos7840_port->control_urb = usb_alloc_urb(0, GFP_KERNEL);
@@ -2661,16 +2565,15 @@ static int mos7840_startup(struct usb_serial *serial)
2661 MODEM_CONTROL_REGISTER, 0x0300); 2565 MODEM_CONTROL_REGISTER, 0x0300);
2662 } 2566 }
2663 } 2567 }
2664 dbg ("mos7840_startup: all ports configured...........");
2665 2568
2666 /* Zero Length flag enable */ 2569 /* Zero Length flag enable */
2667 Data = 0x0f; 2570 Data = 0x0f;
2668 status = mos7840_set_reg_sync(serial->port[0], ZLP_REG5, Data); 2571 status = mos7840_set_reg_sync(serial->port[0], ZLP_REG5, Data);
2669 if (status < 0) { 2572 if (status < 0) {
2670 dbg("Writing ZLP_REG5 failed status-0x%x", status); 2573 dev_dbg(&dev->dev, "Writing ZLP_REG5 failed status-0x%x\n", status);
2671 goto error; 2574 goto error;
2672 } else 2575 } else
2673 dbg("ZLP_REG5 Writing success status%d", status); 2576 dev_dbg(&dev->dev, "ZLP_REG5 Writing success status%d\n", status);
2674 2577
2675 /* setting configuration feature to one */ 2578 /* setting configuration feature to one */
2676 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 2579 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
@@ -2700,11 +2603,6 @@ static void mos7840_disconnect(struct usb_serial *serial)
2700 unsigned long flags; 2603 unsigned long flags;
2701 struct moschip_port *mos7840_port; 2604 struct moschip_port *mos7840_port;
2702 2605
2703 if (!serial) {
2704 dbg("%s", "Invalid Handler");
2705 return;
2706 }
2707
2708 /* check for the ports to be closed,close the ports and disconnect */ 2606 /* check for the ports to be closed,close the ports and disconnect */
2709 2607
2710 /* free private structure allocated for serial port * 2608 /* free private structure allocated for serial port *
@@ -2712,7 +2610,6 @@ static void mos7840_disconnect(struct usb_serial *serial)
2712 2610
2713 for (i = 0; i < serial->num_ports; ++i) { 2611 for (i = 0; i < serial->num_ports; ++i) {
2714 mos7840_port = mos7840_get_port_private(serial->port[i]); 2612 mos7840_port = mos7840_get_port_private(serial->port[i]);
2715 dbg ("mos7840_port %d = %p", i, mos7840_port);
2716 if (mos7840_port) { 2613 if (mos7840_port) {
2717 spin_lock_irqsave(&mos7840_port->pool_lock, flags); 2614 spin_lock_irqsave(&mos7840_port->pool_lock, flags);
2718 mos7840_port->zombie = 1; 2615 mos7840_port->zombie = 1;
@@ -2732,11 +2629,6 @@ static void mos7840_release(struct usb_serial *serial)
2732 int i; 2629 int i;
2733 struct moschip_port *mos7840_port; 2630 struct moschip_port *mos7840_port;
2734 2631
2735 if (!serial) {
2736 dbg("%s", "Invalid Handler");
2737 return;
2738 }
2739
2740 /* check for the ports to be closed,close the ports and disconnect */ 2632 /* check for the ports to be closed,close the ports and disconnect */
2741 2633
2742 /* free private structure allocated for serial port * 2634 /* free private structure allocated for serial port *
@@ -2744,7 +2636,6 @@ static void mos7840_release(struct usb_serial *serial)
2744 2636
2745 for (i = 0; i < serial->num_ports; ++i) { 2637 for (i = 0; i < serial->num_ports; ++i) {
2746 mos7840_port = mos7840_get_port_private(serial->port[i]); 2638 mos7840_port = mos7840_get_port_private(serial->port[i]);
2747 dbg("mos7840_port %d = %p", i, mos7840_port);
2748 if (mos7840_port) { 2639 if (mos7840_port) {
2749 if (mos7840_port->has_led) { 2640 if (mos7840_port->has_led) {
2750 /* Turn off LED */ 2641 /* Turn off LED */
@@ -2801,6 +2692,3 @@ module_usb_serial_driver(serial_drivers, id_table);
2801 2692
2802MODULE_DESCRIPTION(DRIVER_DESC); 2693MODULE_DESCRIPTION(DRIVER_DESC);
2803MODULE_LICENSE("GPL"); 2694MODULE_LICENSE("GPL");
2804
2805module_param(debug, bool, S_IRUGO | S_IWUSR);
2806MODULE_PARM_DESC(debug, "Debug enabled or not");