All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: linux-kernel@vger.kernel.org
Subject: [PATCH 64/70] tty-usb-oti6858: Coding style
Date: Fri, 20 Jun 2008 21:06:42 +0100	[thread overview]
Message-ID: <20080620200640.1479.93783.stgit@localhost.localdomain> (raw)
In-Reply-To: <20080620195406.1479.12620.stgit@localhost.localdomain>

From: Alan Cox <alan@redhat.com>



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

 drivers/usb/serial/oti6858.c |  136 ++++++++++++++++++++++--------------------
 1 files changed, 70 insertions(+), 66 deletions(-)


diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c
index 069d276..81db571 100644
--- a/drivers/usb/serial/oti6858.c
+++ b/drivers/usb/serial/oti6858.c
@@ -25,7 +25,8 @@
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License.
  *
- * 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
  *
  * TODO:
  *  - implement correct flushing for ioctls and oti6858_close()
@@ -49,7 +50,7 @@
 #include <linux/spinlock.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include "oti6858.h"
 
 #define OTI6858_DESCRIPTION \
@@ -135,9 +136,9 @@ struct oti6858_control_pkt {
 
 #define OTI6858_CTRL_PKT_SIZE	sizeof(struct oti6858_control_pkt)
 #define OTI6858_CTRL_EQUALS_PENDING(a, priv) \
-	(    ((a)->divisor == (priv)->pending_setup.divisor) \
+	(((a)->divisor == (priv)->pending_setup.divisor) \
 	  && ((a)->control == (priv)->pending_setup.control) \
-	  && ((a)->frame_fmt == (priv)->pending_setup.frame_fmt) )
+	  && ((a)->frame_fmt == (priv)->pending_setup.frame_fmt))
 
 /* function prototypes */
 static int oti6858_open(struct tty_struct *tty,
@@ -220,7 +221,7 @@ struct oti6858_private {
 	struct delayed_work delayed_setup_work;
 
 	wait_queue_head_t intr_wait;
-        struct usb_serial_port *port;   /* USB port with which associated */
+	struct usb_serial_port *port;   /* USB port with which associated */
 };
 
 #undef dbg
@@ -229,7 +230,8 @@ struct oti6858_private {
 
 static void setup_line(struct work_struct *work)
 {
-	struct oti6858_private *priv = container_of(work, struct oti6858_private, delayed_setup_work.work);
+	struct oti6858_private *priv = container_of(work,
+			struct oti6858_private, delayed_setup_work.work);
 	struct usb_serial_port *port = priv->port;
 	struct oti6858_control_pkt *new_setup;
 	unsigned long flags;
@@ -237,10 +239,12 @@ static void setup_line(struct work_struct *work)
 
 	dbg("%s(port = %d)", __func__, port->number);
 
-	if ((new_setup = kmalloc(OTI6858_CTRL_PKT_SIZE, GFP_KERNEL)) == NULL) {
+	new_setup = kmalloc(OTI6858_CTRL_PKT_SIZE, GFP_KERNEL);
+	if (new_setup == NULL) {
 		dev_err(&port->dev, "%s(): out of memory!\n", __func__);
 		/* we will try again */
-		schedule_delayed_work(&priv->delayed_setup_work, msecs_to_jiffies(2));
+		schedule_delayed_work(&priv->delayed_setup_work,
+						msecs_to_jiffies(2));
 		return;
 	}
 
@@ -256,7 +260,8 @@ static void setup_line(struct work_struct *work)
 		dev_err(&port->dev, "%s(): error reading status\n", __func__);
 		kfree(new_setup);
 		/* we will try again */
-		schedule_delayed_work(&priv->delayed_setup_work, msecs_to_jiffies(2));
+		schedule_delayed_work(&priv->delayed_setup_work,
+							msecs_to_jiffies(2));
 		return;
 	}
 
@@ -297,7 +302,8 @@ static void setup_line(struct work_struct *work)
 
 void send_data(struct work_struct *work)
 {
-	struct oti6858_private *priv = container_of(work, struct oti6858_private, delayed_write_work.work);
+	struct oti6858_private *priv = container_of(work,
+			struct oti6858_private, delayed_write_work.work);
 	struct usb_serial_port *port = priv->port;
 	int count = 0, result;
 	unsigned long flags;
@@ -308,7 +314,8 @@ void send_data(struct work_struct *work)
 	spin_lock_irqsave(&priv->lock, flags);
 	if (priv->flags.write_urb_in_use) {
 		spin_unlock_irqrestore(&priv->lock, flags);
-		schedule_delayed_work(&priv->delayed_write_work, msecs_to_jiffies(2));
+		schedule_delayed_work(&priv->delayed_write_work,
+						msecs_to_jiffies(2));
 		return;
 	}
 	priv->flags.write_urb_in_use = 1;
@@ -359,8 +366,8 @@ void send_data(struct work_struct *work)
 
 static int oti6858_startup(struct usb_serial *serial)
 {
-        struct usb_serial_port *port = serial->port[0];
-        struct oti6858_private *priv;
+	struct usb_serial_port *port = serial->port[0];
+	struct oti6858_private *priv;
 	int i;
 
 	for (i = 0; i < serial->num_ports; ++i) {
@@ -375,8 +382,8 @@ static int oti6858_startup(struct usb_serial *serial)
 
 		spin_lock_init(&priv->lock);
 		init_waitqueue_head(&priv->intr_wait);
-//		INIT_WORK(&priv->setup_work, setup_line, serial->port[i]);
-//		INIT_WORK(&priv->write_work, send_data, serial->port[i]);
+/*		INIT_WORK(&priv->setup_work, setup_line, serial->port[i]); */
+/*		INIT_WORK(&priv->write_work, send_data, serial->port[i]); */
 		priv->port = port;
 		INIT_DELAYED_WORK(&priv->delayed_setup_work, setup_line);
 		INIT_DELAYED_WORK(&priv->delayed_write_work, send_data);
@@ -482,19 +489,19 @@ static void oti6858_set_termios(struct tty_struct *tty,
 
 	frame_fmt &= ~FMT_DATA_BITS_MASK;
 	switch (cflag & CSIZE) {
-		case CS5:
-			frame_fmt |= FMT_DATA_BITS_5;
-			break;
-		case CS6:
-			frame_fmt |= FMT_DATA_BITS_6;
-			break;
-		case CS7:
-			frame_fmt |= FMT_DATA_BITS_7;
-			break;
-		default:
-		case CS8:
-			frame_fmt |= FMT_DATA_BITS_8;
-			break;
+	case CS5:
+		frame_fmt |= FMT_DATA_BITS_5;
+		break;
+	case CS6:
+		frame_fmt |= FMT_DATA_BITS_6;
+		break;
+	case CS7:
+		frame_fmt |= FMT_DATA_BITS_7;
+		break;
+	default:
+	case CS8:
+		frame_fmt |= FMT_DATA_BITS_8;
+		break;
 	}
 
 	/* manufacturer claims that this device can work with baud rates
@@ -517,19 +524,17 @@ static void oti6858_set_termios(struct tty_struct *tty,
 	}
 
 	frame_fmt &= ~FMT_STOP_BITS_MASK;
-	if ((cflag & CSTOPB) != 0) {
+	if ((cflag & CSTOPB) != 0)
 		frame_fmt |= FMT_STOP_BITS_2;
-	} else {
+	else
 		frame_fmt |= FMT_STOP_BITS_1;
-	}
 
 	frame_fmt &= ~FMT_PARITY_MASK;
 	if ((cflag & PARENB) != 0) {
-		if ((cflag & PARODD) != 0) {
+		if ((cflag & PARODD) != 0)
 			frame_fmt |= FMT_PARITY_ODD;
-		} else {
+		else
 			frame_fmt |= FMT_PARITY_EVEN;
-		}
 	} else {
 		frame_fmt |= FMT_PARITY_NONE;
 	}
@@ -584,7 +589,8 @@ static int oti6858_open(struct tty_struct *tty,
 	if (port->port.count != 1)
 		return 0;
 
-	if ((buf = kmalloc(OTI6858_CTRL_PKT_SIZE, GFP_KERNEL)) == NULL) {
+	buf = kmalloc(OTI6858_CTRL_PKT_SIZE, GFP_KERNEL);
+	if (buf == NULL) {
 		dev_err(&port->dev, "%s(): out of memory!\n", __func__);
 		return -ENOMEM;
 	}
@@ -729,11 +735,10 @@ static int oti6858_tiocmset(struct tty_struct *tty, struct file *file,
 	if ((clear & TIOCM_DTR) != 0)
 		control &= ~CONTROL_DTR_HIGH;
 
-	if (control != priv->pending_setup.control) {
+	if (control != priv->pending_setup.control)
 		priv->pending_setup.control = control;
-	}
-	spin_unlock_irqrestore(&priv->lock, flags);
 
+	spin_unlock_irqrestore(&priv->lock, flags);
 	return 0;
 }
 
@@ -785,7 +790,8 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg)
 	spin_unlock_irqrestore(&priv->lock, flags);
 
 	while (1) {
-		wait_event_interruptible(priv->intr_wait, priv->status.pin_state != prev);
+		wait_event_interruptible(priv->intr_wait,
+					priv->status.pin_state != prev);
 		if (signal_pending(current))
 			return -ERESTARTSYS;
 
@@ -795,12 +801,11 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg)
 
 		changed = prev ^ status;
 		/* FIXME: check if this is correct (active high/low) */
-		if (	((arg & TIOCM_RNG) && (changed & PIN_RI)) ||
-			((arg & TIOCM_DSR) && (changed & PIN_DSR)) ||
-			((arg & TIOCM_CD)  && (changed & PIN_DCD)) ||
-			((arg & TIOCM_CTS) && (changed & PIN_CTS))) {
-				return 0;
-		}
+		if (((arg & TIOCM_RNG) && (changed & PIN_RI)) ||
+		    ((arg & TIOCM_DSR) && (changed & PIN_DSR)) ||
+		    ((arg & TIOCM_CD)  && (changed & PIN_DCD)) ||
+		    ((arg & TIOCM_CTS) && (changed & PIN_CTS)))
+			return 0;
 		prev = status;
 	}
 
@@ -817,15 +822,13 @@ static int oti6858_ioctl(struct tty_struct *tty, struct file *file,
 				__func__, port->number, cmd, arg);
 
 	switch (cmd) {
-		case TIOCMIWAIT:
-			dbg("%s(): TIOCMIWAIT", __func__);
-			return wait_modem_info(port, arg);
-
-		default:
-			dbg("%s(): 0x%04x not supported", __func__, cmd);
-			break;
+	case TIOCMIWAIT:
+		dbg("%s(): TIOCMIWAIT", __func__);
+		return wait_modem_info(port, arg);
+	default:
+		dbg("%s(): 0x%04x not supported", __func__, cmd);
+		break;
 	}
-
 	return -ENOIOCTLCMD;
 }
 
@@ -941,7 +944,7 @@ static void oti6858_read_int_callback(struct urb *urb)
 		spin_lock_irqsave(&priv->lock, flags);
 		if (priv->flags.write_urb_in_use == 0
 				&& oti6858_buf_data_avail(priv->buf) != 0) {
-			schedule_delayed_work(&priv->delayed_write_work,0);
+			schedule_delayed_work(&priv->delayed_write_work, 0);
 			resubmit = 0;
 		}
 		spin_unlock_irqrestore(&priv->lock, flags);
@@ -950,7 +953,7 @@ static void oti6858_read_int_callback(struct urb *urb)
 	if (resubmit) {
 		int result;
 
-//		dbg("%s(): submitting interrupt urb", __func__);
+/*		dbg("%s(): submitting interrupt urb", __func__); */
 		urb->dev = port->serial->dev;
 		result = usb_submit_urb(urb, GFP_ATOMIC);
 		if (result != 0) {
@@ -985,8 +988,10 @@ static void oti6858_read_bulk_callback(struct urb *urb)
 		}
 		/*
 		if (status == -EPROTO) {
-			// PL2303 mysteriously fails with -EPROTO reschedule the read
-			dbg("%s - caught -EPROTO, resubmitting the urb", __func__);
+			* PL2303 mysteriously fails with -EPROTO reschedule
+			   the read *
+			dbg("%s - caught -EPROTO, resubmitting the urb",
+								__func__);
 			result = usb_submit_urb(urb, GFP_ATOMIC);
 			if (result)
 				dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result);
@@ -1003,7 +1008,7 @@ static void oti6858_read_bulk_callback(struct urb *urb)
 		tty_flip_buffer_push(tty);
 	}
 
-	// schedule the interrupt urb if we are still open */
+	/* schedule the interrupt urb if we are still open */
 	if (port->port.count != 0) {
 		port->interrupt_in_urb->dev = port->serial->dev;
 		result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
@@ -1055,7 +1060,7 @@ static void oti6858_write_bulk_callback(struct urb *urb)
 
 	priv->flags.write_urb_in_use = 0;
 
-	// schedule the interrupt urb if we are still open */
+	/* schedule the interrupt urb if we are still open */
 	port->interrupt_in_urb->dev = port->serial->dev;
 	dbg("%s(): submitting interrupt urb", __func__);
 	result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
@@ -1130,7 +1135,7 @@ static unsigned int oti6858_buf_data_avail(struct oti6858_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;
 }
 
 /*
@@ -1143,7 +1148,7 @@ static unsigned int oti6858_buf_space_avail(struct oti6858_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;
 }
 
 /*
@@ -1230,13 +1235,12 @@ static int __init oti6858_init(void)
 {
 	int retval;
 
-	if ((retval = usb_serial_register(&oti6858_device)) == 0) {
-		if ((retval = usb_register(&oti6858_driver)) != 0)
+	retval = usb_serial_register(&oti6858_device);
+	if (retval == 0) {
+		retval = usb_register(&oti6858_driver);
+		if (retval)
 			usb_serial_deregister(&oti6858_device);
-		else
-			return 0;
 	}
-
 	return retval;
 }
 


  parent reply	other threads:[~2008-06-20 20:41 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-20 19:57 [PATCH 00/70] tty updates proposed for 2.6.27 Alan Cox
2008-06-20 19:58 ` [PATCH 01/70] tty: Ldisc revamp Alan Cox
2008-06-23 13:39   ` Louis Rilling
2008-06-23 14:11     ` Alan Cox
2008-06-20 19:58 ` [PATCH 02/70] drivers/char/rio/: remove VCS tags Alan Cox
2008-06-20 19:58 ` [PATCH 03/70] drivers/serial/: remove CVS keywords Alan Cox
2008-06-20 19:58 ` [PATCH 04/70] tty: Introduce a tty_port common structure Alan Cox
2008-06-20 19:58 ` [PATCH 05/70] tty.h: clean up Alan Cox
2008-06-20 19:59 ` [PATCH 06/70] epca: use tty_port Alan Cox
2008-06-20 19:59 ` [PATCH 07/70] esp: " Alan Cox
2008-06-20 19:59 ` [PATCH 08/70] gs: " Alan Cox
2008-06-20 19:59 ` [PATCH 09/70] riscom8: " Alan Cox
2008-06-20 19:59 ` [PATCH 10/70] riscom8: remove bogus checks Alan Cox
2008-06-20 19:59 ` [PATCH 11/70] isicom: use tty_port Alan Cox
2008-06-20 19:59 ` [PATCH 12/70] istallion: " Alan Cox
2008-06-20 19:59 ` [PATCH 13/70] moxa: " Alan Cox
2008-06-20 19:59 ` [PATCH 14/70] mxser: " Alan Cox
2008-06-20 20:00 ` [PATCH 15/70] rocket: " Alan Cox
2008-06-20 20:00 ` [PATCH 16/70] serial: " Alan Cox
2008-06-20 20:00 ` [PATCH 17/70] stallion: " Alan Cox
2008-06-20 20:00 ` [PATCH 18/70] synclink: " Alan Cox
2008-06-20 20:00 ` [PATCH 19/70] tty: Clean up tiocmset Alan Cox
2008-06-20 20:00 ` [PATCH 20/70] cyclades: use tty_port Alan Cox
2008-06-20 20:00 ` [PATCH 21/70] termios: Termios defines for other platforms Alan Cox
2008-06-20 20:00 ` [PATCH 22/70] tty: add more tty_port fields Alan Cox
2008-06-20 20:01 ` [PATCH 24/70] whiteheat: coding style Alan Cox
2008-06-20 20:01 ` [PATCH 25/70] whiteheat: fix bugs found in the tidy and audit Alan Cox
2008-06-20 20:01 ` [PATCH 26/70] belkin_sa: clean up code Alan Cox
2008-06-20 20:01 ` [PATCH 27/70] usb-serial-bus: tidy coding style Alan Cox
2008-06-20 20:01 ` [PATCH 28/70] tty-usb-console: tidy the USB console code Alan Cox
2008-06-20 20:01 ` [PATCH 29/70] tty-usb-console: Fix termios Alan Cox
2008-06-20 20:02 ` [PATCH 30/70] cp2101: coding style Alan Cox
2008-06-20 20:02 ` [PATCH 31/70] cyberjack: Coding style Alan Cox
2008-06-20 20:02 ` [PATCH 32/70] cypress_m8: coding style Alan Cox
2008-06-20 20:02 ` [PATCH 33/70] usb-cypress: There is no 0 case to go with CS5/6/7/8 so remove the test Alan Cox
2008-06-20 20:02 ` [PATCH 34/70] digi_acceleport: coding style Alan Cox
2008-06-20 20:02 ` [PATCH 35/70] empeg: Coding style Alan Cox
2008-06-20 20:02 ` [PATCH 36/70] ftdi_sio: " Alan Cox
2008-06-20 20:02 ` [PATCH 37/70] funsoft: Switch to linux/uaccess Alan Cox
2008-06-20 20:03 ` [PATCH 38/70] garmin_gps: Coding style Alan Cox
2008-06-20 20:03 ` [PATCH 39/70] tty-usb-generic: Code cleanup Alan Cox
2008-06-20 20:03 ` [PATCH 40/70] tty-usb-hp4x: Fix overlong line Alan Cox
2008-06-20 20:03 ` [PATCH 41/70] tty-usb-visor: Coding style Alan Cox
2008-06-20 20:03 ` [PATCH 42/70] tty-usb-io_edgeport: " Alan Cox
2008-06-20 20:03 ` [PATCH 43/70] io_edgeport: Fix various bogus returns to the tty layer Alan Cox
2008-06-20 20:03 ` [PATCH 44/70] usb-serial: Coding style Alan Cox
2008-06-20 20:04 ` [PATCH 45/70] io_ti: Minor coding style Alan Cox
2008-06-20 20:04 ` [PATCH 46/70] ipaq: Coding style Alan Cox
2008-06-20 20:04 ` [PATCH 47/70] tty-usb-ipw: " Alan Cox
2008-06-20 20:04 ` [PATCH 48/70] tty-usb-ir-usb: Clean up to coding style Alan Cox
2008-06-20 20:04 ` [PATCH 49/70] tty-usb-iuu-phoenix: " Alan Cox
2008-06-20 20:04 ` [PATCH 50/70] tty-usb-keyspan: Coding style Alan Cox
2008-06-20 20:04 ` [PATCH 51/70] keyspan: Use string flip functions when possible Alan Cox
2008-06-20 20:04 ` [PATCH 52/70] tty-usb-keyspan-pda: Coding style Alan Cox
2008-06-20 20:05 ` [PATCH 53/70] tty-usb-kl5kusb105: " Alan Cox
2008-06-20 20:05 ` [PATCH 54/70] keyspan_pda: Use string flip functions Alan Cox
2008-06-20 20:05 ` [PATCH 55/70] tty-usb-kobil-sct: Coding style Alan Cox
2008-06-20 20:05 ` [PATCH 56/70] kobil_sct: Fix ioctls Alan Cox
2008-06-20 20:05 ` [PATCH 57/70] tty-usb-mct-u232: Coding style Alan Cox
2008-06-20 20:05 ` [PATCH 58/70] mct_u232: Use flip buffer functions Alan Cox
2008-06-20 20:06 ` [PATCH 59/70] tty-usb-pl2303: Coding style Alan Cox
2008-06-20 20:06 ` [PATCH 60/70] tty-usb-sierra: Coding style - minor Alan Cox
2008-06-20 20:06 ` [PATCH 61/70] tty-usb-spcp8x5: Minor coding style Alan Cox
2008-06-20 20:06 ` [PATCH 62/70] tty-usb-ti-usb: Coding style Alan Cox
2008-06-20 20:06 ` [PATCH 63/70] tty-usb-safe-serial: " Alan Cox
2008-06-20 20:06 ` Alan Cox [this message]
2008-06-20 20:06 ` [PATCH 65/70] tty-usb-option: " Alan Cox
2008-06-20 20:06 ` [PATCH 66/70] tty-usb-omninet: " Alan Cox
2008-06-20 20:07 ` [PATCH 67/70] omninet: Use string flip functions Alan Cox
2008-06-20 20:07 ` [PATCH 68/70] mos7840: remove loads of bogus assignments to status Alan Cox
2008-06-20 20:07 ` [PATCH 69/70] whiteheat: remove unused variable Alan Cox
2008-06-20 20:07 ` [PATCH 70/70] tty-usb-mos7720: Coding style Alan Cox
2008-06-20 23:39 ` [PATCH 00/70] tty updates proposed for 2.6.27 Johannes Weiner
2008-06-21  9:09 ` Greg KH
2008-06-21 10:17   ` (Resend of 23/70 plus reply [PATCH 00/70] tty updates proposed for 2.6.27) Alan Cox
2008-06-21 11:19     ` Adrian Bunk
2008-06-22 17:07       ` Alan Cox
2008-06-22 18:39         ` Greg KH
2008-06-21 13:23   ` [PATCH 00/70] tty updates proposed for 2.6.27 Marcel Holtmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080620200640.1479.93783.stgit@localhost.localdomain \
    --to=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.