[PATCH 59/70] tty-usb-pl2303: Coding style

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Alan Cox
Date: Friday, June 20, 2008 - 1:06 pm

From: Alan Cox <alan@redhat.com>



Signed-off-by: Alan Cox <alan@redhat.com>
---

 drivers/usb/serial/pl2303.c |   64 ++++++++++++++++++++++++-------------------
 1 files changed, 36 insertions(+), 28 deletions(-)


diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 8eec785..a65328a 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -10,7 +10,8 @@
  *	modify it under the terms of the GNU General Public License version
  *	2 as published by the Free Software Foundation.
  *
- * See Documentation/usb/usb-serial.txt for more information on using this driver
+ * See Documentation/usb/usb-serial.txt for more information on using this
+ * driver
  *
  */
 
@@ -25,7 +26,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/spinlock.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
 #include "pl2303.h"
@@ -115,7 +116,7 @@ static struct usb_driver pl2303_driver = {
 #define CONTROL_RTS			0x02
 
 #define BREAK_REQUEST_TYPE		0x21
-#define BREAK_REQUEST			0x23	
+#define BREAK_REQUEST			0x23
 #define BREAK_ON			0xffff
 #define BREAK_OFF			0x0000
 
@@ -221,7 +222,7 @@ static unsigned int pl2303_buf_data_avail(struct pl2303_buf *pb)
 	if (pb == NULL)
 		return 0;
 
-	return ((pb->buf_size + pb->buf_put - pb->buf_get) % pb->buf_size);
+	return (pb->buf_size + pb->buf_put - pb->buf_get) % pb->buf_size;
 }
 
 /*
@@ -235,7 +236,7 @@ static unsigned int pl2303_buf_space_avail(struct pl2303_buf *pb)
 	if (pb == NULL)
 		return 0;
 
-	return ((pb->buf_size + pb->buf_get - pb->buf_put - 1) % pb->buf_size);
+	return (pb->buf_size + pb->buf_get - pb->buf_put - 1) % pb->buf_size;
 }
 
 /*
@@ -394,7 +395,7 @@ static int pl2303_startup(struct usb_serial *serial)
 
 cleanup:
 	kfree(buf);
-	for (--i; i>=0; --i) {
+	for (--i; i >= 0; --i) {
 		priv = usb_get_serial_port_data(serial->port[i]);
 		pl2303_buf_free(priv->buf);
 		kfree(priv);
@@ -406,7 +407,7 @@ cleanup:
 static int set_control_lines(struct usb_device *dev, u8 value)
 {
 	int retval;
-	
+
 	retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
 				 SET_CONTROL_REQUEST, SET_CONTROL_REQUEST_TYPE,
 				 value, 0, NULL, 0, 100);
@@ -451,7 +452,7 @@ static void pl2303_send(struct usb_serial_port *port)
 		dev_err(&port->dev, "%s - failed submitting write urb,"
 			" error %d\n", __func__, result);
 		priv->write_urb_in_use = 0;
-		// TODO: reschedule pl2303_send
+		/* TODO: reschedule pl2303_send */
 	}
 
 	usb_serial_port_softint(port);
@@ -560,11 +561,19 @@ static void pl2303_set_termios(struct tty_struct *tty,
 
 	if (cflag & CSIZE) {
 		switch (cflag & CSIZE) {
-			case CS5:	buf[6] = 5;	break;
-			case CS6:	buf[6] = 6;	break;
-			case CS7:	buf[6] = 7;	break;
-			default:
-			case CS8:	buf[6] = 8;	break;
+		case CS5:
+			buf[6] = 5;
+			break;
+		case CS6:
+			buf[6] = 6;
+			break;
+		case CS7:
+			buf[6] = 7;
+			break;
+		default:
+		case CS8:
+			buf[6] = 8;
+			break;
 		}
 		dbg("%s - data bits = %d", __func__, buf[6]);
 	}
@@ -693,7 +702,7 @@ static void pl2303_close(struct tty_struct *tty,
 	/* that is not unnecessarily long) */
 	bps = tty_get_baud_rate(tty);
 	if (bps > 1200)
-		timeout = max((HZ*2560)/bps,HZ/10);
+		timeout = max((HZ*2560)/bps, HZ/10);
 	else
 		timeout = 2*HZ;
 	schedule_timeout_interruptible(timeout);
@@ -739,7 +748,7 @@ static int pl2303_open(struct tty_struct *tty,
 	if (tty)
 		pl2303_set_termios(tty, port, &tmp_termios);
 
-	//FIXME: need to assert RTS and DTR if CRTSCTS off
+	/* FIXME: need to assert RTS and DTR if CRTSCTS off */
 
 	dbg("%s - submitting read urb", __func__);
 	port->read_urb->dev = serial->dev;
@@ -842,12 +851,12 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg)
 		status = priv->line_status;
 		spin_unlock_irqrestore(&priv->lock, flags);
 
-		changed=prevstatus^status;
+		changed = prevstatus ^ status;
 
 		if (((arg & TIOCM_RNG) && (changed & UART_RING)) ||
 		    ((arg & TIOCM_DSR) && (changed & UART_DSR)) ||
 		    ((arg & TIOCM_CD)  && (changed & UART_DCD)) ||
-		    ((arg & TIOCM_CTS) && (changed & UART_CTS)) ) {
+		    ((arg & TIOCM_CTS) && (changed & UART_CTS))) {
 			return 0;
 		}
 		prevstatus = status;
@@ -863,15 +872,13 @@ static int pl2303_ioctl(struct tty_struct *tty, struct file *file,
 	dbg("%s (%d) cmd = 0x%04x", __func__, port->number, cmd);
 
 	switch (cmd) {
-		case TIOCMIWAIT:
-			dbg("%s (%d) TIOCMIWAIT", __func__,  port->number);
-			return wait_modem_info(port, arg);
-
-		default:
-			dbg("%s not supported = 0x%04x", __func__, cmd);
-			break;
+	case TIOCMIWAIT:
+		dbg("%s (%d) TIOCMIWAIT", __func__,  port->number);
+		return wait_modem_info(port, arg);
+	default:
+		dbg("%s not supported = 0x%04x", __func__, cmd);
+		break;
 	}
-
 	return -ENOIOCTLCMD;
 }
 
@@ -888,7 +895,8 @@ static void pl2303_break_ctl(struct tty_struct *tty, int break_state)
 		state = BREAK_OFF;
 	else
 		state = BREAK_ON;
-	dbg("%s - turning break %s", __func__, state==BREAK_OFF ? "off" : "on");
+	dbg("%s - turning break %s", __func__,
+			state == BREAK_OFF ? "off" : "on");
 
 	result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
 				 BREAK_REQUEST, BREAK_REQUEST_TYPE, state,
@@ -942,7 +950,7 @@ static void pl2303_update_line_status(struct usb_serial_port *port,
 	if (actual_length < length)
 		return;
 
-        /* Save off the uart status for others to look at */
+	/* Save off the uart status for others to look at */
 	spin_lock_irqsave(&priv->lock, flags);
 	priv->line_status = data[status_idx];
 	spin_unlock_irqrestore(&priv->lock, flags);
@@ -1041,7 +1049,7 @@ static void pl2303_read_bulk_callback(struct urb *urb)
 
 	/* break takes precedence over parity, */
 	/* which takes precedence over framing errors */
-	if (line_status & UART_BREAK_ERROR )
+	if (line_status & UART_BREAK_ERROR)
 		tty_flag = TTY_BREAK;
 	else if (line_status & UART_PARITY_ERROR)
 		tty_flag = TTY_PARITY;

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/70] tty updates proposed for 2.6.27, Alan Cox, (Fri Jun 20, 12:57 pm)
[PATCH 01/70] tty: Ldisc revamp, Alan Cox, (Fri Jun 20, 12:58 pm)
[PATCH 02/70] drivers/char/rio/: remove VCS tags, Alan Cox, (Fri Jun 20, 12:58 pm)
[PATCH 03/70] drivers/serial/: remove CVS keywords, Alan Cox, (Fri Jun 20, 12:58 pm)
[PATCH 05/70] tty.h: clean up, Alan Cox, (Fri Jun 20, 12:58 pm)
[PATCH 06/70] epca: use tty_port, Alan Cox, (Fri Jun 20, 12:59 pm)
[PATCH 07/70] esp: use tty_port, Alan Cox, (Fri Jun 20, 12:59 pm)
[PATCH 08/70] gs: use tty_port, Alan Cox, (Fri Jun 20, 12:59 pm)
[PATCH 09/70] riscom8: use tty_port, Alan Cox, (Fri Jun 20, 12:59 pm)
[PATCH 10/70] riscom8: remove bogus checks, Alan Cox, (Fri Jun 20, 12:59 pm)
[PATCH 11/70] isicom: use tty_port, Alan Cox, (Fri Jun 20, 12:59 pm)
[PATCH 12/70] istallion: use tty_port, Alan Cox, (Fri Jun 20, 12:59 pm)
[PATCH 13/70] moxa: use tty_port, Alan Cox, (Fri Jun 20, 12:59 pm)
[PATCH 14/70] mxser: use tty_port, Alan Cox, (Fri Jun 20, 12:59 pm)
[PATCH 15/70] rocket: use tty_port, Alan Cox, (Fri Jun 20, 1:00 pm)
[PATCH 16/70] serial: use tty_port, Alan Cox, (Fri Jun 20, 1:00 pm)
[PATCH 17/70] stallion: use tty_port, Alan Cox, (Fri Jun 20, 1:00 pm)
[PATCH 18/70] synclink: use tty_port, Alan Cox, (Fri Jun 20, 1:00 pm)
[PATCH 19/70] tty: Clean up tiocmset, Alan Cox, (Fri Jun 20, 1:00 pm)
[PATCH 20/70] cyclades: use tty_port, Alan Cox, (Fri Jun 20, 1:00 pm)
[PATCH 22/70] tty: add more tty_port fields, Alan Cox, (Fri Jun 20, 1:00 pm)
[PATCH 24/70] whiteheat: coding style, Alan Cox, (Fri Jun 20, 1:01 pm)
[PATCH 26/70] belkin_sa: clean up code, Alan Cox, (Fri Jun 20, 1:01 pm)
[PATCH 27/70] usb-serial-bus: tidy coding style, Alan Cox, (Fri Jun 20, 1:01 pm)
[PATCH 29/70] tty-usb-console: Fix termios, Alan Cox, (Fri Jun 20, 1:01 pm)
[PATCH 30/70] cp2101: coding style, Alan Cox, (Fri Jun 20, 1:02 pm)
[PATCH 31/70] cyberjack: Coding style, Alan Cox, (Fri Jun 20, 1:02 pm)
[PATCH 32/70] cypress_m8: coding style, Alan Cox, (Fri Jun 20, 1:02 pm)
[PATCH 34/70] digi_acceleport: coding style, Alan Cox, (Fri Jun 20, 1:02 pm)
[PATCH 35/70] empeg: Coding style, Alan Cox, (Fri Jun 20, 1:02 pm)
[PATCH 36/70] ftdi_sio: Coding style, Alan Cox, (Fri Jun 20, 1:02 pm)
[PATCH 37/70] funsoft: Switch to linux/uaccess, Alan Cox, (Fri Jun 20, 1:02 pm)
[PATCH 38/70] garmin_gps: Coding style, Alan Cox, (Fri Jun 20, 1:03 pm)
[PATCH 39/70] tty-usb-generic: Code cleanup, Alan Cox, (Fri Jun 20, 1:03 pm)
[PATCH 40/70] tty-usb-hp4x: Fix overlong line, Alan Cox, (Fri Jun 20, 1:03 pm)
[PATCH 41/70] tty-usb-visor: Coding style, Alan Cox, (Fri Jun 20, 1:03 pm)
[PATCH 42/70] tty-usb-io_edgeport: Coding style, Alan Cox, (Fri Jun 20, 1:03 pm)
[PATCH 44/70] usb-serial: Coding style, Alan Cox, (Fri Jun 20, 1:03 pm)
[PATCH 45/70] io_ti: Minor coding style, Alan Cox, (Fri Jun 20, 1:04 pm)
[PATCH 46/70] ipaq: Coding style, Alan Cox, (Fri Jun 20, 1:04 pm)
[PATCH 47/70] tty-usb-ipw: Coding style, Alan Cox, (Fri Jun 20, 1:04 pm)
[PATCH 50/70] tty-usb-keyspan: Coding style, Alan Cox, (Fri Jun 20, 1:04 pm)
[PATCH 52/70] tty-usb-keyspan-pda: Coding style, Alan Cox, (Fri Jun 20, 1:04 pm)
[PATCH 53/70] tty-usb-kl5kusb105: Coding style, Alan Cox, (Fri Jun 20, 1:05 pm)
[PATCH 55/70] tty-usb-kobil-sct: Coding style, Alan Cox, (Fri Jun 20, 1:05 pm)
[PATCH 56/70] kobil_sct: Fix ioctls, Alan Cox, (Fri Jun 20, 1:05 pm)
[PATCH 57/70] tty-usb-mct-u232: Coding style, Alan Cox, (Fri Jun 20, 1:05 pm)
[PATCH 58/70] mct_u232: Use flip buffer functions, Alan Cox, (Fri Jun 20, 1:05 pm)
[PATCH 59/70] tty-usb-pl2303: Coding style, Alan Cox, (Fri Jun 20, 1:06 pm)
[PATCH 61/70] tty-usb-spcp8x5: Minor coding style, Alan Cox, (Fri Jun 20, 1:06 pm)
[PATCH 62/70] tty-usb-ti-usb: Coding style, Alan Cox, (Fri Jun 20, 1:06 pm)
[PATCH 63/70] tty-usb-safe-serial: Coding style, Alan Cox, (Fri Jun 20, 1:06 pm)
[PATCH 64/70] tty-usb-oti6858: Coding style, Alan Cox, (Fri Jun 20, 1:06 pm)
[PATCH 65/70] tty-usb-option: Coding style, Alan Cox, (Fri Jun 20, 1:06 pm)
[PATCH 66/70] tty-usb-omninet: Coding style, Alan Cox, (Fri Jun 20, 1:06 pm)
[PATCH 67/70] omninet: Use string flip functions, Alan Cox, (Fri Jun 20, 1:07 pm)
[PATCH 69/70] whiteheat: remove unused variable, Alan Cox, (Fri Jun 20, 1:07 pm)
[PATCH 70/70] tty-usb-mos7720: Coding style, Alan Cox, (Fri Jun 20, 1:07 pm)
Re: [PATCH 00/70] tty updates proposed for 2.6.27, Johannes Weiner, (Fri Jun 20, 4:39 pm)
Re: [PATCH 00/70] tty updates proposed for 2.6.27, Marcel Holtmann, (Sat Jun 21, 6:23 am)
Re: [PATCH 01/70] tty: Ldisc revamp, Louis Rilling, (Mon Jun 23, 6:39 am)
Re: [PATCH 01/70] tty: Ldisc revamp, Alan Cox, (Mon Jun 23, 7:11 am)