ChangeSet 1.924.3.9, 2002/11/30 22:19:57-08:00, oliver@oenone.homelinux.org [PATCH] - cleanup for new module primitives diff -Nru a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c --- a/drivers/usb/core/devio.c Sun Dec 1 23:05:56 2002 +++ b/drivers/usb/core/devio.c Sun Dec 1 23:05:56 2002 @@ -860,7 +860,7 @@ if (uurb.buffer_length > 16384) return -EINVAL; if (!access_ok((uurb.endpoint & USB_DIR_IN) ? VERIFY_WRITE : VERIFY_READ, uurb.buffer, uurb.buffer_length)) - return -EFAULT; + return -EFAULT; break; default: @@ -955,10 +955,10 @@ if (!(usb_pipeisoc(urb->pipe))) return 0; for (i = 0; i < urb->number_of_packets; i++) { - if (put_user(urb->iso_frame_desc[i].actual_length, + if (put_user(urb->iso_frame_desc[i].actual_length, &((struct usbdevfs_urb *)as->userurb)->iso_frame_desc[i].actual_length)) return -EFAULT; - if (put_user(urb->iso_frame_desc[i].status, + if (put_user(urb->iso_frame_desc[i].status, &((struct usbdevfs_urb *)as->userurb)->iso_frame_desc[i].status)) return -EFAULT; } @@ -1122,18 +1122,16 @@ unlock_kernel(); retval = -ENOSYS; } else { - if (driver->owner - && !try_inc_mod_count (driver->owner)) { + if (!try_module_get (driver->owner)) { unlock_kernel(); retval = -ENOSYS; break; } unlock_kernel (); retval = driver->ioctl (ifp, ctrl.ioctl_code, buf); - if (driver->owner) - __MOD_DEC_USE_COUNT (driver->owner); + put_module (driver->owner); } - + if (retval == -ENOIOCTLCMD) retval = -ENOTTY; } @@ -1188,7 +1186,7 @@ case USBDEVFS_RESET: ret = proc_resetdevice(ps); break; - + case USBDEVFS_CLEAR_HALT: ret = proc_clearhalt(ps, (void *)arg); if (ret >= 0) diff -Nru a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c --- a/drivers/usb/core/usb.c Sun Dec 1 23:05:56 2002 +++ b/drivers/usb/core/usb.c Sun Dec 1 23:05:56 2002 @@ -69,7 +69,8 @@ .probe = generic_probe, .remove = generic_remove, }; - + +/* needs to be called with BKL held */ int usb_device_probe(struct device *dev) { struct usb_interface * intf = to_usb_interface(dev); @@ -83,11 +84,8 @@ if (!driver->probe) return error; - if (driver->owner) { - m = try_inc_mod_count(driver->owner); - if (m == 0) - return error; - } + if (!try_module_get(driver->owner)) + return error; id = usb_match_id (intf, driver->id_table); if (id) { @@ -99,8 +97,7 @@ if (!error) intf->driver = driver; - if (driver->owner) - __MOD_DEC_USE_COUNT(driver->owner); + put_module(driver->owner); return error; } @@ -120,14 +117,12 @@ return -ENODEV; } - if (driver->owner) { - m = try_inc_mod_count(driver->owner); - if (m == 0) { - // FIXME this happens even when we just rmmod - // drivers that aren't in active use... - err("Dieing driver still bound to device.\n"); - return -EIO; - } + m = try_module_get(driver->owner); + if (m == 0) { + // FIXME this happens even when we just rmmod + // drivers that aren't in active use... + err("Dieing driver still bound to device.\n"); + return -EIO; } /* if we sleep here on an umanaged driver @@ -143,8 +138,7 @@ usb_driver_release_interface(driver, intf); up(&driver->serialize); - if (driver->owner) - __MOD_DEC_USE_COUNT(driver->owner); + module_put(driver->owner) return 0; }