diff options
author | Alan Cox <alan@lxorguk.ukuu.org.uk> | 2008-04-29 09:35:39 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-05-02 13:25:58 -0400 |
commit | c4d0f8cbca3a97900f85b082064a63c7a5928bd7 (patch) | |
tree | abfd6996e010cb75962c82fde6fac9fb5eeacc29 | |
parent | e5430f889ce04301152044cce15a4a11a3e21e7d (diff) |
usb_serial: some coding style fixes
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/usb/serial/aircable.c | 98 | ||||
-rw-r--r-- | drivers/usb/serial/airprime.c | 61 | ||||
-rw-r--r-- | drivers/usb/serial/ark3116.c | 54 | ||||
-rw-r--r-- | drivers/usb/serial/ch341.c | 2 |
4 files changed, 112 insertions, 103 deletions
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c index 9b1bb347dc2d..db6f97a93c02 100644 --- a/drivers/usb/serial/aircable.c +++ b/drivers/usb/serial/aircable.c | |||
@@ -147,7 +147,7 @@ static void serial_buf_free(struct circ_buf *cb) | |||
147 | */ | 147 | */ |
148 | static int serial_buf_data_avail(struct circ_buf *cb) | 148 | static int serial_buf_data_avail(struct circ_buf *cb) |
149 | { | 149 | { |
150 | return CIRC_CNT(cb->head,cb->tail,AIRCABLE_BUF_SIZE); | 150 | return CIRC_CNT(cb->head, cb->tail, AIRCABLE_BUF_SIZE); |
151 | } | 151 | } |
152 | 152 | ||
153 | /* | 153 | /* |
@@ -171,7 +171,7 @@ static int serial_buf_put(struct circ_buf *cb, const char *buf, int count) | |||
171 | cb->head = (cb->head + c) & (AIRCABLE_BUF_SIZE-1); | 171 | cb->head = (cb->head + c) & (AIRCABLE_BUF_SIZE-1); |
172 | buf += c; | 172 | buf += c; |
173 | count -= c; | 173 | count -= c; |
174 | ret= c; | 174 | ret = c; |
175 | } | 175 | } |
176 | return ret; | 176 | return ret; |
177 | } | 177 | } |
@@ -197,7 +197,7 @@ static int serial_buf_get(struct circ_buf *cb, char *buf, int count) | |||
197 | cb->tail = (cb->tail + c) & (AIRCABLE_BUF_SIZE-1); | 197 | cb->tail = (cb->tail + c) & (AIRCABLE_BUF_SIZE-1); |
198 | buf += c; | 198 | buf += c; |
199 | count -= c; | 199 | count -= c; |
200 | ret= c; | 200 | ret = c; |
201 | } | 201 | } |
202 | return ret; | 202 | return ret; |
203 | } | 203 | } |
@@ -208,7 +208,7 @@ static void aircable_send(struct usb_serial_port *port) | |||
208 | { | 208 | { |
209 | int count, result; | 209 | int count, result; |
210 | struct aircable_private *priv = usb_get_serial_port_data(port); | 210 | struct aircable_private *priv = usb_get_serial_port_data(port); |
211 | unsigned char* buf; | 211 | unsigned char *buf; |
212 | __le16 *dbuf; | 212 | __le16 *dbuf; |
213 | dbg("%s - port %d", __func__, port->number); | 213 | dbg("%s - port %d", __func__, port->number); |
214 | if (port->write_urb_busy) | 214 | if (port->write_urb_busy) |
@@ -229,7 +229,8 @@ static void aircable_send(struct usb_serial_port *port) | |||
229 | buf[1] = TX_HEADER_1; | 229 | buf[1] = TX_HEADER_1; |
230 | dbuf = (__le16 *)&buf[2]; | 230 | dbuf = (__le16 *)&buf[2]; |
231 | *dbuf = cpu_to_le16((u16)count); | 231 | *dbuf = cpu_to_le16((u16)count); |
232 | serial_buf_get(priv->tx_buf,buf + HCI_HEADER_LENGTH, MAX_HCI_FRAMESIZE); | 232 | serial_buf_get(priv->tx_buf, buf + HCI_HEADER_LENGTH, |
233 | MAX_HCI_FRAMESIZE); | ||
233 | 234 | ||
234 | memcpy(port->write_urb->transfer_buffer, buf, | 235 | memcpy(port->write_urb->transfer_buffer, buf, |
235 | count + HCI_HEADER_LENGTH); | 236 | count + HCI_HEADER_LENGTH); |
@@ -261,7 +262,7 @@ static void aircable_read(struct work_struct *work) | |||
261 | struct tty_struct *tty; | 262 | struct tty_struct *tty; |
262 | unsigned char *data; | 263 | unsigned char *data; |
263 | int count; | 264 | int count; |
264 | if (priv->rx_flags & THROTTLED){ | 265 | if (priv->rx_flags & THROTTLED) { |
265 | if (priv->rx_flags & ACTUALLY_THROTTLED) | 266 | if (priv->rx_flags & ACTUALLY_THROTTLED) |
266 | schedule_work(&priv->rx_work); | 267 | schedule_work(&priv->rx_work); |
267 | return; | 268 | return; |
@@ -282,10 +283,10 @@ static void aircable_read(struct work_struct *work) | |||
282 | count = min(64, serial_buf_data_avail(priv->rx_buf)); | 283 | count = min(64, serial_buf_data_avail(priv->rx_buf)); |
283 | 284 | ||
284 | if (count <= 0) | 285 | if (count <= 0) |
285 | return; //We have finished sending everything. | 286 | return; /* We have finished sending everything. */ |
286 | 287 | ||
287 | tty_prepare_flip_string(tty, &data, count); | 288 | tty_prepare_flip_string(tty, &data, count); |
288 | if (!data){ | 289 | if (!data) { |
289 | err("%s- kzalloc(%d) failed.", __func__, count); | 290 | err("%s- kzalloc(%d) failed.", __func__, count); |
290 | return; | 291 | return; |
291 | } | 292 | } |
@@ -304,9 +305,10 @@ static void aircable_read(struct work_struct *work) | |||
304 | static int aircable_probe(struct usb_serial *serial, | 305 | static int aircable_probe(struct usb_serial *serial, |
305 | const struct usb_device_id *id) | 306 | const struct usb_device_id *id) |
306 | { | 307 | { |
307 | struct usb_host_interface *iface_desc = serial->interface->cur_altsetting; | 308 | struct usb_host_interface *iface_desc = serial->interface-> |
309 | cur_altsetting; | ||
308 | struct usb_endpoint_descriptor *endpoint; | 310 | struct usb_endpoint_descriptor *endpoint; |
309 | int num_bulk_out=0; | 311 | int num_bulk_out = 0; |
310 | int i; | 312 | int i; |
311 | 313 | ||
312 | for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) { | 314 | for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) { |
@@ -325,13 +327,13 @@ static int aircable_probe(struct usb_serial *serial, | |||
325 | return 0; | 327 | return 0; |
326 | } | 328 | } |
327 | 329 | ||
328 | static int aircable_attach (struct usb_serial *serial) | 330 | static int aircable_attach(struct usb_serial *serial) |
329 | { | 331 | { |
330 | struct usb_serial_port *port = serial->port[0]; | 332 | struct usb_serial_port *port = serial->port[0]; |
331 | struct aircable_private *priv; | 333 | struct aircable_private *priv; |
332 | 334 | ||
333 | priv = kzalloc(sizeof(struct aircable_private), GFP_KERNEL); | 335 | priv = kzalloc(sizeof(struct aircable_private), GFP_KERNEL); |
334 | if (!priv){ | 336 | if (!priv) { |
335 | err("%s- kmalloc(%Zd) failed.", __func__, | 337 | err("%s- kmalloc(%Zd) failed.", __func__, |
336 | sizeof(struct aircable_private)); | 338 | sizeof(struct aircable_private)); |
337 | return -ENOMEM; | 339 | return -ENOMEM; |
@@ -392,7 +394,7 @@ static int aircable_write(struct usb_serial_port *port, | |||
392 | 394 | ||
393 | usb_serial_debug_data(debug, &port->dev, __func__, count, source); | 395 | usb_serial_debug_data(debug, &port->dev, __func__, count, source); |
394 | 396 | ||
395 | if (!count){ | 397 | if (!count) { |
396 | dbg("%s - write request of 0 bytes", __func__); | 398 | dbg("%s - write request of 0 bytes", __func__); |
397 | return count; | 399 | return count; |
398 | } | 400 | } |
@@ -418,31 +420,31 @@ static void aircable_write_bulk_callback(struct urb *urb) | |||
418 | 420 | ||
419 | /* This has been taken from cypress_m8.c cypress_write_int_callback */ | 421 | /* This has been taken from cypress_m8.c cypress_write_int_callback */ |
420 | switch (status) { | 422 | switch (status) { |
421 | case 0: | 423 | case 0: |
422 | /* success */ | 424 | /* success */ |
423 | break; | 425 | break; |
424 | case -ECONNRESET: | 426 | case -ECONNRESET: |
425 | case -ENOENT: | 427 | case -ENOENT: |
426 | case -ESHUTDOWN: | 428 | case -ESHUTDOWN: |
427 | /* this urb is terminated, clean up */ | 429 | /* this urb is terminated, clean up */ |
428 | dbg("%s - urb shutting down with status: %d", | 430 | dbg("%s - urb shutting down with status: %d", |
429 | __func__, status); | 431 | __func__, status); |
430 | port->write_urb_busy = 0; | 432 | port->write_urb_busy = 0; |
433 | return; | ||
434 | default: | ||
435 | /* error in the urb, so we have to resubmit it */ | ||
436 | dbg("%s - Overflow in write", __func__); | ||
437 | dbg("%s - nonzero write bulk status received: %d", | ||
438 | __func__, status); | ||
439 | port->write_urb->transfer_buffer_length = 1; | ||
440 | port->write_urb->dev = port->serial->dev; | ||
441 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | ||
442 | if (result) | ||
443 | dev_err(&urb->dev->dev, | ||
444 | "%s - failed resubmitting write urb, error %d\n", | ||
445 | __func__, result); | ||
446 | else | ||
431 | return; | 447 | return; |
432 | default: | ||
433 | /* error in the urb, so we have to resubmit it */ | ||
434 | dbg("%s - Overflow in write", __func__); | ||
435 | dbg("%s - nonzero write bulk status received: %d", | ||
436 | __func__, status); | ||
437 | port->write_urb->transfer_buffer_length = 1; | ||
438 | port->write_urb->dev = port->serial->dev; | ||
439 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | ||
440 | if (result) | ||
441 | dev_err(&urb->dev->dev, | ||
442 | "%s - failed resubmitting write urb, error %d\n", | ||
443 | __func__, result); | ||
444 | else | ||
445 | return; | ||
446 | } | 448 | } |
447 | 449 | ||
448 | port->write_urb_busy = 0; | 450 | port->write_urb_busy = 0; |
@@ -472,11 +474,11 @@ static void aircable_read_bulk_callback(struct urb *urb) | |||
472 | dbg("%s - caught -EPROTO, resubmitting the urb", | 474 | dbg("%s - caught -EPROTO, resubmitting the urb", |
473 | __func__); | 475 | __func__); |
474 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, | 476 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, |
475 | usb_rcvbulkpipe(port->serial->dev, | 477 | usb_rcvbulkpipe(port->serial->dev, |
476 | port->bulk_in_endpointAddress), | 478 | port->bulk_in_endpointAddress), |
477 | port->read_urb->transfer_buffer, | 479 | port->read_urb->transfer_buffer, |
478 | port->read_urb->transfer_buffer_length, | 480 | port->read_urb->transfer_buffer_length, |
479 | aircable_read_bulk_callback, port); | 481 | aircable_read_bulk_callback, port); |
480 | 482 | ||
481 | result = usb_submit_urb(urb, GFP_ATOMIC); | 483 | result = usb_submit_urb(urb, GFP_ATOMIC); |
482 | if (result) | 484 | if (result) |
@@ -490,7 +492,7 @@ static void aircable_read_bulk_callback(struct urb *urb) | |||
490 | } | 492 | } |
491 | 493 | ||
492 | usb_serial_debug_data(debug, &port->dev, __func__, | 494 | usb_serial_debug_data(debug, &port->dev, __func__, |
493 | urb->actual_length,urb->transfer_buffer); | 495 | urb->actual_length, urb->transfer_buffer); |
494 | 496 | ||
495 | tty = port->tty; | 497 | tty = port->tty; |
496 | if (tty && urb->actual_length) { | 498 | if (tty && urb->actual_length) { |
@@ -507,9 +509,9 @@ static void aircable_read_bulk_callback(struct urb *urb) | |||
507 | no_packages = urb->actual_length / (HCI_COMPLETE_FRAME); | 509 | no_packages = urb->actual_length / (HCI_COMPLETE_FRAME); |
508 | 510 | ||
509 | if (urb->actual_length % HCI_COMPLETE_FRAME != 0) | 511 | if (urb->actual_length % HCI_COMPLETE_FRAME != 0) |
510 | no_packages+=1; | 512 | no_packages++; |
511 | 513 | ||
512 | for (i = 0; i < no_packages ;i++) { | 514 | for (i = 0; i < no_packages; i++) { |
513 | if (remaining > (HCI_COMPLETE_FRAME)) | 515 | if (remaining > (HCI_COMPLETE_FRAME)) |
514 | package_length = HCI_COMPLETE_FRAME; | 516 | package_length = HCI_COMPLETE_FRAME; |
515 | else | 517 | else |
@@ -529,7 +531,7 @@ static void aircable_read_bulk_callback(struct urb *urb) | |||
529 | if (port->open_count) { | 531 | if (port->open_count) { |
530 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, | 532 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, |
531 | usb_rcvbulkpipe(port->serial->dev, | 533 | usb_rcvbulkpipe(port->serial->dev, |
532 | port->bulk_in_endpointAddress), | 534 | port->bulk_in_endpointAddress), |
533 | port->read_urb->transfer_buffer, | 535 | port->read_urb->transfer_buffer, |
534 | port->read_urb->transfer_buffer_length, | 536 | port->read_urb->transfer_buffer_length, |
535 | aircable_read_bulk_callback, port); | 537 | aircable_read_bulk_callback, port); |
@@ -602,7 +604,7 @@ static struct usb_serial_driver aircable_device = { | |||
602 | .unthrottle = aircable_unthrottle, | 604 | .unthrottle = aircable_unthrottle, |
603 | }; | 605 | }; |
604 | 606 | ||
605 | static int __init aircable_init (void) | 607 | static int __init aircable_init(void) |
606 | { | 608 | { |
607 | int retval; | 609 | int retval; |
608 | retval = usb_serial_register(&aircable_device); | 610 | retval = usb_serial_register(&aircable_device); |
@@ -619,7 +621,7 @@ failed_usb_register: | |||
619 | return retval; | 621 | return retval; |
620 | } | 622 | } |
621 | 623 | ||
622 | static void __exit aircable_exit (void) | 624 | static void __exit aircable_exit(void) |
623 | { | 625 | { |
624 | usb_deregister(&aircable_driver); | 626 | usb_deregister(&aircable_driver); |
625 | usb_serial_deregister(&aircable_device); | 627 | usb_serial_deregister(&aircable_device); |
diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c index 7290b41fa11c..0798c14ce787 100644 --- a/drivers/usb/serial/airprime.c +++ b/drivers/usb/serial/airprime.c | |||
@@ -68,8 +68,9 @@ static int airprime_send_setup(struct usb_serial_port *port) | |||
68 | val |= 0x02; | 68 | val |= 0x02; |
69 | 69 | ||
70 | return usb_control_msg(serial->dev, | 70 | return usb_control_msg(serial->dev, |
71 | usb_rcvctrlpipe(serial->dev, 0), | 71 | usb_rcvctrlpipe(serial->dev, 0), |
72 | 0x22,0x21,val,0,NULL,0,USB_CTRL_SET_TIMEOUT); | 72 | 0x22, 0x21, val, 0, NULL, 0, |
73 | USB_CTRL_SET_TIMEOUT); | ||
73 | } | 74 | } |
74 | 75 | ||
75 | return 0; | 76 | return 0; |
@@ -90,17 +91,19 @@ static void airprime_read_bulk_callback(struct urb *urb) | |||
90 | __func__, status); | 91 | __func__, status); |
91 | return; | 92 | return; |
92 | } | 93 | } |
93 | usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); | 94 | usb_serial_debug_data(debug, &port->dev, __func__, |
95 | urb->actual_length, data); | ||
94 | 96 | ||
95 | tty = port->tty; | 97 | tty = port->tty; |
96 | if (tty && urb->actual_length) { | 98 | if (tty && urb->actual_length) { |
97 | tty_insert_flip_string (tty, data, urb->actual_length); | 99 | tty_insert_flip_string(tty, data, urb->actual_length); |
98 | tty_flip_buffer_push (tty); | 100 | tty_flip_buffer_push(tty); |
99 | } | 101 | } |
100 | 102 | ||
101 | result = usb_submit_urb (urb, GFP_ATOMIC); | 103 | result = usb_submit_urb(urb, GFP_ATOMIC); |
102 | if (result) | 104 | if (result) |
103 | dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", | 105 | dev_err(&port->dev, |
106 | "%s - failed resubmitting read urb, error %d\n", | ||
104 | __func__, result); | 107 | __func__, result); |
105 | return; | 108 | return; |
106 | } | 109 | } |
@@ -115,7 +118,7 @@ static void airprime_write_bulk_callback(struct urb *urb) | |||
115 | dbg("%s - port %d", __func__, port->number); | 118 | dbg("%s - port %d", __func__, port->number); |
116 | 119 | ||
117 | /* free up the transfer buffer, as usb_free_urb() does not do this */ | 120 | /* free up the transfer buffer, as usb_free_urb() does not do this */ |
118 | kfree (urb->transfer_buffer); | 121 | kfree(urb->transfer_buffer); |
119 | 122 | ||
120 | if (status) | 123 | if (status) |
121 | dbg("%s - nonzero write bulk status received: %d", | 124 | dbg("%s - nonzero write bulk status received: %d", |
@@ -171,7 +174,7 @@ static int airprime_open(struct usb_serial_port *port, struct file *filp) | |||
171 | } | 174 | } |
172 | usb_fill_bulk_urb(urb, serial->dev, | 175 | usb_fill_bulk_urb(urb, serial->dev, |
173 | usb_rcvbulkpipe(serial->dev, | 176 | usb_rcvbulkpipe(serial->dev, |
174 | port->bulk_out_endpointAddress), | 177 | port->bulk_out_endpointAddress), |
175 | buffer, buffer_size, | 178 | buffer, buffer_size, |
176 | airprime_read_bulk_callback, port); | 179 | airprime_read_bulk_callback, port); |
177 | result = usb_submit_urb(urb, GFP_KERNEL); | 180 | result = usb_submit_urb(urb, GFP_KERNEL); |
@@ -183,7 +186,8 @@ static int airprime_open(struct usb_serial_port *port, struct file *filp) | |||
183 | __func__, i, port->number, result); | 186 | __func__, i, port->number, result); |
184 | goto errout; | 187 | goto errout; |
185 | } | 188 | } |
186 | /* remember this urb so we can kill it when the port is closed */ | 189 | /* remember this urb so we can kill it when the |
190 | port is closed */ | ||
187 | priv->read_urbp[i] = urb; | 191 | priv->read_urbp[i] = urb; |
188 | } | 192 | } |
189 | 193 | ||
@@ -192,22 +196,22 @@ static int airprime_open(struct usb_serial_port *port, struct file *filp) | |||
192 | goto out; | 196 | goto out; |
193 | 197 | ||
194 | errout: | 198 | errout: |
195 | /* some error happened, cancel any submitted urbs and clean up anything that | 199 | /* some error happened, cancel any submitted urbs and clean up |
196 | got allocated successfully */ | 200 | anything that got allocated successfully */ |
197 | 201 | ||
198 | while (i-- != 0) { | 202 | while (i-- != 0) { |
199 | urb = priv->read_urbp[i]; | 203 | urb = priv->read_urbp[i]; |
200 | buffer = urb->transfer_buffer; | 204 | buffer = urb->transfer_buffer; |
201 | usb_kill_urb (urb); | 205 | usb_kill_urb(urb); |
202 | usb_free_urb (urb); | 206 | usb_free_urb(urb); |
203 | kfree (buffer); | 207 | kfree(buffer); |
204 | } | 208 | } |
205 | 209 | ||
206 | out: | 210 | out: |
207 | return result; | 211 | return result; |
208 | } | 212 | } |
209 | 213 | ||
210 | static void airprime_close(struct usb_serial_port *port, struct file * filp) | 214 | static void airprime_close(struct usb_serial_port *port, struct file *filp) |
211 | { | 215 | { |
212 | struct airprime_private *priv = usb_get_serial_port_data(port); | 216 | struct airprime_private *priv = usb_get_serial_port_data(port); |
213 | int i; | 217 | int i; |
@@ -223,13 +227,13 @@ static void airprime_close(struct usb_serial_port *port, struct file * filp) | |||
223 | mutex_unlock(&port->serial->disc_mutex); | 227 | mutex_unlock(&port->serial->disc_mutex); |
224 | 228 | ||
225 | for (i = 0; i < NUM_READ_URBS; ++i) { | 229 | for (i = 0; i < NUM_READ_URBS; ++i) { |
226 | usb_kill_urb (priv->read_urbp[i]); | 230 | usb_kill_urb(priv->read_urbp[i]); |
227 | kfree (priv->read_urbp[i]->transfer_buffer); | 231 | kfree(priv->read_urbp[i]->transfer_buffer); |
228 | usb_free_urb (priv->read_urbp[i]); | 232 | usb_free_urb(priv->read_urbp[i]); |
229 | } | 233 | } |
230 | 234 | ||
231 | /* free up private structure */ | 235 | /* free up private structure */ |
232 | kfree (priv); | 236 | kfree(priv); |
233 | usb_set_serial_port_data(port, NULL); | 237 | usb_set_serial_port_data(port, NULL); |
234 | } | 238 | } |
235 | 239 | ||
@@ -259,10 +263,10 @@ static int airprime_write(struct usb_serial_port *port, | |||
259 | urb = usb_alloc_urb(0, GFP_ATOMIC); | 263 | urb = usb_alloc_urb(0, GFP_ATOMIC); |
260 | if (!urb) { | 264 | if (!urb) { |
261 | dev_err(&port->dev, "no more free urbs\n"); | 265 | dev_err(&port->dev, "no more free urbs\n"); |
262 | kfree (buffer); | 266 | kfree(buffer); |
263 | return -ENOMEM; | 267 | return -ENOMEM; |
264 | } | 268 | } |
265 | memcpy (buffer, buf, count); | 269 | memcpy(buffer, buf, count); |
266 | 270 | ||
267 | usb_serial_debug_data(debug, &port->dev, __func__, count, buffer); | 271 | usb_serial_debug_data(debug, &port->dev, __func__, count, buffer); |
268 | 272 | ||
@@ -279,7 +283,7 @@ static int airprime_write(struct usb_serial_port *port, | |||
279 | "%s - usb_submit_urb(write bulk) failed with status = %d\n", | 283 | "%s - usb_submit_urb(write bulk) failed with status = %d\n", |
280 | __func__, status); | 284 | __func__, status); |
281 | count = status; | 285 | count = status; |
282 | kfree (buffer); | 286 | kfree(buffer); |
283 | } else { | 287 | } else { |
284 | spin_lock_irqsave(&priv->lock, flags); | 288 | spin_lock_irqsave(&priv->lock, flags); |
285 | ++priv->outstanding_urbs; | 289 | ++priv->outstanding_urbs; |
@@ -287,7 +291,7 @@ static int airprime_write(struct usb_serial_port *port, | |||
287 | } | 291 | } |
288 | /* we are done with this urb, so let the host driver | 292 | /* we are done with this urb, so let the host driver |
289 | * really free it when it is finished with it */ | 293 | * really free it when it is finished with it */ |
290 | usb_free_urb (urb); | 294 | usb_free_urb(urb); |
291 | return count; | 295 | return count; |
292 | } | 296 | } |
293 | 297 | ||
@@ -315,8 +319,10 @@ static int __init airprime_init(void) | |||
315 | { | 319 | { |
316 | int retval; | 320 | int retval; |
317 | 321 | ||
318 | airprime_device.num_ports = | 322 | airprime_device.num_ports = endpoints; |
319 | (endpoints > 0 && endpoints <= MAX_BULK_EPS) ? endpoints : NUM_BULK_EPS; | 323 | if (endpoints < 0 || endpoints >= MAX_BULK_EPS) |
324 | airprime_device.num_ports = NUM_BULK_EPS; | ||
325 | |||
320 | retval = usb_serial_register(&airprime_device); | 326 | retval = usb_serial_register(&airprime_device); |
321 | if (retval) | 327 | if (retval) |
322 | return retval; | 328 | return retval; |
@@ -341,6 +347,7 @@ MODULE_LICENSE("GPL"); | |||
341 | module_param(debug, bool, S_IRUGO | S_IWUSR); | 347 | module_param(debug, bool, S_IRUGO | S_IWUSR); |
342 | MODULE_PARM_DESC(debug, "Debug enabled"); | 348 | MODULE_PARM_DESC(debug, "Debug enabled"); |
343 | module_param(buffer_size, int, 0); | 349 | module_param(buffer_size, int, 0); |
344 | MODULE_PARM_DESC(buffer_size, "Size of the transfer buffers in bytes (default 4096)"); | 350 | MODULE_PARM_DESC(buffer_size, |
351 | "Size of the transfer buffers in bytes (default 4096)"); | ||
345 | module_param(endpoints, int, 0); | 352 | module_param(endpoints, int, 0); |
346 | MODULE_PARM_DESC(endpoints, "Number of bulk EPs to configure (default 3)"); | 353 | MODULE_PARM_DESC(endpoints, "Number of bulk EPs to configure (default 3)"); |
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c index 599ab2e548a7..77895c8f8f31 100644 --- a/drivers/usb/serial/ark3116.c +++ b/drivers/usb/serial/ark3116.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #include <linux/usb.h> | 24 | #include <linux/usb.h> |
25 | #include <linux/usb/serial.h> | 25 | #include <linux/usb/serial.h> |
26 | #include <linux/serial.h> | 26 | #include <linux/serial.h> |
27 | #include <asm/uaccess.h> | 27 | #include <linux/uaccess.h> |
28 | 28 | ||
29 | 29 | ||
30 | static int debug; | 30 | static int debug; |
@@ -246,29 +246,29 @@ static void ark3116_set_termios(struct usb_serial_port *port, | |||
246 | baud = tty_get_baud_rate(port->tty); | 246 | baud = tty_get_baud_rate(port->tty); |
247 | 247 | ||
248 | switch (baud) { | 248 | switch (baud) { |
249 | case 75: | 249 | case 75: |
250 | case 150: | 250 | case 150: |
251 | case 300: | 251 | case 300: |
252 | case 600: | 252 | case 600: |
253 | case 1200: | 253 | case 1200: |
254 | case 1800: | 254 | case 1800: |
255 | case 2400: | 255 | case 2400: |
256 | case 4800: | 256 | case 4800: |
257 | case 9600: | 257 | case 9600: |
258 | case 19200: | 258 | case 19200: |
259 | case 38400: | 259 | case 38400: |
260 | case 57600: | 260 | case 57600: |
261 | case 115200: | 261 | case 115200: |
262 | case 230400: | 262 | case 230400: |
263 | case 460800: | 263 | case 460800: |
264 | /* Report the resulting rate back to the caller */ | 264 | /* Report the resulting rate back to the caller */ |
265 | tty_encode_baud_rate(port->tty, baud, baud); | 265 | tty_encode_baud_rate(port->tty, baud, baud); |
266 | break; | 266 | break; |
267 | /* set 9600 as default (if given baudrate is invalid for example) */ | 267 | /* set 9600 as default (if given baudrate is invalid for example) */ |
268 | default: | 268 | default: |
269 | tty_encode_baud_rate(port->tty, 9600, 9600); | 269 | tty_encode_baud_rate(port->tty, 9600, 9600); |
270 | case 0: | 270 | case 0: |
271 | baud = 9600; | 271 | baud = 9600; |
272 | } | 272 | } |
273 | 273 | ||
274 | /* | 274 | /* |
@@ -380,19 +380,19 @@ static int ark3116_ioctl(struct usb_serial_port *port, struct file *file, | |||
380 | switch (cmd) { | 380 | switch (cmd) { |
381 | case TIOCGSERIAL: | 381 | case TIOCGSERIAL: |
382 | /* XXX: Some of these values are probably wrong. */ | 382 | /* XXX: Some of these values are probably wrong. */ |
383 | memset(&serstruct, 0, sizeof (serstruct)); | 383 | memset(&serstruct, 0, sizeof(serstruct)); |
384 | serstruct.type = PORT_16654; | 384 | serstruct.type = PORT_16654; |
385 | serstruct.line = port->serial->minor; | 385 | serstruct.line = port->serial->minor; |
386 | serstruct.port = port->number; | 386 | serstruct.port = port->number; |
387 | serstruct.custom_divisor = 0; | 387 | serstruct.custom_divisor = 0; |
388 | serstruct.baud_base = 460800; | 388 | serstruct.baud_base = 460800; |
389 | 389 | ||
390 | if (copy_to_user(user_arg, &serstruct, sizeof (serstruct))) | 390 | if (copy_to_user(user_arg, &serstruct, sizeof(serstruct))) |
391 | return -EFAULT; | 391 | return -EFAULT; |
392 | 392 | ||
393 | return 0; | 393 | return 0; |
394 | case TIOCSSERIAL: | 394 | case TIOCSSERIAL: |
395 | if (copy_from_user(&serstruct, user_arg, sizeof (serstruct))) | 395 | if (copy_from_user(&serstruct, user_arg, sizeof(serstruct))) |
396 | return -EFAULT; | 396 | return -EFAULT; |
397 | return 0; | 397 | return 0; |
398 | default: | 398 | default: |
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c index d947d955bceb..ba28fdc9ccd2 100644 --- a/drivers/usb/serial/ch341.c +++ b/drivers/usb/serial/ch341.c | |||
@@ -130,7 +130,7 @@ static int ch341_get_status(struct usb_device *dev) | |||
130 | return -ENOMEM; | 130 | return -ENOMEM; |
131 | 131 | ||
132 | r = ch341_control_in(dev, 0x95, 0x0706, 0, buffer, size); | 132 | r = ch341_control_in(dev, 0x95, 0x0706, 0, buffer, size); |
133 | if ( r < 0) | 133 | if (r < 0) |
134 | goto out; | 134 | goto out; |
135 | 135 | ||
136 | /* Not having the datasheet for the CH341, we ignore the bytes returned | 136 | /* Not having the datasheet for the CH341, we ignore the bytes returned |