aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/core/generic.c
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2006-07-01 22:08:49 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2006-09-27 14:58:50 -0400
commit8bb54ab573ecd1b4fe2ed66416a8d99a86e65316 (patch)
tree36df75387a62923e3bd152f3c2ce16147be1828c /drivers/usb/core/generic.c
parent36e56a34586783c7986ce09d39db80b27c95ce24 (diff)
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>
Diffstat (limited to 'drivers/usb/core/generic.c')
-rw-r--r--drivers/usb/core/generic.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c
index 7bab9769b34f..fa6f34a12b4b 100644
--- a/drivers/usb/core/generic.c
+++ b/drivers/usb/core/generic.c
@@ -21,14 +21,12 @@
21#include <linux/usb.h> 21#include <linux/usb.h>
22#include "usb.h" 22#include "usb.h"
23 23
24static int generic_probe(struct device *dev) 24static int generic_probe(struct usb_device *udev)
25{ 25{
26 return 0; 26 return 0;
27} 27}
28static int generic_remove(struct device *dev) 28static void generic_disconnect(struct usb_device *udev)
29{ 29{
30 struct usb_device *udev = to_usb_device(dev);
31
32 /* if this is only an unbind, not a physical disconnect, then 30 /* if this is only an unbind, not a physical disconnect, then
33 * unconfigure the device */ 31 * unconfigure the device */
34 if (udev->state == USB_STATE_CONFIGURED) 32 if (udev->state == USB_STATE_CONFIGURED)
@@ -37,17 +35,10 @@ static int generic_remove(struct device *dev)
37 /* in case the call failed or the device was suspended */ 35 /* in case the call failed or the device was suspended */
38 if (udev->state >= USB_STATE_CONFIGURED) 36 if (udev->state >= USB_STATE_CONFIGURED)
39 usb_disable_device(udev, 0); 37 usb_disable_device(udev, 0);
40 return 0;
41} 38}
42 39
43struct device_driver usb_generic_driver = { 40struct usb_device_driver usb_generic_driver = {
44 .owner = THIS_MODULE,
45 .name = "usb", 41 .name = "usb",
46 .bus = &usb_bus_type,
47 .probe = generic_probe, 42 .probe = generic_probe,
48 .remove = generic_remove, 43 .disconnect = generic_disconnect,
49}; 44};
50
51/* Fun hack to determine if the struct device is a
52 * usb device or a usb interface. */
53int usb_generic_driver_data;