On Wed, Dec 19, 2001 at 10:31:31AM +0100, [EMAIL PROTECTED] wrote: > 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.
Ok, how about the patch below? It's almost the same as your patch, but it also protects the "old style" probe and the driver ioctl call. Does anyone have any objections to it? thanks, greg k-h diff -Nru a/drivers/usb/devio.c b/drivers/usb/devio.c --- a/drivers/usb/devio.c Wed Jan 2 16:16:51 2002 +++ b/drivers/usb/devio.c Wed Jan 2 16:16:51 2002 @@ -40,6 +40,7 @@ #include <linux/smp_lock.h> #include <linux/signal.h> #include <linux/poll.h> +#include <linux/module.h> #include <linux/usb.h> #include <linux/usbdevice_fs.h> #include <asm/uaccess.h> @@ -1086,10 +1087,15 @@ else if (ifp->driver == 0 || ifp->driver->ioctl == 0) retval = -ENOSYS; } - if (retval == 0) + if (retval == 0) { + if (ifp->driver->owner) + __MOD_INC_USE_COUNT(ifp->driver->owner); /* ifno might usefully be passed ... */ retval = ifp->driver->ioctl (ps->dev, ctrl.ioctl_code, buf); /* size = min_t(int, size, retval)? */ + if (ifp->driver->owner) + __MOD_DEC_USE_COUNT(ifp->driver->owner); + } } /* cleanup and return */ diff -Nru a/drivers/usb/usb.c b/drivers/usb/usb.c --- a/drivers/usb/usb.c Wed Jan 2 16:16:51 2002 +++ b/drivers/usb/usb.c Wed Jan 2 16:16:51 2002 @@ -150,9 +150,13 @@ struct usb_interface *interface = &dev->actconfig->interface[i]; if (interface->driver == driver) { + if (driver->owner) + __MOD_INC_USE_COUNT(driver->owner); down(&driver->serialize); driver->disconnect(dev, interface->private_data); up(&driver->serialize); + if (driver->owner) + __MOD_DEC_USE_COUNT(driver->owner); /* if driver->disconnect didn't release the interface */ if (interface->driver) usb_driver_release_interface(driver, interface); @@ -781,6 +785,8 @@ driver = list_entry(tmp, struct usb_driver, driver_list); tmp = tmp->next; + if (driver->owner) + __MOD_INC_USE_COUNT(driver->owner); id = driver->id_table; /* new style driver? */ if (id) { @@ -804,6 +810,8 @@ private = driver->probe(dev, ifnum, NULL); up(&driver->serialize); } + if (driver->owner) + __MOD_DEC_USE_COUNT(driver->owner); /* probe() may have changed the config on us */ interface = dev->actconfig->interface + ifnum; @@ -1887,9 +1895,13 @@ struct usb_interface *interface = &dev->actconfig->interface[i]; struct usb_driver *driver = interface->driver; if (driver) { + if (driver->owner) + __MOD_INC_USE_COUNT(driver->owner); down(&driver->serialize); driver->disconnect(dev, interface->private_data); up(&driver->serialize); + if (driver->owner) + __MOD_DEC_USE_COUNT(driver->owner); /* if driver->disconnect didn't release the interface */ if (interface->driver) usb_driver_release_interface(driver, interface); diff -Nru a/include/linux/usb.h b/include/linux/usb.h --- a/include/linux/usb.h Wed Jan 2 16:16:51 2002 +++ b/include/linux/usb.h Wed Jan 2 16:16:51 2002 @@ -502,6 +502,7 @@ * well as cancel any I/O requests that are still pending. */ struct usb_driver { + struct module *owner; const char *name; void *(*probe)( _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel