提交 b9db07fb 编写于 作者: L Lonnie Mendez 提交者: Greg Kroah-Hartman

[PATCH] USB: whitespace fixes for cypress_m8 driver

Reading this driver I noticed some trailing whitespaces and tabs so I
removed them with some 80th column fitting and a few more similar
things.

From: Carlo Perassi <carlo@linux.it>
Signed-off-by: NLonnie Mendez <dignome@gmail.com>
Signed-off-by: NCarlo Perassi <carlo@linux.it>
Signed-off-by: NDomen Puncer <domen@coderock.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 4e149184
......@@ -453,7 +453,7 @@ static int generic_startup (struct usb_serial *serial)
priv->cbr_mask = B300;
usb_set_serial_port_data(serial->port[0], priv);
return (0);
return 0;
}
......@@ -464,14 +464,15 @@ static int cypress_earthmate_startup (struct usb_serial *serial)
dbg("%s", __FUNCTION__);
if (generic_startup(serial)) {
dbg("%s - Failed setting up port %d", __FUNCTION__, serial->port[0]->number);
dbg("%s - Failed setting up port %d", __FUNCTION__,
serial->port[0]->number);
return 1;
}
priv = usb_get_serial_port_data(serial->port[0]);
priv->chiptype = CT_EARTHMATE;
return (0);
return 0;
} /* cypress_earthmate_startup */
......@@ -482,14 +483,15 @@ static int cypress_hidcom_startup (struct usb_serial *serial)
dbg("%s", __FUNCTION__);
if (generic_startup(serial)) {
dbg("%s - Failed setting up port %d", __FUNCTION__, serial->port[0]->number);
dbg("%s - Failed setting up port %d", __FUNCTION__,
serial->port[0]->number);
return 1;
}
priv = usb_get_serial_port_data(serial->port[0]);
priv->chiptype = CT_CYPHIDCOM;
return (0);
return 0;
} /* cypress_hidcom_startup */
......@@ -909,7 +911,8 @@ static int cypress_ioctl (struct usb_serial_port *port, struct file * file, unsi
} /* cypress_ioctl */
static void cypress_set_termios (struct usb_serial_port *port, struct termios *old_termios)
static void cypress_set_termios (struct usb_serial_port *port,
struct termios *old_termios)
{
struct cypress_private *priv = usb_get_serial_port_data(port);
struct tty_struct *tty;
......@@ -931,10 +934,12 @@ static void cypress_set_termios (struct usb_serial_port *port, struct termios *o
if (!priv->termios_initialized) {
if (priv->chiptype == CT_EARTHMATE) {
*(tty->termios) = tty_std_termios;
tty->termios->c_cflag = B4800 | CS8 | CREAD | HUPCL | CLOCAL;
tty->termios->c_cflag = B4800 | CS8 | CREAD | HUPCL |
CLOCAL;
} else if (priv->chiptype == CT_CYPHIDCOM) {
*(tty->termios) = tty_std_termios;
tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL |
CLOCAL;
}
priv->termios_initialized = 1;
}
......@@ -946,9 +951,12 @@ static void cypress_set_termios (struct usb_serial_port *port, struct termios *o
/* check if there are new settings */
if (old_termios) {
if ((cflag != old_termios->c_cflag) ||
(RELEVANT_IFLAG(iflag) != RELEVANT_IFLAG(old_termios->c_iflag))) {
dbg("%s - attempting to set new termios settings", __FUNCTION__);
/* should make a copy of this in case something goes wrong in the function, we can restore it */
(RELEVANT_IFLAG(iflag) !=
RELEVANT_IFLAG(old_termios->c_iflag))) {
dbg("%s - attempting to set new termios settings",
__FUNCTION__);
/* should make a copy of this in case something goes
* wrong in the function, we can restore it */
spin_lock_irqsave(&priv->lock, flags);
priv->tmp_termios = *(tty->termios);
spin_unlock_irqrestore(&priv->lock, flags);
......@@ -962,21 +970,34 @@ static void cypress_set_termios (struct usb_serial_port *port, struct termios *o
/* set number of data bits, parity, stop bits */
/* when parity is disabled the parity type bit is ignored */
stop_bits = cflag & CSTOPB ? 1 : 0; /* 1 means 2 stop bits, 0 means 1 stop bit */
/* 1 means 2 stop bits, 0 means 1 stop bit */
stop_bits = cflag & CSTOPB ? 1 : 0;
if (cflag & PARENB) {
parity_enable = 1;
parity_type = cflag & PARODD ? 1 : 0; /* 1 means odd parity, 0 means even parity */
/* 1 means odd parity, 0 means even parity */
parity_type = cflag & PARODD ? 1 : 0;
} else
parity_enable = parity_type = 0;
if (cflag & CSIZE) {
switch (cflag & CSIZE) {
case CS5: data_bits = 0; break;
case CS6: data_bits = 1; break;
case CS7: data_bits = 2; break;
case CS8: data_bits = 3; break;
default: err("%s - CSIZE was set, but not CS5-CS8", __FUNCTION__); data_bits = 3;
case CS5:
data_bits = 0;
break;
case CS6:
data_bits = 1;
break;
case CS7:
data_bits = 2;
break;
case CS8:
data_bits = 3;
break;
default:
err("%s - CSIZE was set, but not CS5-CS8",
__FUNCTION__);
data_bits = 3;
}
} else
data_bits = 3;
......@@ -991,63 +1012,85 @@ static void cypress_set_termios (struct usb_serial_port *port, struct termios *o
} else {
baud_mask = (cflag & CBAUD);
switch(baud_mask) {
case B300: dbg("%s - setting baud 300bps", __FUNCTION__); break;
case B600: dbg("%s - setting baud 600bps", __FUNCTION__); break;
case B1200: dbg("%s - setting baud 1200bps", __FUNCTION__); break;
case B2400: dbg("%s - setting baud 2400bps", __FUNCTION__); break;
case B4800: dbg("%s - setting baud 4800bps", __FUNCTION__); break;
case B9600: dbg("%s - setting baud 9600bps", __FUNCTION__); break;
case B19200: dbg("%s - setting baud 19200bps", __FUNCTION__); break;
case B38400: dbg("%s - setting baud 38400bps", __FUNCTION__); break;
case B57600: dbg("%s - setting baud 57600bps", __FUNCTION__); break;
case B115200: dbg("%s - setting baud 115200bps", __FUNCTION__); break;
default: dbg("%s - unknown masked baud rate", __FUNCTION__);
case B300:
dbg("%s - setting baud 300bps", __FUNCTION__);
break;
case B600:
dbg("%s - setting baud 600bps", __FUNCTION__);
break;
case B1200:
dbg("%s - setting baud 1200bps", __FUNCTION__);
break;
case B2400:
dbg("%s - setting baud 2400bps", __FUNCTION__);
break;
case B4800:
dbg("%s - setting baud 4800bps", __FUNCTION__);
break;
case B9600:
dbg("%s - setting baud 9600bps", __FUNCTION__);
break;
case B19200:
dbg("%s - setting baud 19200bps", __FUNCTION__);
break;
case B38400:
dbg("%s - setting baud 38400bps", __FUNCTION__);
break;
case B57600:
dbg("%s - setting baud 57600bps", __FUNCTION__);
break;
case B115200:
dbg("%s - setting baud 115200bps", __FUNCTION__);
break;
default:
dbg("%s - unknown masked baud rate", __FUNCTION__);
}
priv->line_control = (CONTROL_DTR | CONTROL_RTS);
}
spin_unlock_irqrestore(&priv->lock, flags);
dbg("%s - sending %d stop_bits, %d parity_enable, %d parity_type, %d data_bits (+5)", __FUNCTION__,
stop_bits, parity_enable, parity_type, data_bits);
dbg("%s - sending %d stop_bits, %d parity_enable, %d parity_type, "
"%d data_bits (+5)", __FUNCTION__, stop_bits,
parity_enable, parity_type, data_bits);
cypress_serial_control(port, baud_mask, data_bits, stop_bits, parity_enable,
parity_type, 0, CYPRESS_SET_CONFIG);
cypress_serial_control(port, baud_mask, data_bits, stop_bits,
parity_enable, parity_type, 0, CYPRESS_SET_CONFIG);
/* we perform a CYPRESS_GET_CONFIG so that the current settings are filled into the private structure
* this should confirm that all is working if it returns what we just set */
/* we perform a CYPRESS_GET_CONFIG so that the current settings are
* filled into the private structure this should confirm that all is
* working if it returns what we just set */
cypress_serial_control(port, 0, 0, 0, 0, 0, 0, CYPRESS_GET_CONFIG);
/* Here we can define custom tty settings for devices
*
* the main tty termios flag base comes from empeg.c
*/
/* Here we can define custom tty settings for devices; the main tty
* termios flag base comes from empeg.c */
spin_lock_irqsave(&priv->lock, flags);
if ( (priv->chiptype == CT_EARTHMATE) && (priv->baud_rate == 4800) ) {
dbg("Using custom termios settings for a baud rate of 4800bps.");
dbg("Using custom termios settings for a baud rate of "
"4800bps.");
/* define custom termios settings for NMEA protocol */
tty->termios->c_iflag /* input modes - */
&= ~(IGNBRK /* disable ignore break */
| BRKINT /* disable break causes interrupt */
| PARMRK /* disable mark parity errors */
| ISTRIP /* disable clear high bit of input characters */
| ISTRIP /* disable clear high bit of input char */
| INLCR /* disable translate NL to CR */
| IGNCR /* disable ignore CR */
| ICRNL /* disable translate CR to NL */
| IXON); /* disable enable XON/XOFF flow control */
tty->termios->c_oflag /* output modes */
&= ~OPOST; /* disable postprocess output characters */
&= ~OPOST; /* disable postprocess output char */
tty->termios->c_lflag /* line discipline modes */
&= ~(ECHO /* disable echo input characters */
| ECHONL /* disable echo new line */
| ICANON /* disable erase, kill, werase, and rprnt special characters */
| ISIG /* disable interrupt, quit, and suspend special characters */
| ICANON /* disable erase, kill, werase, and rprnt
special characters */
| ISIG /* disable interrupt, quit, and suspend
special characters */
| IEXTEN); /* disable non-POSIX special characters */
} /* CT_CYPHIDCOM: Application should handle this for device */
linechange = (priv->line_control != oldlines);
......@@ -1110,7 +1153,8 @@ static void cypress_unthrottle (struct usb_serial_port *port)
result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
if (result)
dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __FUNCTION__, result);
dev_err(&port->dev, "%s - failed submitting read urb, "
"error %d\n", __FUNCTION__, result);
}
}
......@@ -1131,7 +1175,8 @@ static void cypress_read_int_callback(struct urb *urb, struct pt_regs *regs)
dbg("%s - port %d", __FUNCTION__, port->number);
if (urb->status) {
dbg("%s - nonzero read status received: %d", __FUNCTION__, urb->status);
dbg("%s - nonzero read status received: %d", __FUNCTION__,
urb->status);
return;
}
......@@ -1155,51 +1200,55 @@ static void cypress_read_int_callback(struct urb *urb, struct pt_regs *regs)
case 32:
/* This is for the CY7C64013... */
priv->current_status = data[0] & 0xF8;
bytes = data[1]+2;
i=2;
bytes = data[1] + 2;
i = 2;
if (bytes > 2)
havedata = 1;
break;
case 8:
/* This is for the CY7C63743... */
priv->current_status = data[0] & 0xF8;
bytes = (data[0] & 0x07)+1;
i=1;
bytes = (data[0] & 0x07) + 1;
i = 1;
if (bytes > 1)
havedata = 1;
break;
default:
dbg("%s - wrong packet size - received %d bytes", __FUNCTION__, urb->actual_length);
dbg("%s - wrong packet size - received %d bytes",
__FUNCTION__, urb->actual_length);
spin_unlock_irqrestore(&priv->lock, flags);
goto continue_read;
}
spin_unlock_irqrestore(&priv->lock, flags);
usb_serial_debug_data (debug, &port->dev, __FUNCTION__, urb->actual_length, data);
usb_serial_debug_data (debug, &port->dev, __FUNCTION__,
urb->actual_length, data);
spin_lock_irqsave(&priv->lock, flags);
/* check to see if status has changed */
if (priv != NULL) {
if (priv->current_status != priv->prev_status) {
priv->diff_status |= priv->current_status ^ priv->prev_status;
priv->diff_status |= priv->current_status ^
priv->prev_status;
wake_up_interruptible(&priv->delta_msr_wait);
priv->prev_status = priv->current_status;
}
}
spin_unlock_irqrestore(&priv->lock, flags);
/* hangup, as defined in acm.c... this might be a bad place for it though */
if (tty && !(tty->termios->c_cflag & CLOCAL) && !(priv->current_status & UART_CD)) {
/* hangup, as defined in acm.c... this might be a bad place for it
* though */
if (tty && !(tty->termios->c_cflag & CLOCAL) &&
!(priv->current_status & UART_CD)) {
dbg("%s - calling hangup", __FUNCTION__);
tty_hangup(tty);
goto continue_read;
}
/* There is one error bit... I'm assuming it is a parity error indicator
* as the generic firmware will set this bit to 1 if a parity error occurs.
* I can not find reference to any other error events.
*
*/
/* There is one error bit... I'm assuming it is a parity error
* indicator as the generic firmware will set this bit to 1 if a
* parity error occurs.
* I can not find reference to any other error events. */
spin_lock_irqsave(&priv->lock, flags);
if (priv->current_status & CYP_ERROR) {
spin_unlock_irqrestore(&priv->lock, flags);
......@@ -1211,7 +1260,8 @@ static void cypress_read_int_callback(struct urb *urb, struct pt_regs *regs)
/* process read if there is data other than line status */
if (tty && (bytes > i)) {
for (; i < bytes ; ++i) {
dbg("pushing byte number %d - %d - %c",i,data[i],data[i]);
dbg("pushing byte number %d - %d - %c", i, data[i],
data[i]);
if(tty->flip.count >= TTY_FLIPBUF_SIZE) {
tty_flip_buffer_push(tty);
}
......@@ -1221,7 +1271,8 @@ static void cypress_read_int_callback(struct urb *urb, struct pt_regs *regs)
}
spin_lock_irqsave(&priv->lock, flags);
priv->bytes_in += bytes; /* control and status byte(s) are also counted */
/* control and status byte(s) are also counted */
priv->bytes_in += bytes;
spin_unlock_irqrestore(&priv->lock, flags);
continue_read:
......@@ -1230,14 +1281,16 @@ static void cypress_read_int_callback(struct urb *urb, struct pt_regs *regs)
if (port->open_count > 0) {
usb_fill_int_urb(port->interrupt_in_urb, port->serial->dev,
usb_rcvintpipe(port->serial->dev, port->interrupt_in_endpointAddress),
usb_rcvintpipe(port->serial->dev,
port->interrupt_in_endpointAddress),
port->interrupt_in_urb->transfer_buffer,
port->interrupt_in_urb->transfer_buffer_length,
cypress_read_int_callback, port,
interval);
cypress_read_int_callback, port, interval);
result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
if (result)
dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result);
dev_err(&urb->dev->dev, "%s - failed resubmitting "
"read urb, error %d\n", __FUNCTION__,
result);
}
return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册