Commit 60bd3b5e authored by Oliver Neukum's avatar Oliver Neukum Committed by Greg Kroah-Hartman

[PATCH] - cleanup for new module primitives

parent 24dd2623
...@@ -1122,16 +1122,14 @@ static int proc_ioctl (struct dev_state *ps, void *arg) ...@@ -1122,16 +1122,14 @@ static int proc_ioctl (struct dev_state *ps, void *arg)
unlock_kernel(); unlock_kernel();
retval = -ENOSYS; retval = -ENOSYS;
} else { } else {
if (driver->owner if (!try_module_get (driver->owner)) {
&& !try_inc_mod_count (driver->owner)) {
unlock_kernel(); unlock_kernel();
retval = -ENOSYS; retval = -ENOSYS;
break; break;
} }
unlock_kernel (); unlock_kernel ();
retval = driver->ioctl (ifp, ctrl.ioctl_code, buf); retval = driver->ioctl (ifp, ctrl.ioctl_code, buf);
if (driver->owner) put_module (driver->owner);
__MOD_DEC_USE_COUNT (driver->owner);
} }
if (retval == -ENOIOCTLCMD) if (retval == -ENOIOCTLCMD)
......
...@@ -70,6 +70,7 @@ static struct device_driver usb_generic_driver = { ...@@ -70,6 +70,7 @@ static struct device_driver usb_generic_driver = {
.remove = generic_remove, .remove = generic_remove,
}; };
/* needs to be called with BKL held */
int usb_device_probe(struct device *dev) int usb_device_probe(struct device *dev)
{ {
struct usb_interface * intf = to_usb_interface(dev); struct usb_interface * intf = to_usb_interface(dev);
...@@ -83,11 +84,8 @@ int usb_device_probe(struct device *dev) ...@@ -83,11 +84,8 @@ int usb_device_probe(struct device *dev)
if (!driver->probe) if (!driver->probe)
return error; return error;
if (driver->owner) { if (!try_module_get(driver->owner))
m = try_inc_mod_count(driver->owner);
if (m == 0)
return error; return error;
}
id = usb_match_id (intf, driver->id_table); id = usb_match_id (intf, driver->id_table);
if (id) { if (id) {
...@@ -99,8 +97,7 @@ int usb_device_probe(struct device *dev) ...@@ -99,8 +97,7 @@ int usb_device_probe(struct device *dev)
if (!error) if (!error)
intf->driver = driver; intf->driver = driver;
if (driver->owner) put_module(driver->owner);
__MOD_DEC_USE_COUNT(driver->owner);
return error; return error;
} }
...@@ -120,15 +117,13 @@ int usb_device_remove(struct device *dev) ...@@ -120,15 +117,13 @@ int usb_device_remove(struct device *dev)
return -ENODEV; return -ENODEV;
} }
if (driver->owner) { m = try_module_get(driver->owner);
m = try_inc_mod_count(driver->owner);
if (m == 0) { if (m == 0) {
// FIXME this happens even when we just rmmod // FIXME this happens even when we just rmmod
// drivers that aren't in active use... // drivers that aren't in active use...
err("Dieing driver still bound to device.\n"); err("Dieing driver still bound to device.\n");
return -EIO; return -EIO;
} }
}
/* if we sleep here on an umanaged driver /* if we sleep here on an umanaged driver
* the holder of the lock guards against * the holder of the lock guards against
...@@ -143,8 +138,7 @@ int usb_device_remove(struct device *dev) ...@@ -143,8 +138,7 @@ int usb_device_remove(struct device *dev)
usb_driver_release_interface(driver, intf); usb_driver_release_interface(driver, intf);
up(&driver->serialize); up(&driver->serialize);
if (driver->owner) module_put(driver->owner)
__MOD_DEC_USE_COUNT(driver->owner);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment