diff options
author | Bjørn Mork <bjorn@mork.no> | 2012-05-13 12:35:00 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-05-14 09:30:40 -0700 |
commit | ef206f3f01d8cc0d363cfce7dc9ca11db429faa3 (patch) | |
tree | f5767b00bf7c34ea96a1450e27b2a8dda68760d9 | |
parent | e6bbcef0211ed75db1ca3017551a584aed4e00be (diff) | |
download | linux-3.10-ef206f3f01d8cc0d363cfce7dc9ca11db429faa3.tar.gz linux-3.10-ef206f3f01d8cc0d363cfce7dc9ca11db429faa3.tar.bz2 linux-3.10-ef206f3f01d8cc0d363cfce7dc9ca11db429faa3.zip |
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 69919b25777..f6f81c85c5c 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, } EXPORT_SYMBOL_GPL(usb_store_new_id); -static ssize_t show_dynids(struct device_driver *driver, char *buf) +ssize_t usb_show_dynids(struct usb_dynids *dynids, char *buf) { struct usb_dynid *dynid; - struct usb_driver *usb_drv = to_usb_driver(driver); size_t count = 0; - list_for_each_entry(dynid, &usb_drv->dynids.list, node) + list_for_each_entry(dynid, &dynids->list, node) if (dynid->id.bInterfaceClass != 0) count += scnprintf(&buf[count], PAGE_SIZE - count, "%04x %04x %02x\n", dynid->id.idVendor, dynid->id.idProduct, @@ -95,6 +94,14 @@ static ssize_t show_dynids(struct device_driver *driver, char *buf) dynid->id.idVendor, dynid->id.idProduct); return count; } +EXPORT_SYMBOL_GPL(usb_show_dynids); + +static ssize_t show_dynids(struct device_driver *driver, char *buf) +{ + struct usb_driver *usb_drv = to_usb_driver(driver); + + return usb_show_dynids(&usb_drv->dynids, buf); +} static ssize_t store_new_id(struct device_driver *driver, const char *buf, size_t count) diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c index ed8adb052ca..f398d1e3447 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, return retval; } +static ssize_t show_dynids(struct device_driver *driver, char *buf) +{ + struct usb_serial_driver *usb_drv = to_usb_serial_driver(driver); + + return usb_show_dynids(&usb_drv->dynids, buf); +} + static struct driver_attribute drv_attrs[] = { - __ATTR(new_id, S_IWUSR, NULL, store_new_id), + __ATTR(new_id, S_IRUGO | S_IWUSR, show_dynids, store_new_id), __ATTR_NULL, }; diff --git a/include/linux/usb.h b/include/linux/usb.h index 5483cd70390..14933451d21 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, struct device_driver *driver, const char *buf, size_t count); +extern ssize_t usb_show_dynids(struct usb_dynids *dynids, char *buf); + /** * struct usbdrv_wrap - wrapper for driver-model structure * @driver: The driver-model core driver structure. |