diff options
author | Alan Cox <alan@redhat.com> | 2008-07-22 06:15:45 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-22 16:03:26 -0400 |
commit | 19e58fae0c8f197d80fcea338b94fb5740369bc1 (patch) | |
tree | 28396f6f32a08e4c3c3f60f3926b1077eafba6ae /drivers/usb | |
parent | 2a77c8144992e21367cc15956b0ff295f1112c85 (diff) |
tty-usb-option: 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/option.c | 65 |
1 files changed, 35 insertions, 30 deletions
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 4350990abf14..e4eca95f2b0f 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
@@ -43,8 +43,10 @@ | |||
43 | #include <linux/usb/serial.h> | 43 | #include <linux/usb/serial.h> |
44 | 44 | ||
45 | /* Function prototypes */ | 45 | /* Function prototypes */ |
46 | static int option_open(struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); | 46 | static int option_open(struct tty_struct *tty, struct usb_serial_port *port, |
47 | static void option_close(struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); | 47 | struct file *filp); |
48 | static void option_close(struct tty_struct *tty, struct usb_serial_port *port, | ||
49 | struct file *filp); | ||
48 | static int option_startup(struct usb_serial *serial); | 50 | static int option_startup(struct usb_serial *serial); |
49 | static void option_shutdown(struct usb_serial *serial); | 51 | static void option_shutdown(struct usb_serial *serial); |
50 | static int option_write_room(struct tty_struct *tty); | 52 | static int option_write_room(struct tty_struct *tty); |
@@ -393,15 +395,15 @@ static int __init option_init(void) | |||
393 | return 0; | 395 | return 0; |
394 | 396 | ||
395 | failed_driver_register: | 397 | failed_driver_register: |
396 | usb_serial_deregister (&option_1port_device); | 398 | usb_serial_deregister(&option_1port_device); |
397 | failed_1port_device_register: | 399 | failed_1port_device_register: |
398 | return retval; | 400 | return retval; |
399 | } | 401 | } |
400 | 402 | ||
401 | static void __exit option_exit(void) | 403 | static void __exit option_exit(void) |
402 | { | 404 | { |
403 | usb_deregister (&option_driver); | 405 | usb_deregister(&option_driver); |
404 | usb_serial_deregister (&option_1port_device); | 406 | usb_serial_deregister(&option_1port_device); |
405 | } | 407 | } |
406 | 408 | ||
407 | module_init(option_init); | 409 | module_init(option_init); |
@@ -471,7 +473,7 @@ static int option_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
471 | 473 | ||
472 | i = 0; | 474 | i = 0; |
473 | left = count; | 475 | left = count; |
474 | for (i=0; left > 0 && i < N_OUT_URB; i++) { | 476 | for (i = 0; left > 0 && i < N_OUT_URB; i++) { |
475 | todo = left; | 477 | todo = left; |
476 | if (todo > OUT_BUFLEN) | 478 | if (todo > OUT_BUFLEN) |
477 | todo = OUT_BUFLEN; | 479 | todo = OUT_BUFLEN; |
@@ -492,7 +494,7 @@ static int option_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
492 | usb_pipeendpoint(this_urb->pipe), i); | 494 | usb_pipeendpoint(this_urb->pipe), i); |
493 | 495 | ||
494 | /* send the data */ | 496 | /* send the data */ |
495 | memcpy (this_urb->transfer_buffer, buf, todo); | 497 | memcpy(this_urb->transfer_buffer, buf, todo); |
496 | this_urb->transfer_buffer_length = todo; | 498 | this_urb->transfer_buffer_length = todo; |
497 | 499 | ||
498 | this_urb->dev = port->serial->dev; | 500 | this_urb->dev = port->serial->dev; |
@@ -583,7 +585,7 @@ static void option_instat_callback(struct urb *urb) | |||
583 | struct usb_serial *serial = port->serial; | 585 | struct usb_serial *serial = port->serial; |
584 | 586 | ||
585 | dbg("%s", __func__); | 587 | dbg("%s", __func__); |
586 | dbg("%s: urb %p port %p has data %p", __func__,urb,port,portdata); | 588 | dbg("%s: urb %p port %p has data %p", __func__, urb, port, portdata); |
587 | 589 | ||
588 | if (status == 0) { | 590 | if (status == 0) { |
589 | struct usb_ctrlrequest *req_pkt = | 591 | struct usb_ctrlrequest *req_pkt = |
@@ -613,7 +615,7 @@ static void option_instat_callback(struct urb *urb) | |||
613 | tty_hangup(port->port.tty); | 615 | tty_hangup(port->port.tty); |
614 | } else { | 616 | } else { |
615 | dbg("%s: type %x req %x", __func__, | 617 | dbg("%s: type %x req %x", __func__, |
616 | req_pkt->bRequestType,req_pkt->bRequest); | 618 | req_pkt->bRequestType, req_pkt->bRequest); |
617 | } | 619 | } |
618 | } else | 620 | } else |
619 | dbg("%s: error %d", __func__, status); | 621 | dbg("%s: error %d", __func__, status); |
@@ -639,7 +641,7 @@ static int option_write_room(struct tty_struct *tty) | |||
639 | portdata = usb_get_serial_port_data(port); | 641 | portdata = usb_get_serial_port_data(port); |
640 | 642 | ||
641 | 643 | ||
642 | for (i=0; i < N_OUT_URB; i++) { | 644 | for (i = 0; i < N_OUT_URB; i++) { |
643 | this_urb = portdata->out_urbs[i]; | 645 | this_urb = portdata->out_urbs[i]; |
644 | if (this_urb && !test_bit(i, &portdata->out_busy)) | 646 | if (this_urb && !test_bit(i, &portdata->out_busy)) |
645 | data_len += OUT_BUFLEN; | 647 | data_len += OUT_BUFLEN; |
@@ -659,7 +661,7 @@ static int option_chars_in_buffer(struct tty_struct *tty) | |||
659 | 661 | ||
660 | portdata = usb_get_serial_port_data(port); | 662 | portdata = usb_get_serial_port_data(port); |
661 | 663 | ||
662 | for (i=0; i < N_OUT_URB; i++) { | 664 | for (i = 0; i < N_OUT_URB; i++) { |
663 | this_urb = portdata->out_urbs[i]; | 665 | this_urb = portdata->out_urbs[i]; |
664 | /* FIXME: This locking is insufficient as this_urb may | 666 | /* FIXME: This locking is insufficient as this_urb may |
665 | go unused during the test */ | 667 | go unused during the test */ |
@@ -689,7 +691,7 @@ static int option_open(struct tty_struct *tty, | |||
689 | /* Reset low level data toggle and start reading from endpoints */ | 691 | /* Reset low level data toggle and start reading from endpoints */ |
690 | for (i = 0; i < N_IN_URB; i++) { | 692 | for (i = 0; i < N_IN_URB; i++) { |
691 | urb = portdata->in_urbs[i]; | 693 | urb = portdata->in_urbs[i]; |
692 | if (! urb) | 694 | if (!urb) |
693 | continue; | 695 | continue; |
694 | if (urb->dev != serial->dev) { | 696 | if (urb->dev != serial->dev) { |
695 | dbg("%s: dev %p != %p", __func__, | 697 | dbg("%s: dev %p != %p", __func__, |
@@ -714,7 +716,7 @@ static int option_open(struct tty_struct *tty, | |||
714 | /* Reset low level data toggle on out endpoints */ | 716 | /* Reset low level data toggle on out endpoints */ |
715 | for (i = 0; i < N_OUT_URB; i++) { | 717 | for (i = 0; i < N_OUT_URB; i++) { |
716 | urb = portdata->out_urbs[i]; | 718 | urb = portdata->out_urbs[i]; |
717 | if (! urb) | 719 | if (!urb) |
718 | continue; | 720 | continue; |
719 | urb->dev = serial->dev; | 721 | urb->dev = serial->dev; |
720 | /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), | 722 | /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), |
@@ -726,7 +728,7 @@ static int option_open(struct tty_struct *tty, | |||
726 | 728 | ||
727 | option_send_setup(tty, port); | 729 | option_send_setup(tty, port); |
728 | 730 | ||
729 | return (0); | 731 | return 0; |
730 | } | 732 | } |
731 | 733 | ||
732 | static void option_close(struct tty_struct *tty, | 734 | static void option_close(struct tty_struct *tty, |
@@ -784,7 +786,7 @@ static struct urb *option_setup_urb(struct usb_serial *serial, int endpoint, | |||
784 | /* Setup urbs */ | 786 | /* Setup urbs */ |
785 | static void option_setup_urbs(struct usb_serial *serial) | 787 | static void option_setup_urbs(struct usb_serial *serial) |
786 | { | 788 | { |
787 | int i,j; | 789 | int i, j; |
788 | struct usb_serial_port *port; | 790 | struct usb_serial_port *port; |
789 | struct option_port_private *portdata; | 791 | struct option_port_private *portdata; |
790 | 792 | ||
@@ -794,18 +796,22 @@ static void option_setup_urbs(struct usb_serial *serial) | |||
794 | port = serial->port[i]; | 796 | port = serial->port[i]; |
795 | portdata = usb_get_serial_port_data(port); | 797 | portdata = usb_get_serial_port_data(port); |
796 | 798 | ||
797 | /* Do indat endpoints first */ | 799 | /* Do indat endpoints first */ |
798 | for (j = 0; j < N_IN_URB; ++j) { | 800 | for (j = 0; j < N_IN_URB; ++j) { |
799 | portdata->in_urbs[j] = option_setup_urb (serial, | 801 | portdata->in_urbs[j] = option_setup_urb(serial, |
800 | port->bulk_in_endpointAddress, USB_DIR_IN, port, | 802 | port->bulk_in_endpointAddress, |
801 | portdata->in_buffer[j], IN_BUFLEN, option_indat_callback); | 803 | USB_DIR_IN, port, |
804 | portdata->in_buffer[j], | ||
805 | IN_BUFLEN, option_indat_callback); | ||
802 | } | 806 | } |
803 | 807 | ||
804 | /* outdat endpoints */ | 808 | /* outdat endpoints */ |
805 | for (j = 0; j < N_OUT_URB; ++j) { | 809 | for (j = 0; j < N_OUT_URB; ++j) { |
806 | portdata->out_urbs[j] = option_setup_urb (serial, | 810 | portdata->out_urbs[j] = option_setup_urb(serial, |
807 | port->bulk_out_endpointAddress, USB_DIR_OUT, port, | 811 | port->bulk_out_endpointAddress, |
808 | portdata->out_buffer[j], OUT_BUFLEN, option_outdat_callback); | 812 | USB_DIR_OUT, port, |
813 | portdata->out_buffer[j], | ||
814 | OUT_BUFLEN, option_outdat_callback); | ||
809 | } | 815 | } |
810 | } | 816 | } |
811 | } | 817 | } |
@@ -834,8 +840,8 @@ static int option_send_setup(struct tty_struct *tty, | |||
834 | val |= 0x02; | 840 | val |= 0x02; |
835 | 841 | ||
836 | return usb_control_msg(serial->dev, | 842 | return usb_control_msg(serial->dev, |
837 | usb_rcvctrlpipe(serial->dev, 0), | 843 | usb_rcvctrlpipe(serial->dev, 0), |
838 | 0x22,0x21,val,ifNum,NULL,0,USB_CTRL_SET_TIMEOUT); | 844 | 0x22, 0x21, val, ifNum, NULL, 0, USB_CTRL_SET_TIMEOUT); |
839 | } | 845 | } |
840 | return 0; | 846 | return 0; |
841 | } | 847 | } |
@@ -856,7 +862,7 @@ static int option_startup(struct usb_serial *serial) | |||
856 | if (!portdata) { | 862 | if (!portdata) { |
857 | dbg("%s: kmalloc for option_port_private (%d) failed!.", | 863 | dbg("%s: kmalloc for option_port_private (%d) failed!.", |
858 | __func__, i); | 864 | __func__, i); |
859 | return (1); | 865 | return 1; |
860 | } | 866 | } |
861 | 867 | ||
862 | for (j = 0; j < N_IN_URB; j++) { | 868 | for (j = 0; j < N_IN_URB; j++) { |
@@ -875,17 +881,15 @@ static int option_startup(struct usb_serial *serial) | |||
875 | 881 | ||
876 | usb_set_serial_port_data(port, portdata); | 882 | usb_set_serial_port_data(port, portdata); |
877 | 883 | ||
878 | if (! port->interrupt_in_urb) | 884 | if (!port->interrupt_in_urb) |
879 | continue; | 885 | continue; |
880 | err = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); | 886 | err = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); |
881 | if (err) | 887 | if (err) |
882 | dbg("%s: submit irq_in urb failed %d", | 888 | dbg("%s: submit irq_in urb failed %d", |
883 | __func__, err); | 889 | __func__, err); |
884 | } | 890 | } |
885 | |||
886 | option_setup_urbs(serial); | 891 | option_setup_urbs(serial); |
887 | 892 | return 0; | |
888 | return (0); | ||
889 | 893 | ||
890 | bail_out_error2: | 894 | bail_out_error2: |
891 | for (j = 0; j < N_OUT_URB; j++) | 895 | for (j = 0; j < N_OUT_URB; j++) |
@@ -924,7 +928,8 @@ static void option_shutdown(struct usb_serial *serial) | |||
924 | for (j = 0; j < N_IN_URB; j++) { | 928 | for (j = 0; j < N_IN_URB; j++) { |
925 | if (portdata->in_urbs[j]) { | 929 | if (portdata->in_urbs[j]) { |
926 | usb_free_urb(portdata->in_urbs[j]); | 930 | usb_free_urb(portdata->in_urbs[j]); |
927 | free_page((unsigned long)portdata->in_buffer[j]); | 931 | free_page((unsigned long) |
932 | portdata->in_buffer[j]); | ||
928 | portdata->in_urbs[j] = NULL; | 933 | portdata->in_urbs[j] = NULL; |
929 | } | 934 | } |
930 | } | 935 | } |