(patch 10 of 13)

Hi,

Here's a patch for the usb-serial whiteheat driver against 2.2.20-pre2
that brings it up to the same logic level that is in 2.4.5.

thanks,

greg k-h
diff -Nru a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
--- a/drivers/usb/serial/whiteheat.c    Tue Jun 12 22:34:40 2001
+++ b/drivers/usb/serial/whiteheat.c    Tue Jun 12 22:34:40 2001
@@ -1,7 +1,7 @@
 /*
  * USB ConnectTech WhiteHEAT driver
  *
- *     Copyright (C) 1999, 2000
+ *     Copyright (C) 1999 - 2001
  *         Greg Kroah-Hartman ([EMAIL PROTECTED])
  *
  *     This program is free software; you can redistribute it and/or modify
@@ -10,6 +10,14 @@
  *     (at your option) any later version.
  *
  * See Documentation/usb/usb-serial.txt for more information on using this driver
+ *
+ * (04/08/2001) gb
+ *     Identify version on module load.
+ * 
+ * 2001_Mar_19 gkh
+ *     Fixed MOD_INC and MOD_DEC logic, the ability to open a port more 
+ *     than once, and the got the proper usb_device_id table entries so
+ *     the driver works again.
  * 
  * (10/05/2000) gkh
  *     Fixed bug with urb->dev not being set properly, now that the usb
@@ -59,20 +67,25 @@
 #include <linux/tty_flip.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
+#include <linux/usb.h>
 
 #ifdef CONFIG_USB_SERIAL_DEBUG
-       #define DEBUG
+       static int debug = 1;
 #else
-       #undef DEBUG
+       static int debug;
 #endif
-#include <linux/usb.h>
 
 #include "usb-serial.h"
-
 #include "whiteheat_fw.h"              /* firmware for the ConnectTech WhiteHEAT 
device */
-
 #include "whiteheat.h"                 /* WhiteHEAT specific commands */
 
+/*
+ * Version Information
+ */
+#define DRIVER_VERSION "v1.0.0"
+#define DRIVER_AUTHOR "Greg Kroah-Hartman <[EMAIL PROTECTED]>"
+#define DRIVER_DESC "USB ConnectTech WhiteHEAT driver"
+
 #define CONNECT_TECH_VENDOR_ID         0x0710
 #define CONNECT_TECH_FAKE_WHITE_HEAT_ID        0x0001
 #define CONNECT_TECH_WHITE_HEAT_ID     0x8001
@@ -266,43 +279,44 @@
 
        dbg(__FUNCTION__" - port %d", port->number);
 
-       if (port->active) {
-               dbg (__FUNCTION__ " - device already open");
-               return -EINVAL;
-       }
-       port->active = 1;
-
-       /* set up some stuff for our command port */
-       command_port = &port->serial->port[COMMAND_PORT];
-       if (command_port->private == NULL) {
-               info = (struct whiteheat_private *)kmalloc (sizeof(struct 
whiteheat_private), GFP_KERNEL);
-               if (info == NULL) {
-                       err(__FUNCTION__ " - out of memory");
-                       return -ENOMEM;
+       ++port->open_count;
+       MOD_INC_USE_COUNT;
+       
+       if (!port->active) {
+               port->active = 1;
+
+               /* set up some stuff for our command port */
+               command_port = &port->serial->port[COMMAND_PORT];
+               if (command_port->private == NULL) {
+                       info = (struct whiteheat_private *)kmalloc (sizeof(struct 
+whiteheat_private), GFP_KERNEL);
+                       if (info == NULL) {
+                               err(__FUNCTION__ " - out of memory");
+                               return -ENOMEM;
+                       }
+                       
+                       init_waitqueue_head(&info->wait_command);
+                       command_port->private = info;
+                       command_port->write_urb->complete = 
+command_port_write_callback;
+                       command_port->read_urb->complete = command_port_read_callback;
+                       command_port->read_urb->dev = port->serial->dev;
+                       command_port->tty = port->tty;          /* need this to "fake" 
+our our sanity check macros */
+                       usb_submit_urb (command_port->read_urb);
                }
                
-               init_waitqueue_head(&info->wait_command);
-               command_port->private = info;
-               command_port->write_urb->complete = command_port_write_callback;
-               command_port->read_urb->complete = command_port_read_callback;
-               command_port->read_urb->dev = port->serial->dev;
-               command_port->tty = port->tty;          /* need this to "fake" our our 
sanity check macros */
-               usb_submit_urb (command_port->read_urb);
-       }
+               /* Start reading from the device */
+               port->read_urb->dev = port->serial->dev;
+               result = usb_submit_urb(port->read_urb);
+               if (result)
+                       err(__FUNCTION__ " - failed submitting read urb, error %d", 
+result);
+       
+               /* send an open port command */
+               /* firmware uses 1 based port numbering */
+               open_command.port = port->number - port->serial->minor + 1;
+               whiteheat_send_cmd (port->serial, WHITEHEAT_OPEN, (__u8 
+*)&open_command, sizeof(open_command));
        
-       /* Start reading from the device */
-       port->read_urb->dev = port->serial->dev;
-       result = usb_submit_urb(port->read_urb);
-       if (result)
-               err(__FUNCTION__ " - failed submitting read urb, error %d", result);
-
-       /* send an open port command */
-       /* firmware uses 1 based port numbering */
-       open_command.port = port->number - port->serial->minor + 1;
-       whiteheat_send_cmd (port->serial, WHITEHEAT_OPEN, (__u8 *)&open_command, 
sizeof(open_command));
-
-       /* Need to do device specific setup here (control lines, baud rate, etc.) */
-       /* FIXME!!! */
+               /* Need to do device specific setup here (control lines, baud rate, 
+etc.) */
+               /* FIXME!!! */
+       }
 
        dbg(__FUNCTION__ " - exit");
        
@@ -316,18 +330,23 @@
        
        dbg(__FUNCTION__ " - port %d", port->number);
        
-       /* send a close command to the port */
-       /* firmware uses 1 based port numbering */
-       close_command.port = port->number - port->serial->minor + 1;
-       whiteheat_send_cmd (port->serial, WHITEHEAT_CLOSE, (__u8 *)&close_command, 
sizeof(close_command));
+       --port->open_count;
 
-       /* Need to change the control lines here */
-       /* FIXME */
+       if (port->open_count <= 0) {
+               /* send a close command to the port */
+               /* firmware uses 1 based port numbering */
+               close_command.port = port->number - port->serial->minor + 1;
+               whiteheat_send_cmd (port->serial, WHITEHEAT_CLOSE, (__u8 
+*)&close_command, sizeof(close_command));
        
-       /* shutdown our bulk reads and writes */
-       usb_unlink_urb (port->write_urb);
-       usb_unlink_urb (port->read_urb);
-       port->active = 0;
+               /* Need to change the control lines here */
+               /* FIXME */
+               
+               /* shutdown our bulk reads and writes */
+               usb_unlink_urb (port->write_urb);
+               usb_unlink_urb (port->read_urb);
+               port->active = 0;
+       }
+       MOD_DEC_USE_COUNT;
 }
 
 
@@ -525,9 +544,17 @@
 static void whiteheat_shutdown (struct usb_serial *serial)
 {
        struct usb_serial_port          *command_port;
+       int i;
 
        dbg(__FUNCTION__);
 
+       /* stop reads and writes on all ports */
+       for (i=0; i < serial->num_ports; ++i) {
+               while (serial->port[i].open_count > 0) {
+                       whiteheat_close (&serial->port[i], NULL);
+               }
+       }
+
        /* free up our private data for our command port */
        command_port = &serial->port[COMMAND_PORT];
        if (command_port->private != NULL) {
@@ -576,6 +603,8 @@
 {
        usb_serial_register (&whiteheat_fake_device);
        usb_serial_register (&whiteheat_device);
+       info(DRIVER_VERSION " " DRIVER_AUTHOR);
+       info(DRIVER_DESC);
        return 0;
 }
 
@@ -590,5 +619,9 @@
 module_init(whiteheat_init);
 module_exit(whiteheat_exit);
 
-MODULE_AUTHOR("Greg Kroah-Hartman <[EMAIL PROTECTED]>");
-MODULE_DESCRIPTION("USB ConnectTech WhiteHEAT driver");
+MODULE_AUTHOR( DRIVER_AUTHOR );
+MODULE_DESCRIPTION( DRIVER_DESC );
+
+MODULE_PARM(debug, "i");
+MODULE_PARM_DESC(debug, "Debug enabled or not");
+

Reply via email to