diff options
| author | Alan Stern <stern@rowland.harvard.edu> | 2004-09-13 20:33:44 -0700 |
|---|---|---|
| committer | Greg Kroah-Hartman <greg@kroah.com> | 2004-09-13 20:33:44 -0700 |
| commit | 11c763cc105faf3f3148fa209b87ded8bb1fa07e (patch) | |
| tree | e15b3b9c5c483539e2a0a2014a20ec7955cf58e4 /include/linux/usb.h | |
| parent | fa4b40f4ef571816068e6d08b174d0a5c713ad36 (diff) | |
[PATCH] USB: Updated USB device locking
This patch reintroduces the USB device locking code we tried out
earlier. As before, it solves the problem of effectively locking all
the devices while drivers are registered and unregistered by introducing
an rwsem. Unlike the earlier attempt, this version does not ever try to
acquire a lock re-entrantly. I trust that will eliminate the races and
hang-ups you observed with the earlier version. There are also copious
comments explaining exactly how things should work.
The patch interacts slightly with the locktree() code introduced by
David for suspend/resume support. It doesn't change the functionality
at all; it just updates the routine to follow the new locking rules.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Diffstat (limited to 'include/linux/usb.h')
| -rw-r--r-- | include/linux/usb.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/linux/usb.h b/include/linux/usb.h index d07d5aba9e7f..67a8d7bce43b 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -281,6 +281,14 @@ struct usb_bus { struct usb_tt; +/* + * struct usb_device - kernel's representation of a USB device + * + * FIXME: Write the kerneldoc! + * + * Usbcore drivers should not set usbdev->state directly. Instead use + * usb_set_device_state(). + */ struct usb_device { int devnum; /* Address on USB bus */ char devpath [16]; /* Use in messages: /port/port/... */ @@ -331,6 +339,10 @@ struct usb_device { extern struct usb_device *usb_get_dev(struct usb_device *dev); extern void usb_put_dev(struct usb_device *dev); +extern void usb_lock_device(struct usb_device *udev); +extern int usb_trylock_device(struct usb_device *udev); +extern void usb_unlock_device(struct usb_device *udev); + /* mostly for devices emulating SCSI over USB */ extern int usb_reset_device(struct usb_device *dev); extern int __usb_reset_device(struct usb_device *dev); |
