aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2013-10-09 11:01:10 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-10-11 20:00:26 -0400
commit92ad247995c587e07cb67dcc8aafac4db636e394 (patch)
treee3d627f93cbdf8eecb11e3848e00420b5bf4dd00
parent059239adfe577866115cd5270eba40e3cac33f8a (diff)
USB: serial: clean up comments in generic driver
Clean up some comments, drop excessive comments and fix-up style. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/serial/generic.c57
1 files changed, 25 insertions, 32 deletions
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 3a5dac879094..fce374657ea2 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -7,7 +7,6 @@
7 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License version 8 * modify it under the terms of the GNU General Public License version
9 * 2 as published by the Free Software Foundation. 9 * 2 as published by the Free Software Foundation.
10 *
11 */ 10 */
12 11
13#include <linux/kernel.h> 12#include <linux/kernel.h>
@@ -37,7 +36,6 @@ MODULE_PARM_DESC(product, "User specified USB idProduct");
37 36
38static struct usb_device_id generic_device_ids[2]; /* Initially all zeroes. */ 37static struct usb_device_id generic_device_ids[2]; /* Initially all zeroes. */
39 38
40/* All of the device info needed for the Generic Serial Converter */
41struct usb_serial_driver usb_serial_generic_device = { 39struct usb_serial_driver usb_serial_generic_device = {
42 .driver = { 40 .driver = {
43 .owner = THIS_MODULE, 41 .owner = THIS_MODULE,
@@ -66,7 +64,6 @@ int usb_serial_generic_register(void)
66 generic_device_ids[0].match_flags = 64 generic_device_ids[0].match_flags =
67 USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT; 65 USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT;
68 66
69 /* register our generic driver with ourselves */
70 retval = usb_serial_register_drivers(serial_drivers, 67 retval = usb_serial_register_drivers(serial_drivers,
71 "usbserial_generic", generic_device_ids); 68 "usbserial_generic", generic_device_ids);
72#endif 69#endif
@@ -76,7 +73,6 @@ int usb_serial_generic_register(void)
76void usb_serial_generic_deregister(void) 73void usb_serial_generic_deregister(void)
77{ 74{
78#ifdef CONFIG_USB_SERIAL_GENERIC 75#ifdef CONFIG_USB_SERIAL_GENERIC
79 /* remove our generic driver */
80 usb_serial_deregister_drivers(serial_drivers); 76 usb_serial_deregister_drivers(serial_drivers);
81#endif 77#endif
82} 78}
@@ -86,13 +82,11 @@ int usb_serial_generic_open(struct tty_struct *tty, struct usb_serial_port *port
86 int result = 0; 82 int result = 0;
87 unsigned long flags; 83 unsigned long flags;
88 84
89 /* clear the throttle flags */
90 spin_lock_irqsave(&port->lock, flags); 85 spin_lock_irqsave(&port->lock, flags);
91 port->throttled = 0; 86 port->throttled = 0;
92 port->throttle_req = 0; 87 port->throttle_req = 0;
93 spin_unlock_irqrestore(&port->lock, flags); 88 spin_unlock_irqrestore(&port->lock, flags);
94 89
95 /* if we have a bulk endpoint, start reading from it */
96 if (port->bulk_in_size) 90 if (port->bulk_in_size)
97 result = usb_serial_generic_submit_read_urbs(port, GFP_KERNEL); 91 result = usb_serial_generic_submit_read_urbs(port, GFP_KERNEL);
98 92
@@ -127,10 +121,12 @@ int usb_serial_generic_prepare_write_buffer(struct usb_serial_port *port,
127} 121}
128 122
129/** 123/**
130 * usb_serial_generic_write_start - kick off an URB write 124 * usb_serial_generic_write_start - start writing buffered data
131 * @port: Pointer to the &struct usb_serial_port data 125 * @port: usb-serial port
126 *
127 * Serialised using USB_SERIAL_WRITE_BUSY flag.
132 * 128 *
133 * Returns zero on success, or a negative errno value 129 * Return: Zero on success or if busy, otherwise a negative errno value.
134 */ 130 */
135static int usb_serial_generic_write_start(struct usb_serial_port *port) 131static int usb_serial_generic_write_start(struct usb_serial_port *port)
136{ 132{
@@ -175,9 +171,10 @@ retry:
175 clear_bit_unlock(USB_SERIAL_WRITE_BUSY, &port->flags); 171 clear_bit_unlock(USB_SERIAL_WRITE_BUSY, &port->flags);
176 return result; 172 return result;
177 } 173 }
178 174 /*
179 /* Try sending off another urb, unless in irq context (in which case 175 * Try sending off another urb, unless in irq context (in which case
180 * there will be no free urb). */ 176 * there will be no free urb).
177 */
181 if (!in_irq()) 178 if (!in_irq())
182 goto retry; 179 goto retry;
183 180
@@ -187,22 +184,20 @@ retry:
187} 184}
188 185
189/** 186/**
190 * usb_serial_generic_write - generic write function for serial USB devices 187 * usb_serial_generic_write - generic write function
191 * @tty: Pointer to &struct tty_struct for the device 188 * @tty: tty for the port
192 * @port: Pointer to the &usb_serial_port structure for the device 189 * @port: usb-serial port
193 * @buf: Pointer to the data to write 190 * @buf: data to write
194 * @count: Number of bytes to write 191 * @count: number of bytes to write
195 * 192 *
196 * Returns the number of characters actually written, which may be anything 193 * Return: The number of characters buffered, which may be anything from
197 * from zero to @count. If an error occurs, it returns the negative errno 194 * zero to @count, or a negative errno value.
198 * value.
199 */ 195 */
200int usb_serial_generic_write(struct tty_struct *tty, 196int usb_serial_generic_write(struct tty_struct *tty,
201 struct usb_serial_port *port, const unsigned char *buf, int count) 197 struct usb_serial_port *port, const unsigned char *buf, int count)
202{ 198{
203 int result; 199 int result;
204 200
205 /* only do something if we have a bulk out endpoint */
206 if (!port->bulk_out_size) 201 if (!port->bulk_out_size)
207 return -ENODEV; 202 return -ENODEV;
208 203
@@ -337,10 +332,11 @@ void usb_serial_generic_process_read_urb(struct urb *urb)
337 332
338 if (!urb->actual_length) 333 if (!urb->actual_length)
339 return; 334 return;
340 335 /*
341 /* The per character mucking around with sysrq path it too slow for 336 * The per character mucking around with sysrq path it too slow for
342 stuff like 3G modems, so shortcircuit it in the 99.9999999% of cases 337 * stuff like 3G modems, so shortcircuit it in the 99.9999999% of
343 where the USB serial is not a console anyway */ 338 * cases where the USB serial is not a console anyway.
339 */
344 if (!port->port.console || !port->sysrq) 340 if (!port->port.console || !port->sysrq)
345 tty_insert_flip_string(&port->port, ch, urb->actual_length); 341 tty_insert_flip_string(&port->port, ch, urb->actual_length);
346 else { 342 else {
@@ -425,8 +421,6 @@ void usb_serial_generic_throttle(struct tty_struct *tty)
425 struct usb_serial_port *port = tty->driver_data; 421 struct usb_serial_port *port = tty->driver_data;
426 unsigned long flags; 422 unsigned long flags;
427 423
428 /* Set the throttle request flag. It will be picked up
429 * by usb_serial_generic_read_bulk_callback(). */
430 spin_lock_irqsave(&port->lock, flags); 424 spin_lock_irqsave(&port->lock, flags);
431 port->throttle_req = 1; 425 port->throttle_req = 1;
432 spin_unlock_irqrestore(&port->lock, flags); 426 spin_unlock_irqrestore(&port->lock, flags);
@@ -438,7 +432,6 @@ void usb_serial_generic_unthrottle(struct tty_struct *tty)
438 struct usb_serial_port *port = tty->driver_data; 432 struct usb_serial_port *port = tty->driver_data;
439 int was_throttled; 433 int was_throttled;
440 434
441 /* Clear the throttle flags */
442 spin_lock_irq(&port->lock); 435 spin_lock_irq(&port->lock);
443 was_throttled = port->throttled; 436 was_throttled = port->throttled;
444 port->throttled = port->throttle_req = 0; 437 port->throttled = port->throttle_req = 0;
@@ -558,10 +551,10 @@ int usb_serial_handle_break(struct usb_serial_port *port)
558EXPORT_SYMBOL_GPL(usb_serial_handle_break); 551EXPORT_SYMBOL_GPL(usb_serial_handle_break);
559 552
560/** 553/**
561 * usb_serial_handle_dcd_change - handle a change of carrier detect state 554 * usb_serial_handle_dcd_change - handle a change of carrier detect state
562 * @port: usb_serial_port structure for the open port 555 * @port: usb-serial port
563 * @tty: tty_struct structure for the port 556 * @tty: tty for the port
564 * @status: new carrier detect status, nonzero if active 557 * @status: new carrier detect status, nonzero if active
565 */ 558 */
566void usb_serial_handle_dcd_change(struct usb_serial_port *usb_port, 559void usb_serial_handle_dcd_change(struct usb_serial_port *usb_port,
567 struct tty_struct *tty, unsigned int status) 560 struct tty_struct *tty, unsigned int status)