aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial
diff options
context:
space:
mode:
authorAlan Cox <alan@redhat.com>2008-07-22 06:12:41 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-22 16:03:24 -0400
commiteb6215ccd403153c6376f7eaa7b31eef19e488f5 (patch)
tree991ea076a854dd8c0702972e9e41596ce078b081 /drivers/usb/serial
parent2e0ddd626d14f3b69d6c1bdd526721a65d52f93b (diff)
ipaq: 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/serial')
-rw-r--r--drivers/usb/serial/ipaq.c97
1 files changed, 52 insertions, 45 deletions
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
index a7784642d6a1..832a5a4f3cb3 100644
--- a/drivers/usb/serial/ipaq.c
+++ b/drivers/usb/serial/ipaq.c
@@ -53,7 +53,7 @@
53#include <linux/tty_flip.h> 53#include <linux/tty_flip.h>
54#include <linux/module.h> 54#include <linux/module.h>
55#include <linux/spinlock.h> 55#include <linux/spinlock.h>
56#include <asm/uaccess.h> 56#include <linux/uaccess.h>
57#include <linux/usb.h> 57#include <linux/usb.h>
58#include <linux/usb/serial.h> 58#include <linux/usb/serial.h>
59#include "ipaq.h" 59#include "ipaq.h"
@@ -82,10 +82,10 @@ static int ipaq_startup(struct usb_serial *serial);
82static void ipaq_shutdown(struct usb_serial *serial); 82static void ipaq_shutdown(struct usb_serial *serial);
83static int ipaq_write(struct tty_struct *tty, struct usb_serial_port *port, 83static int ipaq_write(struct tty_struct *tty, struct usb_serial_port *port,
84 const unsigned char *buf, int count); 84 const unsigned char *buf, int count);
85static int ipaq_write_bulk(struct usb_serial_port *port, const unsigned char *buf, 85static int ipaq_write_bulk(struct usb_serial_port *port,
86 int count); 86 const unsigned char *buf, int count);
87static void ipaq_write_gather(struct usb_serial_port *port); 87static void ipaq_write_gather(struct usb_serial_port *port);
88static void ipaq_read_bulk_callback (struct urb *urb); 88static void ipaq_read_bulk_callback(struct urb *urb);
89static void ipaq_write_bulk_callback(struct urb *urb); 89static void ipaq_write_bulk_callback(struct urb *urb);
90static int ipaq_write_room(struct tty_struct *tty); 90static int ipaq_write_room(struct tty_struct *tty);
91static int ipaq_chars_in_buffer(struct tty_struct *tty); 91static int ipaq_chars_in_buffer(struct tty_struct *tty);
@@ -552,7 +552,7 @@ static struct usb_device_id ipaq_id_table [] = {
552 { } /* Terminating entry */ 552 { } /* Terminating entry */
553}; 553};
554 554
555MODULE_DEVICE_TABLE (usb, ipaq_id_table); 555MODULE_DEVICE_TABLE(usb, ipaq_id_table);
556 556
557static struct usb_driver ipaq_driver = { 557static struct usb_driver ipaq_driver = {
558 .name = "ipaq", 558 .name = "ipaq",
@@ -620,9 +620,9 @@ static int ipaq_open(struct tty_struct *tty,
620 620
621 for (i = 0; i < URBDATA_QUEUE_MAX / PACKET_SIZE; i++) { 621 for (i = 0; i < URBDATA_QUEUE_MAX / PACKET_SIZE; i++) {
622 pkt = kmalloc(sizeof(struct ipaq_packet), GFP_KERNEL); 622 pkt = kmalloc(sizeof(struct ipaq_packet), GFP_KERNEL);
623 if (pkt == NULL) { 623 if (pkt == NULL)
624 goto enomem; 624 goto enomem;
625 } 625
626 pkt->data = kmalloc(PACKET_SIZE, GFP_KERNEL); 626 pkt->data = kmalloc(PACKET_SIZE, GFP_KERNEL);
627 if (pkt->data == NULL) { 627 if (pkt->data == NULL) {
628 kfree(pkt); 628 kfree(pkt);
@@ -667,8 +667,9 @@ static int ipaq_open(struct tty_struct *tty,
667 port->read_urb->transfer_buffer = port->bulk_in_buffer; 667 port->read_urb->transfer_buffer = port->bulk_in_buffer;
668 port->write_urb->transfer_buffer = port->bulk_out_buffer; 668 port->write_urb->transfer_buffer = port->bulk_out_buffer;
669 port->read_urb->transfer_buffer_length = URBDATA_SIZE; 669 port->read_urb->transfer_buffer_length = URBDATA_SIZE;
670 port->bulk_out_size = port->write_urb->transfer_buffer_length = URBDATA_SIZE; 670 port->bulk_out_size = port->write_urb->transfer_buffer_length
671 671 = URBDATA_SIZE;
672
672 msleep(1000*initial_wait); 673 msleep(1000*initial_wait);
673 674
674 /* 675 /*
@@ -697,13 +698,15 @@ static int ipaq_open(struct tty_struct *tty,
697 698
698 /* Start reading from the device */ 699 /* Start reading from the device */
699 usb_fill_bulk_urb(port->read_urb, serial->dev, 700 usb_fill_bulk_urb(port->read_urb, serial->dev,
700 usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress), 701 usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress),
701 port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, 702 port->read_urb->transfer_buffer,
702 ipaq_read_bulk_callback, port); 703 port->read_urb->transfer_buffer_length,
704 ipaq_read_bulk_callback, port);
703 705
704 result = usb_submit_urb(port->read_urb, GFP_KERNEL); 706 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
705 if (result) { 707 if (result) {
706 err("%s - failed submitting read urb, error %d", __func__, result); 708 err("%s - failed submitting read urb, error %d",
709 __func__, result);
707 goto error; 710 goto error;
708 } 711 }
709 712
@@ -725,7 +728,7 @@ static void ipaq_close(struct tty_struct *tty,
725 struct ipaq_private *priv = usb_get_serial_port_data(port); 728 struct ipaq_private *priv = usb_get_serial_port_data(port);
726 729
727 dbg("%s - port %d", __func__, port->number); 730 dbg("%s - port %d", __func__, port->number);
728 731
729 /* 732 /*
730 * shut down bulk read and write 733 * shut down bulk read and write
731 */ 734 */
@@ -735,7 +738,8 @@ static void ipaq_close(struct tty_struct *tty,
735 kfree(priv); 738 kfree(priv);
736 usb_set_serial_port_data(port, NULL); 739 usb_set_serial_port_data(port, NULL);
737 740
738 /* Uncomment the following line if you want to see some statistics in your syslog */ 741 /* Uncomment the following line if you want to see some statistics
742 * in your syslog */
739 /* info ("Bytes In = %d Bytes Out = %d", bytes_in, bytes_out); */ 743 /* info ("Bytes In = %d Bytes Out = %d", bytes_in, bytes_out); */
740} 744}
741 745
@@ -755,7 +759,8 @@ static void ipaq_read_bulk_callback(struct urb *urb)
755 return; 759 return;
756 } 760 }
757 761
758 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); 762 usb_serial_debug_data(debug, &port->dev, __func__,
763 urb->actual_length, data);
759 764
760 tty = port->port.tty; 765 tty = port->port.tty;
761 if (tty && urb->actual_length) { 766 if (tty && urb->actual_length) {
@@ -766,13 +771,15 @@ static void ipaq_read_bulk_callback(struct urb *urb)
766 } 771 }
767 772
768 /* Continue trying to always read */ 773 /* Continue trying to always read */
769 usb_fill_bulk_urb(port->read_urb, port->serial->dev, 774 usb_fill_bulk_urb(port->read_urb, port->serial->dev,
770 usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), 775 usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress),
771 port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, 776 port->read_urb->transfer_buffer,
772 ipaq_read_bulk_callback, port); 777 port->read_urb->transfer_buffer_length,
778 ipaq_read_bulk_callback, port);
773 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 779 result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
774 if (result) 780 if (result)
775 err("%s - failed resubmitting read urb, error %d", __func__, result); 781 err("%s - failed resubmitting read urb, error %d",
782 __func__, result);
776 return; 783 return;
777} 784}
778 785
@@ -787,9 +794,8 @@ static int ipaq_write(struct tty_struct *tty, struct usb_serial_port *port,
787 794
788 while (count > 0) { 795 while (count > 0) {
789 transfer_size = min(count, PACKET_SIZE); 796 transfer_size = min(count, PACKET_SIZE);
790 if (ipaq_write_bulk(port, current_position, transfer_size)) { 797 if (ipaq_write_bulk(port, current_position, transfer_size))
791 break; 798 break;
792 }
793 current_position += transfer_size; 799 current_position += transfer_size;
794 bytes_sent += transfer_size; 800 bytes_sent += transfer_size;
795 count -= transfer_size; 801 count -= transfer_size;
@@ -797,10 +803,10 @@ static int ipaq_write(struct tty_struct *tty, struct usb_serial_port *port,
797 } 803 }
798 804
799 return bytes_sent; 805 return bytes_sent;
800} 806}
801 807
802static int ipaq_write_bulk(struct usb_serial_port *port, const unsigned char *buf, 808static int ipaq_write_bulk(struct usb_serial_port *port,
803 int count) 809 const unsigned char *buf, int count)
804{ 810{
805 struct ipaq_private *priv = usb_get_serial_port_data(port); 811 struct ipaq_private *priv = usb_get_serial_port_data(port);
806 struct ipaq_packet *pkt = NULL; 812 struct ipaq_packet *pkt = NULL;
@@ -837,9 +843,9 @@ static int ipaq_write_bulk(struct usb_serial_port *port, const unsigned char *bu
837 ipaq_write_gather(port); 843 ipaq_write_gather(port);
838 spin_unlock_irqrestore(&write_list_lock, flags); 844 spin_unlock_irqrestore(&write_list_lock, flags);
839 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 845 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
840 if (result) { 846 if (result)
841 err("%s - failed submitting write urb, error %d", __func__, result); 847 err("%s - failed submitting write urb, error %d",
842 } 848 __func__, result);
843 } else { 849 } else {
844 spin_unlock_irqrestore(&write_list_lock, flags); 850 spin_unlock_irqrestore(&write_list_lock, flags);
845 } 851 }
@@ -866,16 +872,15 @@ static void ipaq_write_gather(struct usb_serial_port *port)
866 list_move(&pkt->list, &priv->freelist); 872 list_move(&pkt->list, &priv->freelist);
867 priv->free_len += PACKET_SIZE; 873 priv->free_len += PACKET_SIZE;
868 } 874 }
869 if (room == 0) { 875 if (room == 0)
870 break; 876 break;
871 }
872 } 877 }
873 878
874 count = URBDATA_SIZE - room; 879 count = URBDATA_SIZE - room;
875 usb_fill_bulk_urb(port->write_urb, serial->dev, 880 usb_fill_bulk_urb(port->write_urb, serial->dev,
876 usb_sndbulkpipe(serial->dev, port->bulk_out_endpointAddress), 881 usb_sndbulkpipe(serial->dev, port->bulk_out_endpointAddress),
877 port->write_urb->transfer_buffer, count, ipaq_write_bulk_callback, 882 port->write_urb->transfer_buffer, count,
878 port); 883 ipaq_write_bulk_callback, port);
879 return; 884 return;
880} 885}
881 886
@@ -900,9 +905,9 @@ static void ipaq_write_bulk_callback(struct urb *urb)
900 ipaq_write_gather(port); 905 ipaq_write_gather(port);
901 spin_unlock_irqrestore(&write_list_lock, flags); 906 spin_unlock_irqrestore(&write_list_lock, flags);
902 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 907 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
903 if (result) { 908 if (result)
904 err("%s - failed submitting write urb, error %d", __func__, result); 909 err("%s - failed submitting write urb, error %d",
905 } 910 __func__, result);
906 } else { 911 } else {
907 priv->active = 0; 912 priv->active = 0;
908 spin_unlock_irqrestore(&write_list_lock, flags); 913 spin_unlock_irqrestore(&write_list_lock, flags);
@@ -953,7 +958,7 @@ static int ipaq_startup(struct usb_serial *serial)
953 serial->dev->actconfig->desc.bConfigurationValue); 958 serial->dev->actconfig->desc.bConfigurationValue);
954 return -ENODEV; 959 return -ENODEV;
955 } 960 }
956 return usb_reset_configuration (serial->dev); 961 return usb_reset_configuration(serial->dev);
957} 962}
958 963
959static void ipaq_shutdown(struct usb_serial *serial) 964static void ipaq_shutdown(struct usb_serial *serial)
@@ -966,7 +971,7 @@ static int __init ipaq_init(void)
966 int retval; 971 int retval;
967 spin_lock_init(&write_list_lock); 972 spin_lock_init(&write_list_lock);
968 retval = usb_serial_register(&ipaq_device); 973 retval = usb_serial_register(&ipaq_device);
969 if (retval) 974 if (retval)
970 goto failed_usb_serial_register; 975 goto failed_usb_serial_register;
971 info(DRIVER_DESC " " DRIVER_VERSION); 976 info(DRIVER_DESC " " DRIVER_VERSION);
972 if (vendor) { 977 if (vendor) {
@@ -976,7 +981,7 @@ static int __init ipaq_init(void)
976 retval = usb_register(&ipaq_driver); 981 retval = usb_register(&ipaq_driver);
977 if (retval) 982 if (retval)
978 goto failed_usb_register; 983 goto failed_usb_register;
979 984
980 return 0; 985 return 0;
981failed_usb_register: 986failed_usb_register:
982 usb_serial_deregister(&ipaq_device); 987 usb_serial_deregister(&ipaq_device);
@@ -995,8 +1000,8 @@ static void __exit ipaq_exit(void)
995module_init(ipaq_init); 1000module_init(ipaq_init);
996module_exit(ipaq_exit); 1001module_exit(ipaq_exit);
997 1002
998MODULE_AUTHOR( DRIVER_AUTHOR ); 1003MODULE_AUTHOR(DRIVER_AUTHOR);
999MODULE_DESCRIPTION( DRIVER_DESC ); 1004MODULE_DESCRIPTION(DRIVER_DESC);
1000MODULE_LICENSE("GPL"); 1005MODULE_LICENSE("GPL");
1001 1006
1002module_param(debug, bool, S_IRUGO | S_IWUSR); 1007module_param(debug, bool, S_IRUGO | S_IWUSR);
@@ -1009,7 +1014,9 @@ module_param(product, ushort, 0);
1009MODULE_PARM_DESC(product, "User specified USB idProduct"); 1014MODULE_PARM_DESC(product, "User specified USB idProduct");
1010 1015
1011module_param(connect_retries, int, S_IRUGO|S_IWUSR); 1016module_param(connect_retries, int, S_IRUGO|S_IWUSR);
1012MODULE_PARM_DESC(connect_retries, "Maximum number of connect retries (one second each)"); 1017MODULE_PARM_DESC(connect_retries,
1018 "Maximum number of connect retries (one second each)");
1013 1019
1014module_param(initial_wait, int, S_IRUGO|S_IWUSR); 1020module_param(initial_wait, int, S_IRUGO|S_IWUSR);
1015MODULE_PARM_DESC(initial_wait, "Time to wait before attempting a connection (in seconds)"); 1021MODULE_PARM_DESC(initial_wait,
1022 "Time to wait before attempting a connection (in seconds)");