diff options
author | Bjørn Mork <bjorn@mork.no> | 2012-05-13 06:35:00 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-05-14 12:30:40 -0400 |
commit | ef206f3f01d8cc0d363cfce7dc9ca11db429faa3 (patch) | |
tree | f5767b00bf7c34ea96a1450e27b2a8dda68760d9 | |
parent | e6bbcef0211ed75db1ca3017551a584aed4e00be (diff) |
USB: add read support to usb-serial/../new_id
Keep the usb-serial support for dynamic IDs in sync with the usb
support. This enables readout of dynamic device IDs for
usb-serial drivers. Common code is exported from the usb core
system and reused by the usb-serial bus driver.
Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/usb/core/driver.c | 13 | ||||
-rw-r--r-- | drivers/usb/serial/bus.c | 9 | ||||
-rw-r--r-- | include/linux/usb.h | 2 |
3 files changed, 20 insertions, 4 deletions
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index 69919b257775..f6f81c85c5cf 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c | |||
@@ -79,13 +79,12 @@ ssize_t usb_store_new_id(struct usb_dynids *dynids, | |||
79 | } | 79 | } |
80 | EXPORT_SYMBOL_GPL(usb_store_new_id); | 80 | EXPORT_SYMBOL_GPL(usb_store_new_id); |
81 | 81 | ||
82 | static ssize_t show_dynids(struct device_driver *driver, char *buf) | 82 | ssize_t usb_show_dynids(struct usb_dynids *dynids, char *buf) |
83 | { | 83 | { |
84 | struct usb_dynid *dynid; | 84 | struct usb_dynid *dynid; |
85 | struct usb_driver *usb_drv = to_usb_driver(driver); | ||
86 | size_t count = 0; | 85 | size_t count = 0; |
87 | 86 | ||
88 | list_for_each_entry(dynid, &usb_drv->dynids.list, node) | 87 | list_for_each_entry(dynid, &dynids->list, node) |
89 | if (dynid->id.bInterfaceClass != 0) | 88 | if (dynid->id.bInterfaceClass != 0) |
90 | count += scnprintf(&buf[count], PAGE_SIZE - count, "%04x %04x %02x\n", | 89 | count += scnprintf(&buf[count], PAGE_SIZE - count, "%04x %04x %02x\n", |
91 | dynid->id.idVendor, dynid->id.idProduct, | 90 | dynid->id.idVendor, dynid->id.idProduct, |
@@ -95,6 +94,14 @@ static ssize_t show_dynids(struct device_driver *driver, char *buf) | |||
95 | dynid->id.idVendor, dynid->id.idProduct); | 94 | dynid->id.idVendor, dynid->id.idProduct); |
96 | return count; | 95 | return count; |
97 | } | 96 | } |
97 | EXPORT_SYMBOL_GPL(usb_show_dynids); | ||
98 | |||
99 | static ssize_t show_dynids(struct device_driver *driver, char *buf) | ||
100 | { | ||
101 | struct usb_driver *usb_drv = to_usb_driver(driver); | ||
102 | |||
103 | return usb_show_dynids(&usb_drv->dynids, buf); | ||
104 | } | ||
98 | 105 | ||
99 | static ssize_t store_new_id(struct device_driver *driver, | 106 | static ssize_t store_new_id(struct device_driver *driver, |
100 | const char *buf, size_t count) | 107 | const char *buf, size_t count) |
diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c index ed8adb052ca7..f398d1e34474 100644 --- a/drivers/usb/serial/bus.c +++ b/drivers/usb/serial/bus.c | |||
@@ -124,8 +124,15 @@ static ssize_t store_new_id(struct device_driver *driver, | |||
124 | return retval; | 124 | return retval; |
125 | } | 125 | } |
126 | 126 | ||
127 | static ssize_t show_dynids(struct device_driver *driver, char *buf) | ||
128 | { | ||
129 | struct usb_serial_driver *usb_drv = to_usb_serial_driver(driver); | ||
130 | |||
131 | return usb_show_dynids(&usb_drv->dynids, buf); | ||
132 | } | ||
133 | |||
127 | static struct driver_attribute drv_attrs[] = { | 134 | static struct driver_attribute drv_attrs[] = { |
128 | __ATTR(new_id, S_IWUSR, NULL, store_new_id), | 135 | __ATTR(new_id, S_IRUGO | S_IWUSR, show_dynids, store_new_id), |
129 | __ATTR_NULL, | 136 | __ATTR_NULL, |
130 | }; | 137 | }; |
131 | 138 | ||
diff --git a/include/linux/usb.h b/include/linux/usb.h index 5483cd70390b..14933451d21d 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h | |||
@@ -790,6 +790,8 @@ extern ssize_t usb_store_new_id(struct usb_dynids *dynids, | |||
790 | struct device_driver *driver, | 790 | struct device_driver *driver, |
791 | const char *buf, size_t count); | 791 | const char *buf, size_t count); |
792 | 792 | ||
793 | extern ssize_t usb_show_dynids(struct usb_dynids *dynids, char *buf); | ||
794 | |||
793 | /** | 795 | /** |
794 | * struct usbdrv_wrap - wrapper for driver-model structure | 796 | * struct usbdrv_wrap - wrapper for driver-model structure |
795 | * @driver: The driver-model core driver structure. | 797 | * @driver: The driver-model core driver structure. |