aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial
diff options
context:
space:
mode:
authorAlan Cox <alan@redhat.com>2008-07-22 06:14:49 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-22 16:03:26 -0400
commit3a0f43e9deffd9619ac34e3b6b9ba7089aa1e511 (patch)
tree11201bbc332685dbc5819e3dbb4cc91a060bdb6e /drivers/usb/serial
parentacc80758abc91e5d91f3f4ceb8dd94da2aa7064d (diff)
tty-usb-pl2303: 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/pl2303.c64
1 files changed, 36 insertions, 28 deletions
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index a0016725d314..2c9c446ad625 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -10,7 +10,8 @@
10 * modify it under the terms of the GNU General Public License version 10 * modify it under the terms of the GNU General Public License version
11 * 2 as published by the Free Software Foundation. 11 * 2 as published by the Free Software Foundation.
12 * 12 *
13 * See Documentation/usb/usb-serial.txt for more information on using this driver 13 * See Documentation/usb/usb-serial.txt for more information on using this
14 * driver
14 * 15 *
15 */ 16 */
16 17
@@ -25,7 +26,7 @@
25#include <linux/module.h> 26#include <linux/module.h>
26#include <linux/moduleparam.h> 27#include <linux/moduleparam.h>
27#include <linux/spinlock.h> 28#include <linux/spinlock.h>
28#include <asm/uaccess.h> 29#include <linux/uaccess.h>
29#include <linux/usb.h> 30#include <linux/usb.h>
30#include <linux/usb/serial.h> 31#include <linux/usb/serial.h>
31#include "pl2303.h" 32#include "pl2303.h"
@@ -116,7 +117,7 @@ static struct usb_driver pl2303_driver = {
116#define CONTROL_RTS 0x02 117#define CONTROL_RTS 0x02
117 118
118#define BREAK_REQUEST_TYPE 0x21 119#define BREAK_REQUEST_TYPE 0x21
119#define BREAK_REQUEST 0x23 120#define BREAK_REQUEST 0x23
120#define BREAK_ON 0xffff 121#define BREAK_ON 0xffff
121#define BREAK_OFF 0x0000 122#define BREAK_OFF 0x0000
122 123
@@ -222,7 +223,7 @@ static unsigned int pl2303_buf_data_avail(struct pl2303_buf *pb)
222 if (pb == NULL) 223 if (pb == NULL)
223 return 0; 224 return 0;
224 225
225 return ((pb->buf_size + pb->buf_put - pb->buf_get) % pb->buf_size); 226 return (pb->buf_size + pb->buf_put - pb->buf_get) % pb->buf_size;
226} 227}
227 228
228/* 229/*
@@ -236,7 +237,7 @@ static unsigned int pl2303_buf_space_avail(struct pl2303_buf *pb)
236 if (pb == NULL) 237 if (pb == NULL)
237 return 0; 238 return 0;
238 239
239 return ((pb->buf_size + pb->buf_get - pb->buf_put - 1) % pb->buf_size); 240 return (pb->buf_size + pb->buf_get - pb->buf_put - 1) % pb->buf_size;
240} 241}
241 242
242/* 243/*
@@ -395,7 +396,7 @@ static int pl2303_startup(struct usb_serial *serial)
395 396
396cleanup: 397cleanup:
397 kfree(buf); 398 kfree(buf);
398 for (--i; i>=0; --i) { 399 for (--i; i >= 0; --i) {
399 priv = usb_get_serial_port_data(serial->port[i]); 400 priv = usb_get_serial_port_data(serial->port[i]);
400 pl2303_buf_free(priv->buf); 401 pl2303_buf_free(priv->buf);
401 kfree(priv); 402 kfree(priv);
@@ -407,7 +408,7 @@ cleanup:
407static int set_control_lines(struct usb_device *dev, u8 value) 408static int set_control_lines(struct usb_device *dev, u8 value)
408{ 409{
409 int retval; 410 int retval;
410 411
411 retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 412 retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
412 SET_CONTROL_REQUEST, SET_CONTROL_REQUEST_TYPE, 413 SET_CONTROL_REQUEST, SET_CONTROL_REQUEST_TYPE,
413 value, 0, NULL, 0, 100); 414 value, 0, NULL, 0, 100);
@@ -452,7 +453,7 @@ static void pl2303_send(struct usb_serial_port *port)
452 dev_err(&port->dev, "%s - failed submitting write urb," 453 dev_err(&port->dev, "%s - failed submitting write urb,"
453 " error %d\n", __func__, result); 454 " error %d\n", __func__, result);
454 priv->write_urb_in_use = 0; 455 priv->write_urb_in_use = 0;
455 // TODO: reschedule pl2303_send 456 /* TODO: reschedule pl2303_send */
456 } 457 }
457 458
458 usb_serial_port_softint(port); 459 usb_serial_port_softint(port);
@@ -561,11 +562,19 @@ static void pl2303_set_termios(struct tty_struct *tty,
561 562
562 if (cflag & CSIZE) { 563 if (cflag & CSIZE) {
563 switch (cflag & CSIZE) { 564 switch (cflag & CSIZE) {
564 case CS5: buf[6] = 5; break; 565 case CS5:
565 case CS6: buf[6] = 6; break; 566 buf[6] = 5;
566 case CS7: buf[6] = 7; break; 567 break;
567 default: 568 case CS6:
568 case CS8: buf[6] = 8; break; 569 buf[6] = 6;
570 break;
571 case CS7:
572 buf[6] = 7;
573 break;
574 default:
575 case CS8:
576 buf[6] = 8;
577 break;
569 } 578 }
570 dbg("%s - data bits = %d", __func__, buf[6]); 579 dbg("%s - data bits = %d", __func__, buf[6]);
571 } 580 }
@@ -694,7 +703,7 @@ static void pl2303_close(struct tty_struct *tty,
694 /* that is not unnecessarily long) */ 703 /* that is not unnecessarily long) */
695 bps = tty_get_baud_rate(tty); 704 bps = tty_get_baud_rate(tty);
696 if (bps > 1200) 705 if (bps > 1200)
697 timeout = max((HZ*2560)/bps,HZ/10); 706 timeout = max((HZ*2560)/bps, HZ/10);
698 else 707 else
699 timeout = 2*HZ; 708 timeout = 2*HZ;
700 schedule_timeout_interruptible(timeout); 709 schedule_timeout_interruptible(timeout);
@@ -740,7 +749,7 @@ static int pl2303_open(struct tty_struct *tty,
740 if (tty) 749 if (tty)
741 pl2303_set_termios(tty, port, &tmp_termios); 750 pl2303_set_termios(tty, port, &tmp_termios);
742 751
743 //FIXME: need to assert RTS and DTR if CRTSCTS off 752 /* FIXME: need to assert RTS and DTR if CRTSCTS off */
744 753
745 dbg("%s - submitting read urb", __func__); 754 dbg("%s - submitting read urb", __func__);
746 port->read_urb->dev = serial->dev; 755 port->read_urb->dev = serial->dev;
@@ -843,12 +852,12 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg)
843 status = priv->line_status; 852 status = priv->line_status;
844 spin_unlock_irqrestore(&priv->lock, flags); 853 spin_unlock_irqrestore(&priv->lock, flags);
845 854
846 changed=prevstatus^status; 855 changed = prevstatus ^ status;
847 856
848 if (((arg & TIOCM_RNG) && (changed & UART_RING)) || 857 if (((arg & TIOCM_RNG) && (changed & UART_RING)) ||
849 ((arg & TIOCM_DSR) && (changed & UART_DSR)) || 858 ((arg & TIOCM_DSR) && (changed & UART_DSR)) ||
850 ((arg & TIOCM_CD) && (changed & UART_DCD)) || 859 ((arg & TIOCM_CD) && (changed & UART_DCD)) ||
851 ((arg & TIOCM_CTS) && (changed & UART_CTS)) ) { 860 ((arg & TIOCM_CTS) && (changed & UART_CTS))) {
852 return 0; 861 return 0;
853 } 862 }
854 prevstatus = status; 863 prevstatus = status;
@@ -864,15 +873,13 @@ static int pl2303_ioctl(struct tty_struct *tty, struct file *file,
864 dbg("%s (%d) cmd = 0x%04x", __func__, port->number, cmd); 873 dbg("%s (%d) cmd = 0x%04x", __func__, port->number, cmd);
865 874
866 switch (cmd) { 875 switch (cmd) {
867 case TIOCMIWAIT: 876 case TIOCMIWAIT:
868 dbg("%s (%d) TIOCMIWAIT", __func__, port->number); 877 dbg("%s (%d) TIOCMIWAIT", __func__, port->number);
869 return wait_modem_info(port, arg); 878 return wait_modem_info(port, arg);
870 879 default:
871 default: 880 dbg("%s not supported = 0x%04x", __func__, cmd);
872 dbg("%s not supported = 0x%04x", __func__, cmd); 881 break;
873 break;
874 } 882 }
875
876 return -ENOIOCTLCMD; 883 return -ENOIOCTLCMD;
877} 884}
878 885
@@ -889,7 +896,8 @@ static void pl2303_break_ctl(struct tty_struct *tty, int break_state)
889 state = BREAK_OFF; 896 state = BREAK_OFF;
890 else 897 else
891 state = BREAK_ON; 898 state = BREAK_ON;
892 dbg("%s - turning break %s", __func__, state==BREAK_OFF ? "off" : "on"); 899 dbg("%s - turning break %s", __func__,
900 state == BREAK_OFF ? "off" : "on");
893 901
894 result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 902 result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
895 BREAK_REQUEST, BREAK_REQUEST_TYPE, state, 903 BREAK_REQUEST, BREAK_REQUEST_TYPE, state,
@@ -943,7 +951,7 @@ static void pl2303_update_line_status(struct usb_serial_port *port,
943 if (actual_length < length) 951 if (actual_length < length)
944 return; 952 return;
945 953
946 /* Save off the uart status for others to look at */ 954 /* Save off the uart status for others to look at */
947 spin_lock_irqsave(&priv->lock, flags); 955 spin_lock_irqsave(&priv->lock, flags);
948 priv->line_status = data[status_idx]; 956 priv->line_status = data[status_idx];
949 spin_unlock_irqrestore(&priv->lock, flags); 957 spin_unlock_irqrestore(&priv->lock, flags);
@@ -1042,7 +1050,7 @@ static void pl2303_read_bulk_callback(struct urb *urb)
1042 1050
1043 /* break takes precedence over parity, */ 1051 /* break takes precedence over parity, */
1044 /* which takes precedence over framing errors */ 1052 /* which takes precedence over framing errors */
1045 if (line_status & UART_BREAK_ERROR ) 1053 if (line_status & UART_BREAK_ERROR)
1046 tty_flag = TTY_BREAK; 1054 tty_flag = TTY_BREAK;
1047 else if (line_status & UART_PARITY_ERROR) 1055 else if (line_status & UART_PARITY_ERROR)
1048 tty_flag = TTY_PARITY; 1056 tty_flag = TTY_PARITY;