Hi,

this adds module usage count handling during probe and disconnect to the
usb core. It applies to 2.5.1 and is now in the smallest possible form.
I did not go at the old style probe, as it shoulde be IMO removed.

Greg, please apply.

        Regards
                Oliver


--- include/linux/usb.h.alt     Tue Dec 18 11:07:27 2001
+++ include/linux/usb.h Tue Dec 18 11:39:20 2001
@@ -514,6 +514,8 @@
            void *handle                        /* as returned by probe() */
            );

+       struct module *module;
+
        struct list_head driver_list;

        struct file_operations *fops;
--- drivers/usb/usb.c.alt       Wed Dec 19 10:15:34 2001
+++ drivers/usb/usb.c   Wed Dec 19 10:19:03 2001
@@ -148,12 +148,16 @@
                struct usb_interface *interface = &dev->actconfig->interface[i];

                if (interface->driver == driver) {
-                       down(&driver->serialize);
+                       if (driver->module)
+                               __MOD_INC_USE_COUNT(driver->module);
+                       down(&driver->serialize);
                        driver->disconnect(dev, interface->private_data);
                        up(&driver->serialize);
                        /* if driver->disconnect didn't release the interface */
                        if (interface->driver)
                                usb_driver_release_interface(driver, interface);
+                       if (driver->module)
+                               __MOD_DEC_USE_COUNT(driver->module);
                        /*
                         * This will go through the list looking for another
                         * driver that can handle the device
@@ -785,9 +789,13 @@
                                interface->act_altsetting = i;
                                id = usb_match_id(dev, interface, id);
                                if (id) {
+                                       if (driver->module)
+                                               __MOD_INC_USE_COUNT(driver->module);
                                        down(&driver->serialize);
                                        private = driver->probe(dev,ifnum,id);
                                        up(&driver->serialize);
+                                       if (driver->module)
+                                               __MOD_DEC_USE_COUNT(driver->module);
                                        if (private != NULL)
                                                break;
                                }
@@ -1883,12 +1891,16 @@
                        struct usb_interface *interface = 
&dev->actconfig->interface[i];
                        struct usb_driver *driver = interface->driver;
                        if (driver) {
+                               if (driver->module)
+                                       __MOD_INC_USE_COUNT(driver->module);
                                down(&driver->serialize);
                                driver->disconnect(dev, interface->private_data);
                                up(&driver->serialize);
                                /* if driver->disconnect didn't release the interface 
*/
                                if (interface->driver)
                                        usb_driver_release_interface(driver, 
interface);
+                               if (driver->module)
+                                       __MOD_DEC_USE_COUNT(driver->module);
                        }
                }
        }


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

Reply via email to