aboutsummaryrefslogtreecommitdiffstats
path: root/usb
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2006-05-15 19:56:19 -0700
committerGreg Kroah-Hartman <gregkh@suse.de>2006-05-15 19:56:19 -0700
commitf92a186176e94c5c9f613d659fc834be6dca1961 (patch)
treef0b9c23e58ddcfbb0bc631468dd5ff1c35936f53 /usb
parentc94aa05c67ae62e0478c200f8e1cf13227ea0ac5 (diff)
downloadpatches-f92a186176e94c5c9f613d659fc834be6dca1961.tar.gz
more coding style cleanups to mos7720
Diffstat (limited to 'usb')
-rw-r--r--usb/usb-serial-mos7720.patch641
1 files changed, 240 insertions, 401 deletions
diff --git a/usb/usb-serial-mos7720.patch b/usb/usb-serial-mos7720.patch
index a4a116e16324c..92b6e9fafde30 100644
--- a/usb/usb-serial-mos7720.patch
+++ b/usb/usb-serial-mos7720.patch
@@ -14,8 +14,8 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/usb/serial/Kconfig | 10
drivers/usb/serial/Makefile | 1
- drivers/usb/serial/mos7720.c | 2121 +++++++++++++++++++++++++++++++++++++++++++
- 3 files changed, 2132 insertions(+)
+ drivers/usb/serial/mos7720.c | 1960 +++++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 1971 insertions(+)
--- gregkh-2.6.orig/drivers/usb/serial/Kconfig
+++ gregkh-2.6/drivers/usb/serial/Kconfig
@@ -48,7 +48,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
obj-$(CONFIG_USB_SERIAL_OPTION) += option.o
--- /dev/null
+++ gregkh-2.6/drivers/usb/serial/mos7720.c
-@@ -0,0 +1,2121 @@
+@@ -0,0 +1,1960 @@
+/*************************************************************************
+ *** Moschip Semiconductor Tech. Ltd.
+ *** --------------------------------------------------------------------
@@ -158,7 +158,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+MODULE_DEVICE_TABLE (usb, moschip_port_id_table);
+
+/* function prototypes for the usbserial callbacks */
-+static int mos7720_chars_in_buffer (struct usb_serial_port *port);
++static int mos7720_chars_in_buffer(struct usb_serial_port *port);
+
+
+/* function prototypes for all of our local functions */
@@ -170,52 +170,12 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+static void block_until_tx_empty(struct moschip_port *mos7720_port);
+
+
-+
-+/************************************************************************/
-+/************************************************************************/
-+/* I N T E R F A C E F U N C T I O N S */
-+/* I N T E R F A C E F U N C T I O N S */
-+/************************************************************************/
-+/************************************************************************/
-+
-+static inline void set_serial_private(struct usb_serial *serial, struct moschip_serial *data)
-+{
-+ usb_set_serial_data(serial, (void *)data );
-+}
-+
-+static inline struct moschip_serial * get_serial_private(struct usb_serial *serial)
-+{
-+ return (struct moschip_serial*) usb_get_serial_data(serial);
-+}
-+
-+static inline void set_port_private(struct usb_serial_port *port, struct moschip_port *data)
-+{
-+ usb_set_serial_port_data(port, (void*)data );
-+}
-+
-+static inline struct moschip_port * get_port_private(struct usb_serial_port *port)
-+{
-+ return (struct moschip_port*) usb_get_serial_port_data(port);
-+}
-+
-+
-+/************************************************************************/
-+/************************************************************************/
-+/* U S B C A L L B A C K F U N C T I O N S */
-+/* U S B C A L L B A C K F U N C T I O N S */
-+/************************************************************************/
-+/************************************************************************/
-+
-+/*****************************************************************************
++/*
+ * mos7720_interrupt_callback
+ * this is the callback function for when we have received data on the
+ * interrupt endpoint.
-+ * Input : 1 Input
-+ * pointer to the URB packet,
-+ *
-+ *****************************************************************************/
-+
-+static void mos7720_interrupt_callback (struct urb *urb,struct pt_regs *regs)
++ */
++static void mos7720_interrupt_callback(struct urb *urb,struct pt_regs *regs)
+{
+ int result;
+ int length ;
@@ -231,34 +191,30 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+ return;
+ }
+
-+
-+ switch (urb->status)
-+ {
-+ case 0:
-+ /* success */
-+ break;
-+ case -ECONNRESET:
-+ case -ENOENT:
-+ case -ESHUTDOWN:
-+ /* this urb is terminated, clean up */
-+ dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
-+ return;
-+ default:
-+ dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status);
-+ goto exit;
++ switch (urb->status) {
++ case 0:
++ /* success */
++ break;
++ case -ECONNRESET:
++ case -ENOENT:
++ case -ESHUTDOWN:
++ /* this urb is terminated, clean up */
++ dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
++ return;
++ default:
++ dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status);
++ goto exit;
+ }
+
-+
+ length = urb->actual_length;
+ data = urb->transfer_buffer;
+
+ mos7720_port= (struct moschip_port*)urb->context;
+
-+ if(!mos7720_port)
-+ {
-+ DPRINTK("%s","NULL mos7720_serial pointer \n");
-+ return ;
-+ }
++ if (!mos7720_port) {
++ DPRINTK("%s","NULL mos7720_serial pointer \n");
++ return ;
++ }
+
+ /* Moschip get 4 bytes
+ * Byte 1 IIR Port 1 (port.number is 0)
@@ -266,66 +222,61 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+ * Byte 3 --------------
+ * Byte 4 FIFO status for both */
+
-+ if(length && length>4)
-+ {
-+ DPRINTK("%s \n","Wrong data !!!");
++ if (length && length > 4) {
++ dbg("Wrong data !!!");
+ return;
+ }
+
-+ status=*data;
++ status = *data;
+
-+ sp1=(status & 0xff000000)>>24;
-+ sp2=(status & 0x00ff0000)>>16;
-+ st =status & 0x000000ff;
++ sp1 = (status & 0xff000000)>>24;
++ sp2 = (status & 0x00ff0000)>>16;
++ st = status & 0x000000ff;
+
-+ if((sp1 & 0x01) || (sp2 & 0x01))
-+ DPRINTK("No Interrupt !!!");
-+ /* No Interrupt Pending in both the ports */
-+ else
-+ {
-+ switch(sp1 & 0x0f)
-+ {
-+ case SERIAL_IIR_RLS: DPRINTK("Serial Port 1: Receiver status error or address bit detected in 9-bit mode\n");
-+ break;
-+ case SERIAL_IIR_CTI: DPRINTK("Serial Port 1: Receiver time out\n");
-+ break;
-+ case SERIAL_IIR_MS: DPRINTK("Serial Port 1: Modem status change\n");
-+ break;
++ if ((sp1 & 0x01) || (sp2 & 0x01)) {
++ /* No Interrupt Pending in both the ports */
++ dbg("No Interrupt !!!");
++ } else {
++ switch (sp1 & 0x0f) {
++ case SERIAL_IIR_RLS:
++ dbg("Serial Port 1: Receiver status error or address bit detected in 9-bit mode\n");
++ break;
++ case SERIAL_IIR_CTI:
++ dbg("Serial Port 1: Receiver time out");
++ break;
++ case SERIAL_IIR_MS:
++ dbg("Serial Port 1: Modem status change");
++ break;
+ }
+
-+ switch(sp2 & 0x0f)
-+ {
-+ case SERIAL_IIR_RLS: DPRINTK("Serial Port 2: Receiver status error or address bit detected in 9-bit mode\n");
-+ break;
-+ case SERIAL_IIR_CTI: DPRINTK("Serial Port 2: Receiver time out\n");
-+ break;
-+ case SERIAL_IIR_MS: DPRINTK("Serial Port 2: Modem status change\n");
-+ break;
-+ }
++ switch (sp2 & 0x0f) {
++ case SERIAL_IIR_RLS:
++ dbg("Serial Port 2: Receiver status error or address bit detected in 9-bit mode");
++ break;
++ case SERIAL_IIR_CTI:
++ dbg("Serial Port 2: Receiver time out");
++ break;
++ case SERIAL_IIR_MS:
++ dbg("Serial Port 2: Modem status change");
++ break;
++ }
+ }
+
+exit:
-+
+ result = usb_submit_urb (urb, GFP_ATOMIC);
+ if (result)
-+ {
-+ dev_err(&urb->dev->dev, "%s - Error %d submitting control urb\n", __FUNCTION__, result);
-+ }
-+
++ dev_err(&urb->dev->dev,
++ "%s - Error %d submitting control urb\n",
++ __FUNCTION__, result);
+ return;
-+
+}
+
-+/*****************************************************************************
++/*
+ * mos7720_bulk_in_callback
+ * this is the callback function for when we have received data on the
+ * bulk in endpoint.
-+ * Input : 1 Input
-+ * pointer to the URB packet,
-+ *
-+ *****************************************************************************/
-+
-+static void mos7720_bulk_in_callback (struct urb *urb, struct pt_regs *regs)
++ */
++static void mos7720_bulk_in_callback(struct urb *urb, struct pt_regs *regs)
+{
+ int status;
+ unsigned char *data ;
@@ -336,14 +287,13 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+ struct tty_struct *tty;
+
+ if (urb->status) {
-+ DPRINTK("nonzero read bulk status received: %d",urb->status);
++ dbg("nonzero read bulk status received: %d",urb->status);
+ return;
+ }
+
+ mos7720_port = urb->context;
-+ if(!mos7720_port)
-+ {
-+ DPRINTK("%s","NULL mos7720_port pointer \n");
++ if (!mos7720_port) {
++ dbg("%s","NULL mos7720_port pointer \n");
+ return ;
+ }
+
@@ -351,12 +301,10 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+ serial = port->serial;
+
-+ DPRINTK("%s\n","Entering... \n");
++ dbg("Entering...");
+
+ data = urb->transfer_buffer;
-+ mos7720_serial = get_serial_private(serial);
-+
-+ DPRINTK("%s","Entering ........... \n");
++ mos7720_serial = usb_get_serial_data(serial);
+
+ tty = port->tty;
+ if (tty && urb->actual_length) {
@@ -365,70 +313,56 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+ tty_flip_buffer_push(tty);
+ }
+
-+ if(!port->read_urb)
-+ {
-+ DPRINTK("%s","URB KILLED !!!\n");
++ if (!port->read_urb) {
++ dbg("URB KILLED !!!");
+ return;
+ }
+
-+ if(port->read_urb->status!=-EINPROGRESS)
-+ {
++ if (port->read_urb->status != -EINPROGRESS) {
+ port->read_urb->dev = serial->dev;
+
+ status = usb_submit_urb(port->read_urb, GFP_ATOMIC);
-+
+ if (status)
-+ {
-+ DPRINTK(" usb_submit_urb(read bulk) failed, status = %d", status);
-+ }
++ dbg("usb_submit_urb(read bulk) failed, status = %d",
++ status);
+ }
+}
+
-+/*****************************************************************************
++/*
+ * mos7720_bulk_out_data_callback
+ * this is the callback function for when we have finished sending serial data
+ * on the bulk out endpoint.
-+ * Input : 1 Input
-+ * pointer to the URB packet,
-+ *
-+ *****************************************************************************/
-+
-+static void mos7720_bulk_out_data_callback (struct urb *urb, struct pt_regs *regs)
++ */
++static void mos7720_bulk_out_data_callback(struct urb *urb, struct pt_regs *regs)
+{
-+ struct moschip_port *mos7720_port ;
++ struct moschip_port *mos7720_port;
+ struct tty_struct *tty;
+
-+ if(!urb)
-+ {
-+ DPRINTK("%s","Invalid Pointer !!!!:\n");
++ if (!urb) {
++ dbg("Invalid Pointer !!!!");
+ return;
+ }
+
-+ if (urb->status)
-+ {
-+ DPRINTK("nonzero write bulk status received:%d\n", urb->status);
++ if (urb->status) {
++ dbg("nonzero write bulk status received:%d", urb->status);
+ return;
+ }
+
+ mos7720_port = (struct moschip_port *)urb->context;
-+ if(!mos7720_port)
-+ {
-+ DPRINTK("%s","NULL mos7720_port pointer \n");
++ if(!mos7720_port) {
++ dbg("NULL mos7720_port pointer");
+ return ;
+ }
+
-+ DPRINTK("%s \n","Entering .........");
++ dbg("Entering .........");
+
+ tty = mos7720_port->port->tty;
+
-+ if (tty && mos7720_port->open)
-+ {
++ if (tty && mos7720_port->open) {
+ /* let the tty driver wakeup if it has a special *
-+ * write_wakeup function */
-+
-+ if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && tty->ldisc.write_wakeup) {
++ * write_wakeup function */
++ if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && tty->ldisc.write_wakeup)
+ (tty->ldisc.write_wakeup)(tty);
-+ }
+
+ /* tell the tty driver that something has changed */
+ wake_up_interruptible(&tty->write_wait);
@@ -437,11 +371,10 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+ /* Release the Write URB */
+ mos7720_port->write_in_progress = 0;
+
-+//schedule_work(&mos7720_port->port->work);
-+
++ //schedule_work(&mos7720_port->port->work);
+}
+
-+/*****************************************************************************
++/*
+ * SendMosCmd
+ * this function will be used for sending command to device
+ * Input : 5 Input
@@ -450,10 +383,9 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+ * value
+ * register index
+ * pointer to data/buffer
-+ *****************************************************************************/
-+
-+
-+static int SendMosCmd(struct usb_serial *serial, __u8 request, __u16 value, __u16 index, void *data)
++ */
++static int SendMosCmd(struct usb_serial *serial, __u8 request, __u16 value,
++ __u16 index, void *data)
+{
+ int status;
+ unsigned int pipe;
@@ -499,79 +431,56 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+ return status;
+}
+
-+
-+/************************************************************************/
-+/************************************************************************/
-+/* D R I V E R T T Y I N T E R F A C E F U N C T I O N S */
-+/* D R I V E R T T Y I N T E R F A C E F U N C T I O N S */
-+/************************************************************************/
-+/************************************************************************/
-+
-+
-+/*****************************************************************************
-+ * Driver tty interface functions
-+ *****************************************************************************/
-+
-+/*****************************************************************************
-+ * SerialOpen
++/*
++ * mos7720_open
+ * this function is called by the tty driver when a port is opened
+ * If successful, we return 0
+ * Otherwise we return a negative error number.
-+ *****************************************************************************/
-+
-+static int mos7720_open (struct usb_serial_port *port, struct file * filp)
++ */
++static int mos7720_open(struct usb_serial_port *port, struct file * filp)
+{
-+ int response;
-+ char data;
-+ int j;
-+ struct usb_serial *serial;
-+ struct usb_serial_port *port0;
-+ struct urb *urb;
-+
-+ struct moschip_serial *mos7720_serial;
-+ struct moschip_port *mos7720_port;
++ struct usb_serial *serial;
++ struct usb_serial_port *port0;
++ struct urb *urb;
++ struct moschip_serial *mos7720_serial;
++ struct moschip_port *mos7720_port;
++ int response;
++ char data;
++ int j;
+
+ serial = port->serial;
+
-+ mos7720_port = get_port_private(port);
-+
++ mos7720_port = usb_get_serial_port_data(port);
+ if (mos7720_port == NULL)
+ return -ENODEV;
+
+ port0 = serial->port[0];
+
-+ mos7720_serial = get_serial_private(serial);
++ mos7720_serial = usb_get_serial_data(serial);
+
+ if (mos7720_serial == NULL || port0 == NULL)
-+ {
+ return -ENODEV;
-+ }
+
++ usb_clear_halt(serial->dev, port->write_urb->pipe);
++ usb_clear_halt(serial->dev, port->read_urb->pipe);
+
-+ usb_clear_halt(serial->dev, port->write_urb->pipe);
-+ usb_clear_halt(serial->dev, port->read_urb->pipe);
-+
-+ /* Initialising the write urb pool */
-+ for (j = 0; j < NUM_URBS; ++j)
-+ {
-+ urb = usb_alloc_urb(0,SLAB_ATOMIC);
-+ mos7720_port->write_urb_pool[j] = urb;
-+
-+ if (urb == NULL)
-+ {
-+ err("No more urbs???");
-+ continue;
-+ }
-+
-+ urb->transfer_buffer = NULL;
-+ urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL);
-+ if (!urb->transfer_buffer)
-+ {
-+ err("%s-out of memory for urb buffers.", __FUNCTION__);
-+ continue;
-+ }
-+ }
++ /* Initialising the write urb pool */
++ for (j = 0; j < NUM_URBS; ++j) {
++ urb = usb_alloc_urb(0,SLAB_ATOMIC);
++ mos7720_port->write_urb_pool[j] = urb;
++
++ if (urb == NULL) {
++ err("No more urbs???");
++ continue;
++ }
+
++ urb->transfer_buffer = NULL;
++ urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL);
++ if (!urb->transfer_buffer) {
++ err("%s-out of memory for urb buffers.", __FUNCTION__);
++ continue;
++ }
++ }
+
+/*****************************************************************************
+ * Initialize MCS7720 -- Write Init values to corresponding Registers
@@ -631,18 +540,18 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+ data = 0x83;
+ mos7720_port->shadowLCR = data;
-+ SendMosCmd(port->serial,MOS_WRITE,port->number - port->serial->minor,0x03, &data);
++ SendMosCmd(port->serial, MOS_WRITE, port->number - port->serial->minor, 0x03, &data);
+ data = 0x0c;
-+ SendMosCmd(port->serial,MOS_WRITE,port->number - port->serial->minor,0x00, &data);
++ SendMosCmd(port->serial, MOS_WRITE, port->number - port->serial->minor, 0x00, &data);
+ data = 0x00;
-+ SendMosCmd(port->serial,MOS_WRITE,port->number - port->serial->minor,0x01, &data);
++ SendMosCmd(port->serial, MOS_WRITE, port->number - port->serial->minor, 0x01, &data);
+ data = 0x03;
+ mos7720_port->shadowLCR = data;
-+ SendMosCmd(port->serial,MOS_WRITE,port->number - port->serial->minor,0x03, &data);
++ SendMosCmd(port->serial, MOS_WRITE, port->number - port->serial->minor, 0x03, &data);
+ data = 0x0c;
-+ SendMosCmd(port->serial,MOS_WRITE,port->number - port->serial->minor,0x01, &data);
++ SendMosCmd(port->serial, MOS_WRITE, port->number - port->serial->minor, 0x01, &data);
+ data = 0x0c;
-+ SendMosCmd(port->serial,MOS_WRITE,port->number - port->serial->minor,0x01, &data);
++ SendMosCmd(port->serial, MOS_WRITE, port->number - port->serial->minor, 0x01, &data);
+
+//Matrix
+
@@ -652,18 +561,17 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+ if (port->tty)
+ port->tty->low_latency = 1;
-+ /* see if we've set up our endpoint info yet *
++
++ /* see if we've set up our endpoint info yet *
+ * (can't set it up in mos7720_startup as the *
+ * structures were not set up at that time.) */
-+
-+
+ if (!mos7720_serial->interrupt_started) {
-+ DPRINTK("%s \n","Interrupt buffer NULL !!!");
++ dbg("Interrupt buffer NULL !!!");
+
+ /* not set up yet, so do it now */
+ mos7720_serial->interrupt_started = 1;
+
-+ DPRINTK("%s \n","To Submit URB !!!");
++ dbg("To Submit URB !!!");
+
+ /* set up our interrupt urb */
+ usb_fill_int_urb(port0->interrupt_in_urb, serial->dev,
@@ -676,10 +584,12 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+ /* start interrupt read for this mos7720 this interrupt *
+ * will continue as long as the mos7720 is connected */
-+ DPRINTK("%s \n","Submit URB over !!!");
++ dbg("Submit URB over !!!");
+ response = usb_submit_urb(port0->interrupt_in_urb, GFP_KERNEL);
+ if (response)
-+ err("%s - Error %d submitting control urb", __FUNCTION__, response);
++ dev_err(&port->dev,
++ "%s - Error %d submitting control urb",
++ __FUNCTION__, response);
+ }
+
+ /* set up our bulk in urb */
@@ -690,7 +600,8 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+ mos7720_bulk_in_callback, mos7720_port);
+ response = usb_submit_urb(port->read_urb, GFP_KERNEL);
+ if (response)
-+ err("%s - Error %d submitting read urb", __FUNCTION__, response);
++ dev_err(&port->dev,
++ "%s - Error %d submitting read urb", __FUNCTION__, response);
+
+ /* initialize our wait queues */
+ init_waitqueue_head(&mos7720_port->wait_open);
@@ -702,16 +613,12 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+ memset (&(mos7720_port->icount), 0x00, sizeof(mos7720_port->icount));
+
+ /* initialize our port settings */
-+ mos7720_port->shadowMCR = UART_MCR_OUT2; /* Must set to enable ints! */
++ mos7720_port->shadowMCR = UART_MCR_OUT2; /* Must set to enable ints! */
+ mos7720_port->chaseResponsePending = 0;
+ /* send a open port command */
+ mos7720_port->open = 1;
+ mos7720_port->rxBytesAvail = 0x0;
+
-+
-+ DPRINTK("\n\nusb_serial serial:%x mos7720_port:%x\nmos7720_serial:%x usb_serial_port port:%x\n\n",(unsigned int)serial,(unsigned int)mos7720_port,(unsigned int)mos7720_serial,(unsigned int)port);
-+
-+
+ return 0;
+}
+
@@ -732,14 +639,10 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+ serial = port->serial;
+
-+ mos7720_serial = get_serial_private(serial);
-+ mos7720_port = get_port_private(port);
-+
++ mos7720_serial = usb_get_serial_data(serial);
++ mos7720_port = usb_get_serial_port_data(port);
+ if ((mos7720_serial == NULL) || (mos7720_port == NULL))
-+ {
+ return;
-+ }
-+
+
+ for (j = 0; j < NUM_URBS; ++j)
+ usb_unlink_urb (mos7720_port->write_urb_pool[j]);
@@ -807,12 +710,10 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+ serial = port->serial;
+
-+ mos7720_serial = get_serial_private(serial);
-+ mos7720_port = get_port_private(port);
-+
-+ if ((mos7720_serial == NULL) || (mos7720_port == NULL)) {
++ mos7720_serial = usb_get_serial_data(serial);
++ mos7720_port = usb_get_serial_port_data(port);
++ if ((mos7720_serial == NULL) || (mos7720_port == NULL))
+ return;
-+ }
+
+ /* flush and chase */
+ mos7720_port->chaseResponsePending = 1;
@@ -882,16 +783,13 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+}
+
+
-+/************************************************************************
-+ *
++/*
+ * block_until_tx_empty
-+ *
+ * This function will block the close until one of the following:
+ * 1. TX count are 0
+ * 2. The mos7720 has stopped
+ * 3. A timout of 3 seconds without activity has expired
-+ *
-+ ************************************************************************/
++ */
+static void block_until_tx_empty (struct moschip_port *mos7720_port)
+{
+ int timeout = HZ/10;
@@ -927,45 +825,37 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+ }
+}
+
-+/*****************************************************************************
++/*
+ * mos7720_write_room
+ * this function is called by the tty driver when it wants to know how many
+ * bytes of data we can accept for a specific port.
+ * If successful, we return the amount of room that we have for this port
+ * Otherwise we return a negative error number.
-+ *****************************************************************************/
-+
-+static int mos7720_write_room (struct usb_serial_port *port)
++ */
++static int mos7720_write_room(struct usb_serial_port *port)
+{
-+ int i;
-+ int room = 0;
-+ struct moschip_port *mos7720_port;
-+
++ struct moschip_port *mos7720_port;
++ int room = 0;
++ int i;
+
+ DPRINTK("%s \n"," mos7720_write_room:entering ...........");
+
-+ mos7720_port = get_port_private(port);
-+ if (mos7720_port == NULL)
-+ {
-+ DPRINTK("%s \n","mos7720_break:leaving ...........");
-+ return -1;
-+ }
-+
-+ for (i = 0; i < NUM_URBS; ++i)
-+ {
-+ if (mos7720_port->write_urb_pool[i]->status != -EINPROGRESS)
-+ {
-+ room += URB_TRANSFER_BUFFER_SIZE;
-+ }
-+ }
++ mos7720_port = usb_get_serial_port_data(port);
++ if (mos7720_port == NULL) {
++ DPRINTK("%s \n","mos7720_break:leaving ...........");
++ return -ENODEV;
++ }
+
-+ dbg("%s - returns %d", __FUNCTION__, room);
-+ return (room);
++ for (i = 0; i < NUM_URBS; ++i) {
++ if (mos7720_port->write_urb_pool[i]->status != -EINPROGRESS)
++ room += URB_TRANSFER_BUFFER_SIZE;
++ }
+
++ dbg("%s - returns %d", __FUNCTION__, room);
++ return room;
+}
+
-+
-+/*****************************************************************************
++/*
+ * mos7720_chars_in_buffer
+ * this function is called by the tty driver when it wants to know how many
+ * bytes of data we currently have outstanding in the port (data that has
@@ -973,44 +863,37 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+ * If successful, we return the number of bytes left to be written in the
+ * system,
+ * Otherwise we return a negative error number.
-+ *****************************************************************************/
-+
-+static int mos7720_chars_in_buffer (struct usb_serial_port *port)
++ */
++static int mos7720_chars_in_buffer(struct usb_serial_port *port)
+{
+ int i;
-+ int chars = 0;
-+ struct moschip_port *mos7720_port;
++ int chars = 0;
++ struct moschip_port *mos7720_port;
+
+ DPRINTK("%s \n"," mos7720_chars_in_buffer:entering ...........");
+
-+ mos7720_port = get_port_private(port);
-+ if (mos7720_port == NULL)
-+ {
-+ DPRINTK("%s \n","mos7720_break:leaving ...........");
-+ return -1;
-+ }
-+
-+ for (i = 0; i < NUM_URBS; ++i)
-+ {
-+ if (mos7720_port->write_urb_pool[i]->status == -EINPROGRESS)
-+ {
-+ chars += URB_TRANSFER_BUFFER_SIZE;
-+ }
-+ }
-+ dbg("%s - returns %d", __FUNCTION__, chars);
-+ return (chars);
++ mos7720_port = usb_get_serial_port_data(port);
++ if (mos7720_port == NULL) {
++ DPRINTK("%s \n","mos7720_break:leaving ...........");
++ return -ENODEV;
++ }
+
++ for (i = 0; i < NUM_URBS; ++i) {
++ if (mos7720_port->write_urb_pool[i]->status == -EINPROGRESS)
++ chars += URB_TRANSFER_BUFFER_SIZE;
++ }
++ dbg("%s - returns %d", __FUNCTION__, chars);
++ return chars;
+}
+
+
-+/*****************************************************************************
-+ * SerialWrite
++/*
++ * mos7720_write
+ * this function is called by the tty driver when data should be written to
+ * the port.
+ * If successful, we return the number of bytes written, otherwise we
-+ * return a negative error number.
-+ *****************************************************************************/
-+
++ * return a negative error number.
++ */
+static int mos7720_write(struct usb_serial_port *port, const unsigned char *data, int count)
+{
+ int status;
@@ -1029,16 +912,15 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+ serial = port->serial;
+
-+ mos7720_port = get_port_private(port);
++ mos7720_port = usb_get_serial_port_data(port);
+ if(mos7720_port==NULL)
+ {
+ DPRINTK("%s","mos7720_port is NULL\n");
+ return -1;
+ }
+
-+ mos7720_serial =get_serial_private(serial);
-+ if(mos7720_serial==NULL)
-+ {
++ mos7720_serial = usb_get_serial_data(serial);
++ if (mos7720_serial==NULL) {
+ DPRINTK("%s","mos7720_serial is NULL \n");
+ return -1;
+ }
@@ -1106,13 +988,12 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+}
+
-+/*****************************************************************************
++/*
+ * SerialThrottle
+ * this function is called by the tty driver when it wants to stop the data
+ * being read from the port.
-+ *****************************************************************************/
-+
-+static void mos7720_throttle (struct usb_serial_port *port)
++ */
++static void mos7720_throttle(struct usb_serial_port *port)
+{
+ struct moschip_port *mos7720_port;
+ struct tty_struct *tty;
@@ -1120,13 +1001,12 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+ DPRINTK("- port %d\n", port->number);
+
-+ mos7720_port = get_port_private(port);
++ mos7720_port = usb_get_serial_port_data(port);
+
+ if (mos7720_port == NULL)
+ return;
+
-+ if (!mos7720_port->open)
-+ {
++ if (!mos7720_port->open) {
+ DPRINTK("%s\n","port not opened");
+ return;
+ }
@@ -1134,48 +1014,41 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+ DPRINTK("%s","Entering .......... \n");
+
+ tty = port->tty;
-+ if (!tty)
-+ {
++ if (!tty) {
+ dbg ("%s - no tty available", __FUNCTION__);
+ return;
+ }
+
+ /* if we are implementing XON/XOFF, send the stop character */
-+ if (I_IXOFF(tty))
-+ {
++ if (I_IXOFF(tty)) {
+ unsigned char stop_char = STOP_CHAR(tty);
+ status = mos7720_write(port, &stop_char, 1);
+ if (status <= 0)
-+ {
+ return;
-+ }
+ }
+
+ /* if we are implementing RTS/CTS, toggle that line */
-+ if (tty->termios->c_cflag & CRTSCTS)
-+ {
++ if (tty->termios->c_cflag & CRTSCTS) {
+ mos7720_port->shadowMCR &= ~UART_MCR_RTS;
+ status = SendMosCmd(port->serial,MOS_WRITE,port->number - port->serial->minor, UART_MCR, &mos7720_port->shadowMCR);
+ if (status != 0)
-+ {
+ return;
-+ }
+ }
+
+ return;
+}
+
+
-+/*****************************************************************************
++/*
+ * mos7720_unthrottle
+ * this function is called by the tty driver when it wants to resume the data
-+ * being read from the port (called after SerialThrottle is called)
-+ *****************************************************************************/
-+static void mos7720_unthrottle (struct usb_serial_port *port)
++ * being read from the port.
++ */
++static void mos7720_unthrottle(struct usb_serial_port *port)
+{
+ struct tty_struct *tty;
+ int status;
-+ struct moschip_port *mos7720_port = get_port_private(port);
++ struct moschip_port *mos7720_port = usb_get_serial_port_data(port);
+
+ if (mos7720_port == NULL)
+ return;
@@ -1188,44 +1061,39 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+ DPRINTK("%s","Entering .......... \n");
+
+ tty = port->tty;
-+ if (!tty)
-+ {
-+ dbg ("%s - no tty available", __FUNCTION__);
++ if (!tty) {
++ dbg("%s - no tty available", __FUNCTION__);
+ return;
+ }
+
+ /* if we are implementing XON/XOFF, send the start character */
-+ if (I_IXOFF(tty))
-+ {
++ if (I_IXOFF(tty)) {
+ unsigned char start_char = START_CHAR(tty);
+ status = mos7720_write(port, &start_char, 1);
+ if (status <= 0)
-+ {
+ return;
-+ }
+ }
+
+ /* if we are implementing RTS/CTS, toggle that line */
-+ if (tty->termios->c_cflag & CRTSCTS)
-+ {
++ if (tty->termios->c_cflag & CRTSCTS) {
+ mos7720_port->shadowMCR |= UART_MCR_RTS;
-+ status = SendMosCmd(port->serial,MOS_WRITE,port->number - port->serial->minor, UART_MCR, &mos7720_port->shadowMCR);
++ status = SendMosCmd(port->serial, MOS_WRITE,
++ port->number - port->serial->minor,
++ UART_MCR, &mos7720_port->shadowMCR);
+ if (status != 0)
-+ {
+ return;
-+ }
+ }
+
+ return;
+}
+
-+
+/*****************************************************************************
-+ * SerialSetTermios
-+ * this function is called by the tty driver when it wants to change the termios structure
-+ *****************************************************************************/
-+
-+static void mos7720_set_termios (struct usb_serial_port *port, struct termios *old_termios)
++ * mos7720_set_termios
++ * this function is called by the tty driver when it wants to change the
++ * termios structure.
++ */
++static void mos7720_set_termios(struct usb_serial_port *port,
++ struct termios *old_termios)
+{
+ int status;
+ unsigned int cflag;
@@ -1235,42 +1103,38 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+ serial = port->serial;
+
-+ mos7720_port = get_port_private(port);
++ mos7720_port = usb_get_serial_port_data(port);
+
+ if (mos7720_port == NULL)
+ return;
+
+ tty = port->tty;
+
-+ if (!port->tty || !port->tty->termios)
-+ {
-+ dbg ("%s - no tty or termios", __FUNCTION__);
++ if (!port->tty || !port->tty->termios) {
++ dbg("%s - no tty or termios", __FUNCTION__);
+ return;
+ }
+
-+ if (!mos7720_port->open)
-+ {
++ if (!mos7720_port->open) {
+ dbg("%s - port not opened", __FUNCTION__);
+ return;
+ }
+
-+ DPRINTK("%s\n","setting termios - ASPIRE");
++ dbg("%s\n","setting termios - ASPIRE");
+
+ cflag = tty->termios->c_cflag;
+
-+ if (!cflag)
-+ {
-+ printk("%s %s\n",__FUNCTION__,"cflag is NULL");
-+ return;
++ if (!cflag) {
++ printk("%s %s\n",__FUNCTION__,"cflag is NULL");
++ return;
+ }
+
+ /* check that they really want us to change something */
-+ if (old_termios)
-+ {
++ if (old_termios) {
+ if ((cflag == old_termios->c_cflag) &&
-+ (RELEVANT_IFLAG(tty->termios->c_iflag) == RELEVANT_IFLAG(old_termios->c_iflag)))
-+ {
-+ DPRINTK("%s\n","Nothing to change");
++ (RELEVANT_IFLAG(tty->termios->c_iflag) ==
++ RELEVANT_IFLAG(old_termios->c_iflag))) {
++ dbg("Nothing to change");
+ return;
+ }
+ }
@@ -1280,37 +1144,30 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+ RELEVANT_IFLAG(tty->termios->c_iflag));
+
+ if (old_termios)
-+ {
+ dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__,
+ old_termios->c_cflag,
+ RELEVANT_IFLAG(old_termios->c_iflag));
-+ }
+
+ dbg("%s - port %d", __FUNCTION__, port->number);
+
+ /* change the port settings to the new ones specified */
-+
+ change_port_settings (mos7720_port, old_termios);
+
-+ if(!port->read_urb)
-+ {
-+ DPRINTK("%s","URB KILLED !!!!!\n");
++ if(!port->read_urb) {
++ dbg("%s","URB KILLED !!!!!\n");
+ return;
+ }
+
-+ if(port->read_urb->status!=-EINPROGRESS)
-+ {
++ if(port->read_urb->status != -EINPROGRESS) {
+ port->read_urb->dev = serial->dev;
-+ status = usb_submit_urb(port->read_urb, GFP_ATOMIC);
++ status = usb_submit_urb(port->read_urb, GFP_ATOMIC);
+ if (status)
-+ {
-+ DPRINTK(" usb_submit_urb(read bulk) failed, status = %d", status);
-+ }
++ dbg("usb_submit_urb(read bulk) failed, status = %d",
++ status);
+ }
+ return;
+}
+
-+
+/*****************************************************************************
+ * get_lsr_info - get line status register info
+ *
@@ -1321,7 +1178,6 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+ * transmit holding register is empty. This functionality
+ * allows an RS485 driver to be written in user space.
+ *****************************************************************************/
-+
+static int get_lsr_info(struct moschip_port *mos7720_port, unsigned int __user *value)
+{
+ int count;
@@ -1578,7 +1434,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+ struct async_icount cprev;
+ struct serial_icounter_struct icount;
+
-+ mos7720_port = get_port_private(port);
++ mos7720_port = usb_get_serial_port_data(port);
+ if (mos7720_port == NULL)
+ return -1;
+
@@ -2013,7 +1869,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+ return -ENOMEM;
+ }
+
-+ set_serial_private(serial,mos7720_serial);
++ usb_set_serial_data(serial, mos7720_serial);
+
+ /* we set up the pointers to the endpoints in the mos7720_open *
+ * function, as the structures aren't created yet. */
@@ -2023,7 +1879,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+ mos7720_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL);
+ if (mos7720_port == NULL) {
+ err("%s - Out of memory", __FUNCTION__);
-+ set_serial_private(serial,NULL);
++ usb_set_serial_data(serial, NULL);
+ kfree(mos7720_serial);
+ return -ENOMEM;
+ }
@@ -2034,7 +1890,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+ serial->port[i]->interrupt_in_endpointAddress = serial->port[0]->interrupt_in_endpointAddress;
+
+ mos7720_port->port = serial->port[i];
-+ set_port_private(serial->port[i],mos7720_port);
++ usb_set_serial_port_data(serial->port[i], mos7720_port);
+
+ dbg("port number is %d", serial->port[i]->number);
+ dbg("serial number is %d", serial->minor);
@@ -2053,13 +1909,6 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+ return 0;
+}
+
-+
-+
-+/****************************************************************************
-+ * mos7720_shutdown
-+ * This function is called whenever the device is removed from the usb bus.
-+ ****************************************************************************/
-+
+static void mos7720_shutdown (struct usb_serial *serial)
+{
+ int i;
@@ -2072,23 +1921,17 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+ * stop reads and writes on all ports */
+
+ for (i=0; i < serial->num_ports; ++i) {
-+ kfree(get_port_private(serial->port[i]));
-+ set_port_private(serial->port[i],NULL);
++ kfree(usb_get_serial_port_data(serial->port[i]));
++ usb_set_serial_port_data(serial->port[i], NULL);
+ }
+
+ /* free private structure allocated for serial device */
-+ kfree(get_serial_private(serial));
-+ set_serial_private(serial,NULL);
++ kfree(usb_get_serial_data(serial));
++ usb_set_serial_data(serial, NULL);
+
+ dbg("%s\n","Thank u :: ASPIRE COMMUNICATIONS");
+}
+
-+
-+/****************************************************************************
-+ * moschip7720_2port_driver
-+ * Structure defining MCS7720, usb serail device
-+ ****************************************************************************/
-+
+static struct usb_serial_driver moschip7720_2port_driver = {
+ .driver = {
+ .owner = THIS_MODULE,
@@ -2122,7 +1965,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+ .id_table = moschip_port_id_table,
+};
+
-+ int __init moschip7720_init(void)
++static int __init moschip7720_init(void)
+{
+ int retval;
+
@@ -2151,11 +1994,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+ return retval;
+}
+
-+/****************************************************************************
-+ * moschip7720_exit
-+ * Called when the driver is about to be unloaded.
-+ ****************************************************************************/
-+void __exit moschip7720_exit (void)
++static void __exit moschip7720_exit (void)
+{
+ usb_deregister(&usb_driver);
+ usb_serial_deregister(&moschip7720_2port_driver);