tty-usb-mos7720: 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>
This commit is contained in:
Alan Cox
2008-07-22 11:16:21 +01:00
committed by Linus Torvalds
parent 880af9db2c
commit 4da1a17dbc

View File

@@ -33,7 +33,7 @@
#include <linux/serial_reg.h> #include <linux/serial_reg.h>
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/usb/serial.h> #include <linux/usb/serial.h>
#include <asm/uaccess.h> #include <linux/uaccess.h>
/* /*
@@ -64,8 +64,7 @@
#define URB_TRANSFER_BUFFER_SIZE 32 /* URB Size */ #define URB_TRANSFER_BUFFER_SIZE 32 /* URB Size */
/* This structure holds all of the local port information */ /* This structure holds all of the local port information */
struct moschip_port struct moschip_port {
{
__u8 shadowLCR; /* last LCR value received */ __u8 shadowLCR; /* last LCR value received */
__u8 shadowMCR; /* last MCR value received */ __u8 shadowMCR; /* last MCR value received */
__u8 shadowMSR; /* last MSR value received */ __u8 shadowMSR; /* last MSR value received */
@@ -76,8 +75,7 @@ struct moschip_port
}; };
/* This structure holds all of the individual serial device information */ /* This structure holds all of the individual serial device information */
struct moschip_serial struct moschip_serial {
{
int interrupt_started; int interrupt_started;
}; };
@@ -284,17 +282,16 @@ static int send_mos_cmd(struct usb_serial *serial, __u8 request, __u16 value,
__u16 size = 0x0000; __u16 size = 0x0000;
if (value < MOS_MAX_PORT) { if (value < MOS_MAX_PORT) {
if (product == MOSCHIP_DEVICE_ID_7715) { if (product == MOSCHIP_DEVICE_ID_7715)
value = value*0x100+0x100; value = value*0x100+0x100;
} else { else
value = value*0x100+0x200; value = value*0x100+0x200;
}
} else { } else {
value = 0x0000; value = 0x0000;
if ((product == MOSCHIP_DEVICE_ID_7715) && if ((product == MOSCHIP_DEVICE_ID_7715) &&
(index != 0x08)) { (index != 0x08)) {
dbg("serial->product== MOSCHIP_DEVICE_ID_7715"); dbg("serial->product== MOSCHIP_DEVICE_ID_7715");
//index = 0x01 ; /* index = 0x01 ; */
} }
} }
@@ -421,7 +418,8 @@ static int mos7720_open(struct tty_struct *tty,
data = 0x03; data = 0x03;
send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, port_number + 1, &data); send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, port_number + 1, &data);
data = 0x00; data = 0x00;
send_mos_cmd(port->serial, MOS_WRITE, MOS_MAX_PORT, port_number + 1, &data); send_mos_cmd(port->serial, MOS_WRITE, MOS_MAX_PORT,
port_number + 1, &data);
*/ */
data = 0x00; data = 0x00;
send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, 0x08, &data); send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, 0x08, &data);
@@ -490,8 +488,8 @@ static int mos7720_open(struct tty_struct *tty,
mos7720_bulk_in_callback, mos7720_port); mos7720_bulk_in_callback, mos7720_port);
response = usb_submit_urb(port->read_urb, GFP_KERNEL); response = usb_submit_urb(port->read_urb, GFP_KERNEL);
if (response) if (response)
dev_err(&port->dev, dev_err(&port->dev, "%s - Error %d submitting read urb\n",
"%s - Error %d submitting read urb\n", __func__, response); __func__, response);
/* initialize our icount structure */ /* initialize our icount structure */
memset(&(mos7720_port->icount), 0x00, sizeof(mos7720_port->icount)); memset(&(mos7720_port->icount), 0x00, sizeof(mos7720_port->icount));
@@ -530,7 +528,8 @@ static int mos7720_chars_in_buffer(struct tty_struct *tty)
} }
for (i = 0; i < NUM_URBS; ++i) { for (i = 0; i < NUM_URBS; ++i) {
if (mos7720_port->write_urb_pool[i] && mos7720_port->write_urb_pool[i]->status == -EINPROGRESS) if (mos7720_port->write_urb_pool[i] &&
mos7720_port->write_urb_pool[i]->status == -EINPROGRESS)
chars += URB_TRANSFER_BUFFER_SIZE; chars += URB_TRANSFER_BUFFER_SIZE;
} }
dbg("%s - returns %d", __func__, chars); dbg("%s - returns %d", __func__, chars);
@@ -576,12 +575,12 @@ static void mos7720_close(struct tty_struct *tty,
* been disconnected */ * been disconnected */
if (!serial->disconnected) { if (!serial->disconnected) {
data = 0x00; data = 0x00;
send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor, send_mos_cmd(serial, MOS_WRITE,
0x04, &data); port->number - port->serial->minor, 0x04, &data);
data = 0x00; data = 0x00;
send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor, send_mos_cmd(serial, MOS_WRITE,
0x01, &data); port->number - port->serial->minor, 0x01, &data);
} }
mutex_unlock(&serial->disc_mutex); mutex_unlock(&serial->disc_mutex);
mos7720_port->open = 0; mos7720_port->open = 0;
@@ -640,7 +639,8 @@ static int mos7720_write_room(struct tty_struct *tty)
/* FIXME: Locking */ /* FIXME: Locking */
for (i = 0; i < NUM_URBS; ++i) { for (i = 0; i < NUM_URBS; ++i) {
if (mos7720_port->write_urb_pool[i] && mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) if (mos7720_port->write_urb_pool[i] &&
mos7720_port->write_urb_pool[i]->status != -EINPROGRESS)
room += URB_TRANSFER_BUFFER_SIZE; room += URB_TRANSFER_BUFFER_SIZE;
} }
@@ -675,7 +675,8 @@ static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port,
urb = NULL; urb = NULL;
for (i = 0; i < NUM_URBS; ++i) { for (i = 0; i < NUM_URBS; ++i) {
if (mos7720_port->write_urb_pool[i] && mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) { if (mos7720_port->write_urb_pool[i] &&
mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) {
urb = mos7720_port->write_urb_pool[i]; urb = mos7720_port->write_urb_pool[i];
dbg("URB:%d", i); dbg("URB:%d", i);
break; break;
@@ -873,8 +874,7 @@ static int set_higher_rates(struct moschip_port *mos7720_port,
} }
/* baud rate information */ /* baud rate information */
struct divisor_table_entry struct divisor_table_entry {
{
__u32 baudrate; __u32 baudrate;
__u16 divisor; __u16 divisor;
}; };
@@ -1095,13 +1095,15 @@ static void change_port_settings(struct tty_struct *tty,
#define LCR_PAR_MASK 0x38 /* Mask for parity field */ #define LCR_PAR_MASK 0x38 /* Mask for parity field */
/* Update the LCR with the correct value */ /* Update the LCR with the correct value */
mos7720_port->shadowLCR &= ~(LCR_BITS_MASK | LCR_STOP_MASK | LCR_PAR_MASK); mos7720_port->shadowLCR &=
~(LCR_BITS_MASK | LCR_STOP_MASK | LCR_PAR_MASK);
mos7720_port->shadowLCR |= (lData | lParity | lStop); mos7720_port->shadowLCR |= (lData | lParity | lStop);
/* Disable Interrupts */ /* Disable Interrupts */
data = 0x00; data = 0x00;
send_mos_cmd(serial,MOS_WRITE,port->number - port->serial->minor, UART_IER, &data); send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor,
UART_IER, &data);
data = 0x00; data = 0x00;
send_mos_cmd(serial, MOS_WRITE, port_number, UART_FCR, &data); send_mos_cmd(serial, MOS_WRITE, port_number, UART_FCR, &data);
@@ -1126,7 +1128,6 @@ static void change_port_settings(struct tty_struct *tty,
if (cflag & CRTSCTS) { if (cflag & CRTSCTS) {
mos7720_port->shadowMCR |= (UART_MCR_XONANY); mos7720_port->shadowMCR |= (UART_MCR_XONANY);
/* To set hardware flow control to the specified * /* To set hardware flow control to the specified *
* serial port, in SP1/2_CONTROL_REG */ * serial port, in SP1/2_CONTROL_REG */
if (port->number) { if (port->number) {
@@ -1249,8 +1250,8 @@ static void mos7720_set_termios(struct tty_struct *tty,
* transmit holding register is empty. This functionality * transmit holding register is empty. This functionality
* allows an RS485 driver to be written in user space. * allows an RS485 driver to be written in user space.
*/ */
static int get_lsr_info(struct tty_struct *tty, struct moschip_port *mos7720_port, static int get_lsr_info(struct tty_struct *tty,
unsigned int __user *value) struct moschip_port *mos7720_port, unsigned int __user *value)
{ {
int count; int count;
unsigned int result = 0; unsigned int result = 0;
@@ -1417,15 +1418,16 @@ static int mos7720_ioctl(struct tty_struct *tty, struct file *file,
case TIOCSERGETLSR: case TIOCSERGETLSR:
dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); dbg("%s (%d) TIOCSERGETLSR", __func__, port->number);
return get_lsr_info(tty, mos7720_port, (unsigned int __user *)arg); return get_lsr_info(tty, mos7720_port,
(unsigned int __user *)arg);
return 0; return 0;
/* FIXME: These should be using the mode methods */ /* FIXME: These should be using the mode methods */
case TIOCMBIS: case TIOCMBIS:
case TIOCMBIC: case TIOCMBIC:
case TIOCMSET: case TIOCMSET:
dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __func__, dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET",
port->number); __func__, port->number);
return set_modem_info(mos7720_port, cmd, return set_modem_info(mos7720_port, cmd,
(unsigned int __user *)arg); (unsigned int __user *)arg);
@@ -1526,7 +1528,8 @@ static int mos7720_startup(struct usb_serial *serial)
/* Initialize all port interrupt end point to port 0 int /* Initialize all port interrupt end point to port 0 int
* endpoint. Our device has only one interrupt endpoint * endpoint. Our device has only one interrupt endpoint
* comman to all ports */ * comman to all ports */
serial->port[i]->interrupt_in_endpointAddress = serial->port[0]->interrupt_in_endpointAddress; serial->port[i]->interrupt_in_endpointAddress =
serial->port[0]->interrupt_in_endpointAddress;
mos7720_port->port = serial->port[i]; mos7720_port->port = serial->port[i];
usb_set_serial_port_data(serial->port[i], mos7720_port); usb_set_serial_port_data(serial->port[i], mos7720_port);
@@ -1540,10 +1543,12 @@ static int mos7720_startup(struct usb_serial *serial)
usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
(__u8)0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5*HZ); (__u8)0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5*HZ);
send_mos_cmd(serial,MOS_READ,0x00, UART_LSR, &data); // LSR For Port 1 /* LSR For Port 1 */
send_mos_cmd(serial, MOS_READ, 0x00, UART_LSR, &data);
dbg("LSR:%x", data); dbg("LSR:%x", data);
send_mos_cmd(serial,MOS_READ,0x01, UART_LSR, &data); // LSR For Port 2 /* LSR For Port 2 */
send_mos_cmd(serial, MOS_READ, 0x01, UART_LSR, &data);
dbg("LSR:%x", data); dbg("LSR:%x", data);
return 0; return 0;