diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2006-12-17 15:50:23 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-02-07 18:44:33 -0500 |
commit | 93bacefc4cc0b53e1cb6a336d43847154fdf6886 (patch) | |
tree | 4a82a9d2693d1165c58602a0bf4a8e5c76c541ef /drivers/usb/core/driver.c | |
parent | 495a678fc62e850d15f860d39faee07ba0a8910c (diff) |
USB serial: add dynamic id support to usb-serial core
Thanks to Johannes Hölzl <johannes.hoelzl@gmx.de> for fixing a few
things and getting it all working properly.
This adds support for dynamic usb ids to the usb serial core. The file
"new_id" will show up under the usb serial driver, not the usb driver
associated with the usb-serial driver (yeah, it can be a bit confusing
at first glance...)
This patch also modifies the USB core to allow the usb-serial core to
reuse much of the dynamic id logic.
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Johannes Hölzl <johannes.hoelzl@gmx.de>
Diffstat (limited to 'drivers/usb/core/driver.c')
-rw-r--r-- | drivers/usb/core/driver.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index d6eb5ce1dd1..0c0c03a4e03 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c | |||
@@ -28,24 +28,16 @@ | |||
28 | #include "hcd.h" | 28 | #include "hcd.h" |
29 | #include "usb.h" | 29 | #include "usb.h" |
30 | 30 | ||
31 | static int usb_match_one_id(struct usb_interface *interface, | ||
32 | const struct usb_device_id *id); | ||
33 | |||
34 | struct usb_dynid { | ||
35 | struct list_head node; | ||
36 | struct usb_device_id id; | ||
37 | }; | ||
38 | |||
39 | #ifdef CONFIG_HOTPLUG | 31 | #ifdef CONFIG_HOTPLUG |
40 | 32 | ||
41 | /* | 33 | /* |
42 | * Adds a new dynamic USBdevice ID to this driver, | 34 | * Adds a new dynamic USBdevice ID to this driver, |
43 | * and cause the driver to probe for all devices again. | 35 | * and cause the driver to probe for all devices again. |
44 | */ | 36 | */ |
45 | static ssize_t store_new_id(struct device_driver *driver, | 37 | ssize_t usb_store_new_id(struct usb_dynids *dynids, |
46 | const char *buf, size_t count) | 38 | struct device_driver *driver, |
39 | const char *buf, size_t count) | ||
47 | { | 40 | { |
48 | struct usb_driver *usb_drv = to_usb_driver(driver); | ||
49 | struct usb_dynid *dynid; | 41 | struct usb_dynid *dynid; |
50 | u32 idVendor = 0; | 42 | u32 idVendor = 0; |
51 | u32 idProduct = 0; | 43 | u32 idProduct = 0; |
@@ -65,9 +57,9 @@ static ssize_t store_new_id(struct device_driver *driver, | |||
65 | dynid->id.idProduct = idProduct; | 57 | dynid->id.idProduct = idProduct; |
66 | dynid->id.match_flags = USB_DEVICE_ID_MATCH_DEVICE; | 58 | dynid->id.match_flags = USB_DEVICE_ID_MATCH_DEVICE; |
67 | 59 | ||
68 | spin_lock(&usb_drv->dynids.lock); | 60 | spin_lock(&dynids->lock); |
69 | list_add_tail(&usb_drv->dynids.list, &dynid->node); | 61 | list_add_tail(&dynids->list, &dynid->node); |
70 | spin_unlock(&usb_drv->dynids.lock); | 62 | spin_unlock(&dynids->lock); |
71 | 63 | ||
72 | if (get_driver(driver)) { | 64 | if (get_driver(driver)) { |
73 | retval = driver_attach(driver); | 65 | retval = driver_attach(driver); |
@@ -78,6 +70,15 @@ static ssize_t store_new_id(struct device_driver *driver, | |||
78 | return retval; | 70 | return retval; |
79 | return count; | 71 | return count; |
80 | } | 72 | } |
73 | EXPORT_SYMBOL_GPL(usb_store_new_id); | ||
74 | |||
75 | static ssize_t store_new_id(struct device_driver *driver, | ||
76 | const char *buf, size_t count) | ||
77 | { | ||
78 | struct usb_driver *usb_drv = to_usb_driver(driver); | ||
79 | |||
80 | return usb_store_new_id(&usb_drv->dynids, driver, buf, count); | ||
81 | } | ||
81 | static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id); | 82 | static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id); |
82 | 83 | ||
83 | static int usb_create_newid_file(struct usb_driver *usb_drv) | 84 | static int usb_create_newid_file(struct usb_driver *usb_drv) |
@@ -365,8 +366,8 @@ void usb_driver_release_interface(struct usb_driver *driver, | |||
365 | EXPORT_SYMBOL(usb_driver_release_interface); | 366 | EXPORT_SYMBOL(usb_driver_release_interface); |
366 | 367 | ||
367 | /* returns 0 if no match, 1 if match */ | 368 | /* returns 0 if no match, 1 if match */ |
368 | static int usb_match_one_id(struct usb_interface *interface, | 369 | int usb_match_one_id(struct usb_interface *interface, |
369 | const struct usb_device_id *id) | 370 | const struct usb_device_id *id) |
370 | { | 371 | { |
371 | struct usb_host_interface *intf; | 372 | struct usb_host_interface *intf; |
372 | struct usb_device *dev; | 373 | struct usb_device *dev; |
@@ -432,6 +433,8 @@ static int usb_match_one_id(struct usb_interface *interface, | |||
432 | 433 | ||
433 | return 1; | 434 | return 1; |
434 | } | 435 | } |
436 | EXPORT_SYMBOL_GPL(usb_match_one_id); | ||
437 | |||
435 | /** | 438 | /** |
436 | * usb_match_id - find first usb_device_id matching device or interface | 439 | * usb_match_id - find first usb_device_id matching device or interface |
437 | * @interface: the interface of interest | 440 | * @interface: the interface of interest |