Merge to Fedora kernel-2.6.18-1.2224_FC5 patched with stable patch-2.6.18.1-vs2.0...
[linux-2.6.git] / drivers / usb / serial / garmin_gps.c
index 1655085..7278526 100644 (file)
@@ -23,7 +23,6 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
  */
 
-#include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/init.h>
@@ -36,6 +35,7 @@
 #include <linux/spinlock.h>
 #include <asm/uaccess.h>
 #include <linux/usb.h>
+#include <linux/usb/serial.h>
 
 /* the mode to be set when the port ist opened */
 static int initial_mode = 1;
@@ -43,8 +43,6 @@ static int initial_mode = 1;
 /* debug flag */
 static int debug = 0;
 
-#include "usb-serial.h"
-
 #define GARMIN_VENDOR_ID             0x091E
 
 /*
@@ -222,11 +220,11 @@ static struct usb_device_id id_table [] = {
 MODULE_DEVICE_TABLE (usb, id_table);
 
 static struct usb_driver garmin_driver = {
-       .owner =        THIS_MODULE,
        .name =         "garmin_gps",
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table,
+       .no_dynamic_id =        1,
 };
 
 
@@ -275,23 +273,14 @@ static void send_to_tty(struct usb_serial_port *port,
                         char *data, unsigned int actual_length)
 {
        struct tty_struct *tty = port->tty;
-       int i;
 
        if (tty && actual_length) {
 
                usb_serial_debug_data(debug, &port->dev, 
                                        __FUNCTION__, actual_length, data);
 
-               for (i = 0; i < actual_length ; ++i) {
-                       /* if we insert more than TTY_FLIPBUF_SIZE characters,
-                          we drop them. */
-                       if(tty->flip.count >= TTY_FLIPBUF_SIZE) {
-                               tty_flip_buffer_push(tty);
-                       }
-                       /* this doesn't actually push the data through unless
-                          tty->low_latency is set */
-                       tty_insert_flip_char(tty, data[i], 0);
-               }
+               tty_buffer_request_room(tty, actual_length);
+               tty_insert_flip_string(tty, data, actual_length);
                tty_flip_buffer_push(tty);
        }
 }
@@ -614,8 +603,8 @@ static int gsp_receive(struct garmin_data * garmin_data_p,
  *
  * return <0 on error, 0 if packet is incomplete or > 0 if packet was sent
  */
-int gsp_send(struct garmin_data * garmin_data_p, const unsigned char *buf,
-              int count)
+static int gsp_send(struct garmin_data * garmin_data_p,
+                   const unsigned char *buf, int count)
 {
        const unsigned char *src;
        unsigned char *dst;
@@ -1021,7 +1010,7 @@ static void garmin_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
                garmin_data_p->flags |= CLEAR_HALT_REQUIRED;
        }
 
-       schedule_work(&port->work);
+       usb_serial_port_softint(port);
 }
 
 
@@ -1431,12 +1420,11 @@ static int garmin_attach (struct usb_serial *serial)
 
        dbg("%s", __FUNCTION__);
 
-       garmin_data_p = kmalloc (sizeof(struct garmin_data), GFP_KERNEL);
+       garmin_data_p = kzalloc(sizeof(struct garmin_data), GFP_KERNEL);
        if (garmin_data_p == NULL) {
                dev_err(&port->dev, "%s - Out of memory\n", __FUNCTION__);
                return -ENOMEM;
        }
-       memset (garmin_data_p, 0, sizeof(struct garmin_data));
        init_timer(&garmin_data_p->timer);
        spin_lock_init(&garmin_data_p->lock);
        INIT_LIST_HEAD(&garmin_data_p->pktlist);
@@ -1468,16 +1456,13 @@ static void garmin_shutdown (struct usb_serial *serial)
 }
 
 
-
-
-
-
-
 /* All of the device info needed */
-static struct usb_serial_device_type garmin_device = {
-       .owner               = THIS_MODULE,
-       .name                = "Garmin GPS usb/tty",
-       .short_name          = "garmin_gps",
+static struct usb_serial_driver garmin_device = {
+       .driver = {
+               .owner =        THIS_MODULE,
+               .name =         "garmin_gps",
+       },
+       .description =          "Garmin GPS usb/tty",
        .id_table            = id_table,
        .num_interrupt_in    = 1,
        .num_bulk_in         = 1,