usb_serial: API all change
[pandora-kernel.git] / drivers / usb / serial / omninet.c
index ee94d96..5a2d045 100644 (file)
@@ -61,12 +61,12 @@ static int debug;
 #define BT_IGNITIONPRO_ID      0x2000  /* This one seems to be a re-branded ZyXEL device */
 
 /* function prototypes */
-static int  omninet_open               (struct usb_serial_port *port, struct file *filp);
-static void omninet_close              (struct usb_serial_port *port, struct file *filp);
+static int  omninet_open               (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
+static void omninet_close              (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);
 static void omninet_read_bulk_callback (struct urb *urb);
 static void omninet_write_bulk_callback        (struct urb *urb);
-static int  omninet_write              (struct usb_serial_port *port, const unsigned char *buf, int count);
-static int  omninet_write_room         (struct usb_serial_port *port);
+static int  omninet_write              (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count);
+static int  omninet_write_room         (struct tty_struct *tty);
 static void omninet_shutdown           (struct usb_serial *serial);
 static int omninet_attach              (struct usb_serial *serial);
 
@@ -95,9 +95,6 @@ static struct usb_serial_driver zyxel_omninet_device = {
        .description =          "ZyXEL - omni.net lcd plus usb",
        .usb_driver =           &omninet_driver,
        .id_table =             id_table,
-       .num_interrupt_in =     1,
-       .num_bulk_in =          1,
-       .num_bulk_out =         2,
        .num_ports =            1,
        .attach =               omninet_attach,
        .open =                 omninet_open,
@@ -153,23 +150,24 @@ static int omninet_attach (struct usb_serial *serial)
 
        od = kmalloc( sizeof(struct omninet_data), GFP_KERNEL );
        if( !od ) {
-               err("%s- kmalloc(%Zd) failed.", __FUNCTION__, sizeof(struct omninet_data));
+               err("%s- kmalloc(%Zd) failed.", __func__, sizeof(struct omninet_data));
                return -ENOMEM;
        }
        usb_set_serial_port_data(port, od);
        return 0;
 }
 
-static int omninet_open (struct usb_serial_port *port, struct file *filp)
+static int omninet_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct usb_serial       *serial = port->serial;
        struct usb_serial_port  *wport;
        int                     result = 0;
 
-       dbg("%s - port %d", __FUNCTION__, port->number);
+       dbg("%s - port %d", __func__, port->number);
 
        wport = serial->port[1];
-       wport->tty = port->tty;
+       wport->port.tty = tty;          /* FIXME */
 
        /* Start reading from the device */
        usb_fill_bulk_urb(port->read_urb, serial->dev, 
@@ -178,15 +176,16 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp)
                      omninet_read_bulk_callback, port);
        result = usb_submit_urb(port->read_urb, GFP_KERNEL);
        if (result) {
-               err("%s - failed submitting read urb, error %d", __FUNCTION__, result);
+               err("%s - failed submitting read urb, error %d", __func__, result);
        }
 
        return result;
 }
 
-static void omninet_close (struct usb_serial_port *port, struct file * filp)
+static void omninet_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file * filp)
 {
-       dbg("%s - port %d", __FUNCTION__, port->number);
+       dbg("%s - port %d", __func__, port->number);
        usb_kill_urb(port->read_urb);
 }
 
@@ -197,18 +196,18 @@ static void omninet_close (struct usb_serial_port *port, struct file * filp)
 
 static void omninet_read_bulk_callback (struct urb *urb)
 {
-       struct usb_serial_port  *port   = (struct usb_serial_port *)urb->context;
+       struct usb_serial_port  *port   = urb->context;
        unsigned char           *data   = urb->transfer_buffer;
        struct omninet_header   *header = (struct omninet_header *) &data[0];
        int status = urb->status;
        int i;
        int result;
 
-       dbg("%s - port %d", __FUNCTION__, port->number);
+       dbg("%s - port %d", __func__, port->number);
 
        if (status) {
                dbg("%s - nonzero read bulk status received: %d",
-                   __FUNCTION__, status);
+                   __func__, status);
                return;
        }
 
@@ -224,9 +223,9 @@ static void omninet_read_bulk_callback (struct urb *urb)
 
        if (urb->actual_length && header->oh_len) {
                for (i = 0; i < header->oh_len; i++) {
-                        tty_insert_flip_char(port->tty, data[OMNINET_DATAOFFSET + i], 0);
+                        tty_insert_flip_char(port->port.tty, data[OMNINET_DATAOFFSET + i], 0);
                }
-               tty_flip_buffer_push(port->tty);
+               tty_flip_buffer_push(port->port.tty);
        }
 
        /* Continue trying to always read  */
@@ -236,12 +235,13 @@ static void omninet_read_bulk_callback (struct urb *urb)
                      omninet_read_bulk_callback, port);
        result = usb_submit_urb(urb, GFP_ATOMIC);
        if (result)
-               err("%s - failed resubmitting read urb, error %d", __FUNCTION__, result);
+               err("%s - failed resubmitting read urb, error %d", __func__, result);
 
        return;
 }
 
-static int omninet_write (struct usb_serial_port *port, const unsigned char *buf, int count)
+static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port,
+                                       const unsigned char *buf, int count)
 {
        struct usb_serial       *serial = port->serial;
        struct usb_serial_port  *wport  = serial->port[1];
@@ -251,17 +251,17 @@ static int omninet_write (struct usb_serial_port *port, const unsigned char *buf
 
        int                     result;
 
-       dbg("%s - port %d", __FUNCTION__, port->number);
+       dbg("%s - port %d", __func__, port->number);
 
        if (count == 0) {
-               dbg("%s - write request of 0 bytes", __FUNCTION__);
+               dbg("%s - write request of 0 bytes", __func__);
                return (0);
        }
 
        spin_lock_bh(&wport->lock);
        if (wport->write_urb_busy) {
                spin_unlock_bh(&wport->lock);
-               dbg("%s - already writing", __FUNCTION__);
+               dbg("%s - already writing", __func__);
                return 0;
        }
        wport->write_urb_busy = 1;
@@ -271,7 +271,7 @@ static int omninet_write (struct usb_serial_port *port, const unsigned char *buf
 
        memcpy (wport->write_urb->transfer_buffer + OMNINET_DATAOFFSET, buf, count);
 
-       usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, wport->write_urb->transfer_buffer);
+       usb_serial_debug_data(debug, &port->dev, __func__, count, wport->write_urb->transfer_buffer);
 
        header->oh_seq  = od->od_outseq++;
        header->oh_len  = count;
@@ -285,7 +285,7 @@ static int omninet_write (struct usb_serial_port *port, const unsigned char *buf
        result = usb_submit_urb(wport->write_urb, GFP_ATOMIC);
        if (result) {
                wport->write_urb_busy = 0;
-               err("%s - failed submitting write urb, error %d", __FUNCTION__, result);
+               err("%s - failed submitting write urb, error %d", __func__, result);
        } else
                result = count;
 
@@ -293,17 +293,19 @@ static int omninet_write (struct usb_serial_port *port, const unsigned char *buf
 }
 
 
-static int omninet_write_room (struct usb_serial_port *port)
+static int omninet_write_room (struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct usb_serial       *serial = port->serial;
        struct usb_serial_port  *wport  = serial->port[1];
 
-       int room = 0; // Default: no room
+       int room = 0; /* Default: no room */
 
+       /* FIXME: no consistent locking for write_urb_busy */
        if (wport->write_urb_busy)
                room = wport->bulk_out_size - OMNINET_HEADERLEN;
 
-       dbg("%s - returns %d", __FUNCTION__, room);
+       dbg("%s - returns %d", __func__, room);
 
        return (room);
 }
@@ -311,15 +313,15 @@ static int omninet_write_room (struct usb_serial_port *port)
 static void omninet_write_bulk_callback (struct urb *urb)
 {
 /*     struct omninet_header   *header = (struct omninet_header  *) urb->transfer_buffer; */
-       struct usb_serial_port  *port   = (struct usb_serial_port *) urb->context;
+       struct usb_serial_port  *port   =  urb->context;
        int status = urb->status;
 
-       dbg("%s - port %0x\n", __FUNCTION__, port->number);
+       dbg("%s - port %0x\n", __func__, port->number);
 
        port->write_urb_busy = 0;
        if (status) {
                dbg("%s - nonzero write bulk status received: %d",
-                   __FUNCTION__, status);
+                   __func__, status);
                return;
        }
 
@@ -331,7 +333,7 @@ static void omninet_shutdown (struct usb_serial *serial)
 {
        struct usb_serial_port *wport = serial->port[1];
        struct usb_serial_port *port = serial->port[0];
-       dbg ("%s", __FUNCTION__);
+       dbg ("%s", __func__);
 
        usb_kill_urb(wport->write_urb);
        kfree(usb_get_serial_port_data(port));