Hi,

Here's a patch against 2.5.2-pre1 that moves the module locking logic
out of the individual usb-serial drivers, and into the core (much like
the patch that Oliver posted earlier for the usb core.)

If anyone sees a problem with this patch, or has questions, please let
me know.

thanks,

greg k-h


diff -Nru a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c
--- a/drivers/usb/serial/belkin_sa.c    Fri Dec 21 16:21:19 2001
+++ b/drivers/usb/serial/belkin_sa.c    Fri Dec 21 16:21:19 2001
@@ -119,6 +119,7 @@
 
 /* All of the device info needed for the serial converters */
 static struct usb_serial_device_type belkin_device = {
+       owner:                  THIS_MODULE,
        name:                   "Belkin / Peracom / GoHubs USB Serial Adapter",
        id_table:               id_table_combined,
        num_interrupt_in:       1,
@@ -209,7 +210,6 @@
        down (&port->sem);
        
        ++port->open_count;
-       MOD_INC_USE_COUNT;
        
        if (port->open_count == 1) {
                /*Start reading from the device*/
@@ -264,7 +264,6 @@
        }
        
        up (&port->sem);
-       MOD_DEC_USE_COUNT;
 } /* belkin_sa_close */
 
 
diff -Nru a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
--- a/drivers/usb/serial/cyberjack.c    Fri Dec 21 16:21:19 2001
+++ b/drivers/usb/serial/cyberjack.c    Fri Dec 21 16:21:19 2001
@@ -77,6 +77,7 @@
 MODULE_DEVICE_TABLE (usb, id_table);
 
 static struct usb_serial_device_type cyberjack_device = {
+       owner:                  THIS_MODULE,
        name:                   "Reiner SCT Cyberjack USB card reader",
        id_table:               id_table,
        num_interrupt_in:       1,
@@ -148,8 +149,6 @@
        if (port_paranoia_check (port, __FUNCTION__))
                return -ENODEV;
 
-       MOD_INC_USE_COUNT;
-
        dbg(__FUNCTION__ " - port %d", port->number);
 
        down (&port->sem);
@@ -204,7 +203,6 @@
        }
 
        up (&port->sem);
-       MOD_DEC_USE_COUNT;
 }
 
 static int cyberjack_write (struct usb_serial_port *port, int from_user, const 
unsigned char *buf, int count)
diff -Nru a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
--- a/drivers/usb/serial/digi_acceleport.c      Fri Dec 21 16:21:19 2001
+++ b/drivers/usb/serial/digi_acceleport.c      Fri Dec 21 16:21:19 2001
@@ -501,6 +501,7 @@
 /* device info needed for the Digi serial converter */
 
 static struct usb_serial_device_type digi_acceleport_2_device = {
+       owner:                          THIS_MODULE,
        name:                           "Digi USB",
        id_table:                       id_table_2,
        num_interrupt_in:               0,
@@ -524,6 +525,7 @@
 };
 
 static struct usb_serial_device_type digi_acceleport_4_device = {
+       owner:                          THIS_MODULE,
        name:                           "Digi USB",
        id_table:                       id_table_4,
        num_interrupt_in:               0,
@@ -603,7 +605,6 @@
        spin_lock_irqsave( &priv->dp_port_lock, flags );
        digi_wakeup_write( port );
        spin_unlock_irqrestore( &priv->dp_port_lock, flags );
-       MOD_DEC_USE_COUNT;
 }
 
 static void digi_wakeup_write( struct usb_serial_port *port )
@@ -1410,9 +1411,7 @@
 
        /* also queue up a wakeup at scheduler time, in case we */
        /* lost the race in write_chan(). */
-       MOD_INC_USE_COUNT;
-       if (schedule_task(&priv->dp_wakeup_task) == 0)
-               MOD_DEC_USE_COUNT;
+       schedule_task(&priv->dp_wakeup_task);
 
        spin_unlock( &priv->dp_port_lock );
 
@@ -1493,7 +1492,6 @@
 
        /* inc module use count before sleeping to wait for closes */
        ++port->open_count;
-       MOD_INC_USE_COUNT;
 
        /* wait for a close in progress to finish */
        while( priv->dp_in_close ) {
@@ -1502,7 +1500,6 @@
                        &priv->dp_port_lock, flags );
                if( signal_pending(current) ) {
                        --port->open_count;
-                       MOD_DEC_USE_COUNT;
                        return( -EINTR );
                }
                spin_lock_irqsave( &priv->dp_port_lock, flags );
@@ -1562,7 +1559,6 @@
        spin_lock_irqsave( &priv->dp_port_lock, flags );
        if( port->open_count > 1 ) {
                --port->open_count;
-               MOD_DEC_USE_COUNT;
                spin_unlock_irqrestore( &priv->dp_port_lock, flags );
                return;
        } else if( port->open_count <= 0 ) {
@@ -1642,7 +1638,6 @@
        priv->dp_write_urb_in_use = 0;
        priv->dp_in_close = 0;
        --port->open_count;
-       MOD_DEC_USE_COUNT;
        wake_up_interruptible( &priv->dp_close_wait );
        spin_unlock_irqrestore( &priv->dp_port_lock, flags );
 
@@ -1787,7 +1782,6 @@
                priv = serial->port[i].private;
                spin_lock_irqsave( &priv->dp_port_lock, flags );
                while( serial->port[i].open_count > 0 ) {
-                       MOD_DEC_USE_COUNT;
                        --serial->port[i].open_count;
                }
                spin_unlock_irqrestore( &priv->dp_port_lock, flags );
diff -Nru a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c
--- a/drivers/usb/serial/empeg.c        Fri Dec 21 16:21:19 2001
+++ b/drivers/usb/serial/empeg.c        Fri Dec 21 16:21:19 2001
@@ -114,6 +114,7 @@
 MODULE_DEVICE_TABLE (usb, id_table);
 
 static struct usb_serial_device_type empeg_device = {
+       owner:                  THIS_MODULE,
        name:                   "Empeg",
        id_table:               id_table,
        num_interrupt_in:       0,
@@ -159,7 +160,6 @@
        down (&port->sem);
 
        ++port->open_count;
-       MOD_INC_USE_COUNT;
 
        if (port->open_count == 1) {
 
@@ -224,8 +224,6 @@
 
        /* Uncomment the following line if you want to see some statistics in your 
syslog */
        /* info ("Bytes In = %d  Bytes Out = %d", bytes_in, bytes_out); */
-
-       MOD_DEC_USE_COUNT;
 }
 
 
diff -Nru a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
--- a/drivers/usb/serial/ftdi_sio.c     Fri Dec 21 16:21:19 2001
+++ b/drivers/usb/serial/ftdi_sio.c     Fri Dec 21 16:21:19 2001
@@ -174,6 +174,7 @@
    which share common code */ 
 
 static struct usb_serial_device_type ftdi_sio_device = {
+       owner:                  THIS_MODULE,
        name:                   "FTDI SIO",
        id_table:               id_table_sio,
        num_interrupt_in:       0,
@@ -318,7 +319,6 @@
 
        down (&port->sem);
        
-       MOD_INC_USE_COUNT;
        ++port->open_count;
 
        if (port->open_count == 1){
@@ -411,7 +411,6 @@
        }
 
        up (&port->sem);
-       MOD_DEC_USE_COUNT;
 
 } /* ftdi_sio_close */
 
diff -Nru a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
--- a/drivers/usb/serial/io_edgeport.c  Fri Dec 21 16:21:19 2001
+++ b/drivers/usb/serial/io_edgeport.c  Fri Dec 21 16:21:19 2001
@@ -985,7 +985,6 @@
                return -ENODEV;
 
        ++port->open_count;
-       MOD_INC_USE_COUNT;
        
        if (port->open_count == 1) {
                /* force low_latency on so that our tty_push actually forces the data 
through, 
@@ -999,7 +998,6 @@
                edge_serial = (struct edgeport_serial *)serial->private;
                if (edge_serial == NULL) {
                        port->open_count = 0;
-                       MOD_DEC_USE_COUNT;
                        return -ENODEV;
                }
                if (edge_serial->interrupt_in_buffer == NULL) {
@@ -1062,7 +1060,6 @@
                        err(__FUNCTION__" - error sending open port command");
                        edge_port->openPending = FALSE;
                        port->open_count = 0;
-                       MOD_DEC_USE_COUNT;
                        return -ENODEV;
                }
 
@@ -1077,7 +1074,6 @@
                        dbg(__FUNCTION__" - open timedout");
                        edge_port->openPending = FALSE;
                        port->open_count = 0;
-                       MOD_DEC_USE_COUNT;
                        return -ENODEV;
                }
 
@@ -1283,7 +1279,6 @@
                port->open_count = 0;
        }
 
-       MOD_DEC_USE_COUNT;
        dbg(__FUNCTION__" exited");
 }   
 
diff -Nru a/drivers/usb/serial/io_tables.h b/drivers/usb/serial/io_tables.h
--- a/drivers/usb/serial/io_tables.h    Fri Dec 21 16:21:19 2001
+++ b/drivers/usb/serial/io_tables.h    Fri Dec 21 16:21:19 2001
@@ -72,6 +72,7 @@
 MODULE_DEVICE_TABLE (usb, id_table_combined);
 
 static struct usb_serial_device_type edgeport_1port_device = {
+       owner:                  THIS_MODULE,
        name:                   "Edgeport 1 port adapter",
        id_table:               edgeport_1port_id_table,
        num_interrupt_in:       1,
@@ -93,6 +94,7 @@
 };
 
 static struct usb_serial_device_type edgeport_2port_device = {
+       owner:                  THIS_MODULE,
        name:                   "Edgeport 2 port adapter",
        id_table:               edgeport_2port_id_table,
        num_interrupt_in:       1,
@@ -114,6 +116,7 @@
 };
 
 static struct usb_serial_device_type edgeport_4port_device = {
+       owner:                  THIS_MODULE,
        name:                   "Edgeport 4 port adapter",
        id_table:               edgeport_4port_id_table,
        num_interrupt_in:       1,
@@ -135,6 +138,7 @@
 };
 
 static struct usb_serial_device_type edgeport_8port_device = {
+       owner:                  THIS_MODULE,
        name:                   "Edgeport 8 port adapter",
        id_table:               edgeport_8port_id_table,
        num_interrupt_in:       1,
diff -Nru a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
--- a/drivers/usb/serial/ipaq.c Fri Dec 21 16:21:19 2001
+++ b/drivers/usb/serial/ipaq.c Fri Dec 21 16:21:19 2001
@@ -69,6 +69,7 @@
 
 /* All of the device info needed for the Compaq iPAQ */
 struct usb_serial_device_type ipaq_device = {
+       owner:                  THIS_MODULE,
        name:                   "Compaq iPAQ",
        id_table:               ipaq_id_table,
        num_interrupt_in:       0,
@@ -106,7 +107,6 @@
        down(&port->sem);
        
        ++port->open_count;
-       MOD_INC_USE_COUNT;
        
        if (port->open_count == 1) {
                bytes_in = 0;
@@ -242,8 +242,6 @@
 
        /* Uncomment the following line if you want to see some statistics in your 
syslog */
        /* info ("Bytes In = %d  Bytes Out = %d", bytes_in, bytes_out); */
-
-       MOD_DEC_USE_COUNT;
 }
 
 static void ipaq_read_bulk_callback(struct urb *urb)
diff -Nru a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
--- a/drivers/usb/serial/ir-usb.c       Fri Dec 21 16:21:19 2001
+++ b/drivers/usb/serial/ir-usb.c       Fri Dec 21 16:21:19 2001
@@ -91,6 +91,7 @@
 
 
 struct usb_serial_device_type ir_device = {
+       owner:                  THIS_MODULE,
        name:                   "IR Dongle",
        id_table:               id_table,
        num_interrupt_in:       1,
@@ -204,7 +205,6 @@
        down (&port->sem);
        
        ++port->open_count;
-       MOD_INC_USE_COUNT;
        
        if (port->open_count == 1) {
                if (buffer_size) {
@@ -270,7 +270,6 @@
 
        }
        up (&port->sem);
-       MOD_DEC_USE_COUNT;
 }
 
 static int ir_write (struct usb_serial_port *port, int from_user, const unsigned char 
*buf, int count)
diff -Nru a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
--- a/drivers/usb/serial/keyspan.c      Fri Dec 21 16:21:19 2001
+++ b/drivers/usb/serial/keyspan.c      Fri Dec 21 16:21:19 2001
@@ -877,8 +877,6 @@
        
        dbg("keyspan_open called for port%d.\n", port->number); 
 
-       MOD_INC_USE_COUNT;
-
        down (&port->sem);
        already_active = port->open_count;
        ++port->open_count;
@@ -960,8 +958,6 @@
                port->tty = 0;
        }
        up (&port->sem);
-
-       MOD_DEC_USE_COUNT;
 }
 
 
@@ -1789,7 +1785,6 @@
                port = &serial->port[i];
                while (port->open_count > 0) {
                        --port->open_count;
-                       MOD_DEC_USE_COUNT;
                }
                kfree(port->private);
        }
diff -Nru a/drivers/usb/serial/keyspan.h b/drivers/usb/serial/keyspan.h
--- a/drivers/usb/serial/keyspan.h      Fri Dec 21 16:21:19 2001
+++ b/drivers/usb/serial/keyspan.h      Fri Dec 21 16:21:19 2001
@@ -449,6 +449,7 @@
 
     /* Structs for the devices, pre and post renumeration. */
 static struct usb_serial_device_type keyspan_usa18x_pre_device = {
+       owner:                  THIS_MODULE,
        name:                   "Keyspan USA18X - (without firmware)",
        id_table:               keyspan_usa18x_pre_ids,
        num_interrupt_in:       NUM_DONT_CARE,
@@ -459,6 +460,7 @@
 };
 
 static struct usb_serial_device_type keyspan_usa19_pre_device = {
+       owner:                  THIS_MODULE,
        name:                   "Keyspan USA19 - (without firmware)",
        id_table:               keyspan_usa19_pre_ids,
        num_interrupt_in:       NUM_DONT_CARE,
@@ -470,6 +472,7 @@
 
 
 static struct usb_serial_device_type keyspan_usa19w_pre_device = {
+       owner:                  THIS_MODULE,
        name:                   "Keyspan USA19W - (without firmware)",
        id_table:               keyspan_usa19w_pre_ids,
        num_interrupt_in:       NUM_DONT_CARE,
@@ -481,6 +484,7 @@
 
 
 static struct usb_serial_device_type keyspan_usa28_pre_device = {
+       owner:                  THIS_MODULE,
        name:                   "Keyspan USA28 - (without firmware)",
        id_table:               keyspan_usa28_pre_ids,
        num_interrupt_in:       NUM_DONT_CARE,
@@ -491,6 +495,7 @@
 };
 
 static struct usb_serial_device_type keyspan_usa28x_pre_device = {
+       owner:                  THIS_MODULE,
        name:                   "Keyspan USA28X - (without firmware)",
        id_table:               keyspan_usa28x_pre_ids,
        num_interrupt_in:       NUM_DONT_CARE,
@@ -501,6 +506,7 @@
 };
 
 static struct usb_serial_device_type keyspan_usa28xa_pre_device = {
+       owner:                  THIS_MODULE,
        name:                   "Keyspan USA28XA - (without firmware)",
        id_table:               keyspan_usa28xa_pre_ids,
        num_interrupt_in:       NUM_DONT_CARE,
@@ -511,6 +517,7 @@
 };
 
 static struct usb_serial_device_type keyspan_usa28xb_pre_device = {
+       owner:                  THIS_MODULE,
        name:                   "Keyspan USA28XB - (without firmware)",
        id_table:               keyspan_usa28xb_pre_ids,
        num_interrupt_in:       NUM_DONT_CARE,
@@ -521,6 +528,7 @@
 };
 
 static struct usb_serial_device_type keyspan_usa49w_pre_device = {
+       owner:                  THIS_MODULE,
        name:                   "Keyspan USA49W - (without firmware)",
        id_table:               keyspan_usa49w_pre_ids,
        num_interrupt_in:       NUM_DONT_CARE,
@@ -531,6 +539,7 @@
 };
 
 static struct usb_serial_device_type keyspan_usa18x_device = {
+       owner:                  THIS_MODULE,
        name:                   "Keyspan USA18X",
        id_table:               keyspan_usa18x_ids,
        num_interrupt_in:       NUM_DONT_CARE,
@@ -554,6 +563,7 @@
 };
 
 static struct usb_serial_device_type keyspan_usa19_device = {
+       owner:                  THIS_MODULE,
        name:                   "Keyspan USA19",
        id_table:               keyspan_usa19_ids,
        num_interrupt_in:       NUM_DONT_CARE,
@@ -578,6 +588,7 @@
 
 
 static struct usb_serial_device_type keyspan_usa19w_device = {
+       owner:                  THIS_MODULE,
        name:                   "Keyspan USA19W",
        id_table:               keyspan_usa19w_ids,
        num_interrupt_in:       NUM_DONT_CARE,
@@ -602,6 +613,7 @@
 
 
 static struct usb_serial_device_type keyspan_usa28_device = {
+       owner:                  THIS_MODULE,
        name:                   "Keyspan USA28",
        id_table:               keyspan_usa28_ids,
        num_interrupt_in:       NUM_DONT_CARE,
@@ -617,6 +629,7 @@
 
 
 static struct usb_serial_device_type keyspan_usa28x_device = {
+       owner:                  THIS_MODULE,
        name:                   "Keyspan USA28X/XB",
        id_table:               keyspan_usa28x_ids,
        num_interrupt_in:       NUM_DONT_CARE,
@@ -641,6 +654,7 @@
 };
 
 static struct usb_serial_device_type keyspan_usa28xa_device = {
+       owner:                  THIS_MODULE,
        name:                   "Keyspan USA28XA",
        id_table:               keyspan_usa28xa_ids,
        num_interrupt_in:       NUM_DONT_CARE,
@@ -665,6 +679,7 @@
 };
 
 static struct usb_serial_device_type keyspan_usa49w_device = {
+       owner:                  THIS_MODULE,
        name:                   "Keyspan USA49W",
        id_table:               keyspan_usa49w_ids,
        num_interrupt_in:       NUM_DONT_CARE,
diff -Nru a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
--- a/drivers/usb/serial/keyspan_pda.c  Fri Dec 21 16:21:19 2001
+++ b/drivers/usb/serial/keyspan_pda.c  Fri Dec 21 16:21:19 2001
@@ -193,7 +193,6 @@
        /* wake up other tty processes */
        wake_up_interruptible( &tty->write_wait );
        /* For 2.2.16 backport -- wake_up_interruptible( &tty->poll_wait ); */
-       MOD_DEC_USE_COUNT;
 }
 
 static void keyspan_pda_request_unthrottle( struct usb_serial *serial )
@@ -212,7 +211,6 @@
                             NULL,
                             0,
                             2*HZ);
-       MOD_DEC_USE_COUNT;
 }
 
 
@@ -261,9 +259,7 @@
                        tty = serial->port[0].tty;
                        priv->tx_throttled = 0;
                        /* queue up a wakeup at scheduler time */
-                       MOD_INC_USE_COUNT;
-                       if (schedule_task(&priv->wakeup_task) == 0)
-                               MOD_DEC_USE_COUNT;
+                       schedule_task(&priv->wakeup_task);
                        break;
                default:
                        break;
@@ -602,9 +598,7 @@
 
        if (request_unthrottle) {
                priv->tx_throttled = 1; /* block writers */
-               MOD_INC_USE_COUNT;
-               if (schedule_task(&priv->unthrottle_task) == 0)
-                       MOD_DEC_USE_COUNT;
+               schedule_task(&priv->unthrottle_task);
        }
 
        rc = count;
@@ -631,9 +625,7 @@
        }
        
        /* queue up a wakeup at scheduler time */
-       MOD_INC_USE_COUNT;
-       if (schedule_task(&priv->wakeup_task) == 0)
-               MOD_DEC_USE_COUNT;
+       schedule_task(&priv->wakeup_task);
 }
 
 
@@ -672,7 +664,6 @@
 
        down (&port->sem);
 
-       MOD_INC_USE_COUNT;
        ++port->open_count;
 
        if (port->open_count == 1) {
@@ -721,7 +712,6 @@
        return rc;
 error:
        --port->open_count;
-       MOD_DEC_USE_COUNT;
        up (&port->sem);
        return rc;
 }
@@ -749,7 +739,6 @@
        }
 
        up (&port->sem);
-       MOD_DEC_USE_COUNT;
 }
 
 
diff -Nru a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
--- a/drivers/usb/serial/kl5kusb105.c   Fri Dec 21 16:21:19 2001
+++ b/drivers/usb/serial/kl5kusb105.c   Fri Dec 21 16:21:19 2001
@@ -121,6 +121,7 @@
 
 
 static struct usb_serial_device_type kl5kusb105d_device = {
+       owner:               THIS_MODULE,
        name:                "KL5KUSB105D / PalmConnect",
        id_table:            id_table,
        num_interrupt_in:    1,
@@ -360,7 +361,6 @@
        down (&port->sem);
        
        ++port->open_count;
-       MOD_INC_USE_COUNT;
 
        if (port->open_count == 1) {
                int rc;
@@ -484,7 +484,6 @@
        }
        
        up (&port->sem);
-       MOD_DEC_USE_COUNT;
 } /* klsi_105_close */
 
 
diff -Nru a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
--- a/drivers/usb/serial/mct_u232.c     Fri Dec 21 16:21:19 2001
+++ b/drivers/usb/serial/mct_u232.c     Fri Dec 21 16:21:19 2001
@@ -144,6 +144,7 @@
 
 
 static struct usb_serial_device_type mct_u232_device = {
+       owner:               THIS_MODULE,
        name:                "Magic Control Technology USB-RS232",
        id_table:            id_table_combined,
        num_interrupt_in:    2,
@@ -343,7 +344,6 @@
        down (&port->sem);
        
        ++port->open_count;
-       MOD_INC_USE_COUNT;
 
        if (port->open_count == 1) {
                /* Compensate for a hardware bug: although the Sitecom U232-P25
@@ -423,7 +423,6 @@
        }
        
        up (&port->sem);
-       MOD_DEC_USE_COUNT;
 } /* mct_u232_close */
 
 
diff -Nru a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c
--- a/drivers/usb/serial/omninet.c      Fri Dec 21 16:21:19 2001
+++ b/drivers/usb/serial/omninet.c      Fri Dec 21 16:21:19 2001
@@ -88,6 +88,7 @@
 
 
 static struct usb_serial_device_type zyxel_omninet_device = {
+       owner:                  THIS_MODULE,
        name:                   "ZyXEL - omni.net lcd plus usb",
        id_table:               id_table,
        num_interrupt_in:       1,
@@ -158,7 +159,6 @@
 
        down (&port->sem);
 
-       MOD_INC_USE_COUNT;
        ++port->open_count;
 
        if (port->open_count == 1) {
@@ -167,7 +167,6 @@
                        err(__FUNCTION__"- kmalloc(%Zd) failed.", sizeof(struct 
omninet_data));
                        port->open_count = 0;
                        up (&port->sem);
-                       MOD_DEC_USE_COUNT;
                        return -ENOMEM;
                }
 
@@ -223,7 +222,6 @@
        }
 
        up (&port->sem);
-       MOD_DEC_USE_COUNT;
 }
 
 
diff -Nru a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
--- a/drivers/usb/serial/pl2303.c       Fri Dec 21 16:21:19 2001
+++ b/drivers/usb/serial/pl2303.c       Fri Dec 21 16:21:19 2001
@@ -116,6 +116,7 @@
 
 /* All of the device info needed for the PL2303 SIO serial converter */
 static struct usb_serial_device_type pl2303_device = {
+       owner:                  THIS_MODULE,
        name:                   "PL-2303",
        id_table:               id_table,
        num_interrupt_in:       NUM_DONT_CARE,
@@ -369,7 +370,6 @@
        down (&port->sem);
 
        ++port->open_count;
-       MOD_INC_USE_COUNT;
 
        if (port->open_count == 1) {
 #define FISH(a,b,c,d)                                                                 
 \
@@ -480,7 +480,6 @@
        }
 
        up (&port->sem);
-       MOD_DEC_USE_COUNT;
 }
 
 static int set_modem_info (struct usb_serial_port *port, unsigned int cmd, unsigned 
int *value)
diff -Nru a/drivers/usb/serial/usb-serial.h b/drivers/usb/serial/usb-serial.h
--- a/drivers/usb/serial/usb-serial.h   Fri Dec 21 16:21:19 2001
+++ b/drivers/usb/serial/usb-serial.h   Fri Dec 21 16:21:19 2001
@@ -116,6 +116,7 @@
 
 /**
  * usb_serial_device_type - a structure that defines a usb serial device
+ * @owner: pointer to the module that owns this device.
  * @name: pointer to a string that describes this device.  This string used
  *     in the syslog messages when a device is inserted or removed.
  * @id_table: pointer to a list of usb_device_id structures that define all
@@ -138,6 +139,7 @@
  * called, the generic serial function will be used instead.
  */
 struct usb_serial_device_type {
+       struct module *owner;
        char    *name;
        const struct usb_device_id *id_table;
        char    num_interrupt_in;
diff -Nru a/drivers/usb/serial/usbserial.c b/drivers/usb/serial/usbserial.c
--- a/drivers/usb/serial/usbserial.c    Fri Dec 21 16:21:19 2001
+++ b/drivers/usb/serial/usbserial.c    Fri Dec 21 16:21:19 2001
@@ -506,6 +506,7 @@
        struct usb_serial *serial;
        struct usb_serial_port *port;
        int portNumber;
+       int retval;
        
        dbg(__FUNCTION__);
 
@@ -527,10 +528,16 @@
         
        /* pass on to the driver specific version of this function if it is available 
*/
        if (serial->type->open) {
-               return (serial->type->open(port, filp));
+               if (serial->type->owner)
+                       __MOD_INC_USE_COUNT(serial->type->owner);
+               retval = serial->type->open(port, filp);
+               if (retval)
+                       __MOD_DEC_USE_COUNT(serial->type->owner);
        } else {
-               return (generic_open(port, filp));
+               retval = generic_open(port, filp);
        }
+
+       return retval;
 }
 
 
@@ -553,6 +560,8 @@
        /* pass on to the driver specific version of this function if it is available 
*/
        if (serial->type->close) {
                serial->type->close(port, filp);
+               if (serial->type->owner)
+                       __MOD_DEC_USE_COUNT(serial->type->owner);
        } else {
                generic_close(port, filp);
        }
@@ -1059,6 +1068,7 @@
        struct usb_endpoint_descriptor *bulk_out_endpoint[MAX_NUM_PORTS];
        struct usb_serial_device_type *type = NULL;
        struct list_head *tmp;
+       int retval;
        int found;
        int minor;
        int buffer_size;
@@ -1180,9 +1190,13 @@
 
        /* if this device type has a startup function, call it */
        if (type->startup) {
-               if (type->startup (serial)) {
+               if (type->owner)
+                       __MOD_INC_USE_COUNT(type->owner);
+               retval = type->startup (serial);
+               if (type->owner)
+                       __MOD_DEC_USE_COUNT(type->owner);
+               if (retval)
                        goto probe_error;
-               }
        }
 
        /* set up the endpoint information */
diff -Nru a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
--- a/drivers/usb/serial/visor.c        Fri Dec 21 16:21:19 2001
+++ b/drivers/usb/serial/visor.c        Fri Dec 21 16:21:19 2001
@@ -182,6 +182,7 @@
 
 /* All of the device info needed for the Handspring Visor, and Palm 4.0 devices */
 static struct usb_serial_device_type handspring_device = {
+       owner:                  THIS_MODULE,
        name:                   "Handspring Visor / Palm 4.0 / Clié 4.0",
        id_table:               combined_id_table,
        num_interrupt_in:       0,
@@ -205,6 +206,7 @@
 
 /* device info for the Sony Clie OS version 3.5 */
 static struct usb_serial_device_type clie_3_5_device = {
+       owner:                  THIS_MODULE,
        name:                   "Sony Clié 3.5",
        id_table:               clie_id_3_5_table,
        num_interrupt_in:       0,
@@ -255,7 +257,6 @@
        down (&port->sem);
        
        ++port->open_count;
-       MOD_INC_USE_COUNT;
        
        if (port->open_count == 1) {
                bytes_in = 0;
@@ -327,8 +328,6 @@
 
        /* Uncomment the following line if you want to see some statistics in your 
syslog */
        /* info ("Bytes In = %d  Bytes Out = %d", bytes_in, bytes_out); */
-
-       MOD_DEC_USE_COUNT;
 }
 
 
diff -Nru a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
--- a/drivers/usb/serial/whiteheat.c    Fri Dec 21 16:21:19 2001
+++ b/drivers/usb/serial/whiteheat.c    Fri Dec 21 16:21:19 2001
@@ -133,6 +133,7 @@
 static void whiteheat_real_shutdown    (struct usb_serial *serial);
 
 static struct usb_serial_device_type whiteheat_fake_device = {
+       owner:                  THIS_MODULE,
        name:                   "Connect Tech - WhiteHEAT - (prerenumeration)",
        id_table:               id_table_prerenumeration,
        num_interrupt_in:       NUM_DONT_CARE,
@@ -143,6 +144,7 @@
 };
 
 static struct usb_serial_device_type whiteheat_device = {
+       owner:                  THIS_MODULE,
        name:                   "Connect Tech - WhiteHEAT",
        id_table:               id_table_std,
        num_interrupt_in:       NUM_DONT_CARE,
@@ -307,7 +309,6 @@
        down (&port->sem);
 
        ++port->open_count;
-       MOD_INC_USE_COUNT;
        
        if (port->open_count == 1) {
                /* set up some stuff for our command port */
@@ -359,7 +360,6 @@
 
 error_exit:
        --port->open_count;
-       MOD_DEC_USE_COUNT;
 
        dbg(__FUNCTION__ " - error_exit");
        up (&port->sem);
@@ -391,7 +391,6 @@
                usb_unlink_urb (port->read_urb);
                port->open_count = 0;
        }
-       MOD_DEC_USE_COUNT;
        up (&port->sem);
 }
 

_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to