Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc
[safe/jmp/linux-2.6] / drivers / usb / serial / navman.c
index ac3f8b5..5ceaa4c 100644 (file)
@@ -6,6 +6,10 @@
  *     This program is free software; you can redistribute it and/or
  *     modify it under the terms of the GNU General Public License
  *     version 2 as published by the Free Software Foundation.
+ *
+ * TODO:
+ *     Add termios method that uses copy_hw but also kills all echo
+ *     flags as the navman is rx only so cannot echo.
  */
 
 #include <linux/kernel.h>
@@ -32,14 +36,15 @@ static struct usb_driver navman_driver = {
        .no_dynamic_id =        1,
 };
 
-static void navman_read_int_callback(struct urb *urb, struct pt_regs *regs)
+static void navman_read_int_callback(struct urb *urb)
 {
        struct usb_serial_port *port = urb->context;
        unsigned char *data = urb->transfer_buffer;
        struct tty_struct *tty;
+       int status = urb->status;
        int result;
 
-       switch (urb->status) {
+       switch (status) {
        case 0:
                /* success */
                break;
@@ -48,70 +53,66 @@ static void navman_read_int_callback(struct urb *urb, struct pt_regs *regs)
        case -ESHUTDOWN:
                /* this urb is terminated, clean up */
                dbg("%s - urb shutting down with status: %d",
-                   __FUNCTION__, urb->status);
+                   __func__, status);
                return;
        default:
                dbg("%s - nonzero urb status received: %d",
-                   __FUNCTION__, urb->status);
+                   __func__, status);
                goto exit;
        }
 
-       usb_serial_debug_data(debug, &port->dev, __FUNCTION__,
+       usb_serial_debug_data(debug, &port->dev, __func__,
                              urb->actual_length, data);
 
-       tty = port->tty;
+       tty = tty_port_tty_get(&port->port);
        if (tty && urb->actual_length) {
                tty_buffer_request_room(tty, urb->actual_length);
                tty_insert_flip_string(tty, data, urb->actual_length);
                tty_flip_buffer_push(tty);
        }
+       tty_kref_put(tty);
 
 exit:
        result = usb_submit_urb(urb, GFP_ATOMIC);
        if (result)
                dev_err(&urb->dev->dev,
                        "%s - Error %d submitting interrupt urb\n",
-                       __FUNCTION__, result);
+                       __func__, result);
 }
 
-static int navman_open(struct usb_serial_port *port, struct file *filp)
+static int navman_open(struct tty_struct *tty, struct usb_serial_port *port)
 {
        int result = 0;
 
-       dbg("%s - port %d", __FUNCTION__, port->number);
+       dbg("%s - port %d", __func__, port->number);
 
        if (port->interrupt_in_urb) {
-               dbg("%s - adding interrupt input for treo", __FUNCTION__);
+               dbg("%s - adding interrupt input for treo", __func__);
                result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
                if (result)
                        dev_err(&port->dev,
                                "%s - failed submitting interrupt urb, error %d\n",
-                               __FUNCTION__, result);
+                               __func__, result);
        }
        return result;
 }
 
-static void navman_close(struct usb_serial_port *port, struct file *filp)
+static void navman_close(struct usb_serial_port *port)
 {
-       dbg("%s - port %d", __FUNCTION__, port->number);
+       dbg("%s - port %d", __func__, port->number);
 
-       if (port->interrupt_in_urb)
-               usb_kill_urb(port->interrupt_in_urb);
+       usb_kill_urb(port->interrupt_in_urb);
 }
 
-static int navman_write(struct usb_serial_port *port,
+static int navman_write(struct tty_struct *tty, struct usb_serial_port *port,
                        const unsigned char *buf, int count)
 {
-       dbg("%s - port %d", __FUNCTION__, port->number);
+       dbg("%s - port %d", __func__, port->number);
 
        /*
         * This device can't write any data, only read from the device
-        * so we just silently eat all data sent to us and say it was
-        * successfully sent.
-        * Evil, I know, but do you have a better idea?
         */
-
-       return count;
+       return -EOPNOTSUPP;
 }
 
 static struct usb_serial_driver navman_device = {
@@ -120,9 +121,7 @@ static struct usb_serial_driver navman_device = {
                .name =         "navman",
        },
        .id_table =             id_table,
-       .num_interrupt_in =     NUM_DONT_CARE,
-       .num_bulk_in =          NUM_DONT_CARE,
-       .num_bulk_out =         NUM_DONT_CARE,
+       .usb_driver =           &navman_driver,
        .num_ports =            1,
        .open =                 navman_open,
        .close =                navman_close,