usbcore: add usb_device_driver definition
This patch (as732) adds a usb_device_driver structure, for representing drivers that manage an entire USB device as opposed to just an interface. Support routines like usb_register_device_driver, usb_deregister_device_driver, usb_probe_device, and usb_unbind_device are also added. Unlike an earlier version of this patch, the new code is type-safe. To accomplish this, the existing struct driver embedded in struct usb_driver had to be wrapped in an intermediate wrapper. This enables the core to tell at runtime whether a particular struct driver belongs to a device driver or to an interface driver. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
36e56a3458
commit
8bb54ab573
5 changed files with 245 additions and 84 deletions
|
@ -34,8 +34,24 @@ extern int usb_port_suspend(struct usb_device *dev);
|
|||
extern int usb_port_resume(struct usb_device *dev);
|
||||
|
||||
extern struct bus_type usb_bus_type;
|
||||
extern struct device_driver usb_generic_driver;
|
||||
extern int usb_generic_driver_data;
|
||||
extern struct usb_device_driver usb_generic_driver;
|
||||
|
||||
/* Here's how we tell apart devices and interfaces. Luckily there's
|
||||
* no such thing as a platform USB device, so we can steal the use
|
||||
* of the platform_data field. */
|
||||
|
||||
static inline int is_usb_device(struct device *dev)
|
||||
{
|
||||
return dev->platform_data == &usb_generic_driver;
|
||||
}
|
||||
|
||||
/* Do the same for device drivers and interface drivers. */
|
||||
|
||||
static inline int is_usb_device_driver(struct device_driver *drv)
|
||||
{
|
||||
return container_of(drv, struct usbdrv_wrap, driver)->
|
||||
for_devices;
|
||||
}
|
||||
|
||||
/* Interfaces and their "power state" are owned by usbcore */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue