diff options
| author | Linus Torvalds <torvalds@penguin.transmeta.com> | 2002-04-08 20:47:59 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@penguin.transmeta.com> | 2002-04-08 20:47:59 -0700 |
| commit | 6e16d892a8875baa492199f2d4e08ce47917ee15 (patch) | |
| tree | 87939235cb4ccb3aac1f57142d8aa161eb1632f7 /include | |
| parent | 4d40f872ad2c75a81618cc7bfde18e92d24a4ead (diff) | |
| parent | 0083ab86cb3b8a7b044fbeea4cea6ebdf1bdab30 (diff) | |
Merge home:v2.5/linux
into penguin.transmeta.com:/home/penguin/torvalds/repositories/kernel/linux
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/usb.h | 74 | ||||
| -rw-r--r-- | include/linux/usbdevice_fs.h | 2 |
2 files changed, 52 insertions, 24 deletions
diff --git a/include/linux/usb.h b/include/linux/usb.h index 3b5c1df0ba46..9849c917c9ac 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -305,6 +305,7 @@ struct usb_qualifier_descriptor { } __attribute__ ((packed)); /* helpers for driver access to descriptors */ +extern int usb_ifnum_to_ifpos(struct usb_device *dev, unsigned ifnum); extern struct usb_interface * usb_ifnum_to_if(struct usb_device *dev, unsigned ifnum); extern struct usb_endpoint_descriptor * @@ -470,8 +471,10 @@ struct usb_device_id { /** * struct usb_driver - identifies USB driver to usbcore - * @owner: pointer to the module owner of this driver - * @name: The driver name should be unique among USB drivers + * @owner: Pointer to the module owner of this driver; initialize + * it using THIS_MODULE. + * @name: The driver name should be unique among USB drivers, + * and should normally be the same as the module name. * @probe: Called to see if the driver is willing to manage a particular * interface on a device. The probe routine returns a handle that * will later be provided to disconnect(), or a null pointer to @@ -506,7 +509,7 @@ struct usb_device_id { * is used by both user and kernel mode hotplugging support. * * The probe() and disconnect() methods are called in a context where - * they can sleep, but they should avoid abusing the privilage. Most + * they can sleep, but they should avoid abusing the privilege. Most * work to connect to a device should be done when the device is opened, * and undone at the last close. The disconnect code needs to address * concurrency issues with respect to open() and close() methods, as @@ -961,24 +964,6 @@ struct usb_tt { /* -------------------------------------------------------------------------- */ -/* Enumeration is only for the hub driver, or HCD virtual root hubs */ -extern struct usb_device *usb_alloc_dev(struct usb_device *parent, - struct usb_bus *); -extern void usb_free_dev(struct usb_device *); -extern int usb_new_device(struct usb_device *dev); -extern void usb_connect(struct usb_device *dev); -extern void usb_disconnect(struct usb_device **); - -#ifndef _LINUX_HUB_H -/* exported to hub driver ONLY to support usb_reset_device () */ -extern int usb_get_configuration(struct usb_device *dev); -extern void usb_set_maxpacket(struct usb_device *dev); -extern void usb_destroy_configuration(struct usb_device *dev); -extern int usb_set_address(struct usb_device *dev); -#endif /* _LINUX_HUB_H */ - -/* -------------------------------------------------------------------------- */ - /* This is arbitrary. * From USB 2.0 spec Table 11-13, offset 7, a hub can * have up to 255 ports. The most yet reported is 10. @@ -1047,11 +1032,52 @@ extern int usb_reset_device(struct usb_device *dev); /* for drivers using iso endpoints */ extern int usb_get_current_frame_number (struct usb_device *usb_dev); -/* drivers must track when they bind to a device's interfaces */ -extern void usb_inc_dev_use(struct usb_device *); -#define usb_dec_dev_use usb_free_dev +/** + * usb_inc_dev_use - record another reference to a device + * @dev: the device being referenced + * + * Each live reference to a device should be refcounted. + * + * Drivers for USB interfaces should normally record such references in + * their probe() methods, when they bind to an interface, and release + * them usb_dec_dev_use(), in their disconnect() methods. + */ +static inline void usb_inc_dev_use (struct usb_device *dev) +{ + atomic_inc (&dev->refcnt); +} + +/** + * usb_dec_dev_use - drop a reference to a device + * @dev: the device no longer being referenced + * + * Each live reference to a device should be refcounted. + * + * Drivers for USB interfaces should normally release such references in + * their disconnect() methods, and record them in probe(). + * + * Note that driver disconnect() methods must guarantee that when they + * return, all of their outstanding references to the device (and its + * interfaces) are cleaned up. That means that all pending URBs from + * this driver must have completed, and that no more copies of the device + * handle are saved in driver records (including other kernel threads). + */ +static inline void usb_dec_dev_use (struct usb_device *dev) +{ + if (atomic_dec_and_test (&dev->refcnt)) { + /* May only go to zero when usbcore finishes + * usb_disconnect() processing: khubd or HCDs. + * + * If you hit this BUG() it's likely a problem + * with some driver's disconnect() routine. + */ + BUG (); + } +} + /* used these for multi-interface device registration */ +extern int usb_find_interface_driver_for_ifnum(struct usb_device *dev, unsigned int ifnum); extern void usb_driver_claim_interface(struct usb_driver *driver, struct usb_interface *iface, void* priv); extern int usb_interface_claimed(struct usb_interface *iface); diff --git a/include/linux/usbdevice_fs.h b/include/linux/usbdevice_fs.h index 0bf98f1d598b..10a508f55a07 100644 --- a/include/linux/usbdevice_fs.h +++ b/include/linux/usbdevice_fs.h @@ -142,6 +142,8 @@ struct usbdevfs_hub_portinfo { #define USBDEVFS_HUB_PORTINFO _IOR('U', 19, struct usbdevfs_hub_portinfo) #define USBDEVFS_RESET _IO('U', 20) #define USBDEVFS_CLEAR_HALT _IOR('U', 21, unsigned int) +#define USBDEVFS_DISCONNECT _IO('U', 22) +#define USBDEVFS_CONNECT _IO('U', 23) /* --------------------------------------------------------------------- */ |
