aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/core
diff options
context:
space:
mode:
authorBjørn Mork <bjorn@mork.no>2012-05-13 06:34:59 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-05-14 12:30:40 -0400
commite6bbcef0211ed75db1ca3017551a584aed4e00be (patch)
tree67143d849f6338e2398fad06b2ca9a97534608da /drivers/usb/core
parent581791f5c7a480b2cc3431af9a6e799ffd51eb5e (diff)
USB: let both new_id and remove_id show dynamic id list
This enables the current list of dynamic IDs to be read out through either new_id or remove_id. Signed-off-by: Bjørn Mork <bjorn@mork.no> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/core')
-rw-r--r--drivers/usb/core/driver.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 112a7ae5095c..69919b257775 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -79,6 +79,23 @@ ssize_t usb_store_new_id(struct usb_dynids *dynids,
79} 79}
80EXPORT_SYMBOL_GPL(usb_store_new_id); 80EXPORT_SYMBOL_GPL(usb_store_new_id);
81 81
82static ssize_t show_dynids(struct device_driver *driver, char *buf)
83{
84 struct usb_dynid *dynid;
85 struct usb_driver *usb_drv = to_usb_driver(driver);
86 size_t count = 0;
87
88 list_for_each_entry(dynid, &usb_drv->dynids.list, node)
89 if (dynid->id.bInterfaceClass != 0)
90 count += scnprintf(&buf[count], PAGE_SIZE - count, "%04x %04x %02x\n",
91 dynid->id.idVendor, dynid->id.idProduct,
92 dynid->id.bInterfaceClass);
93 else
94 count += scnprintf(&buf[count], PAGE_SIZE - count, "%04x %04x\n",
95 dynid->id.idVendor, dynid->id.idProduct);
96 return count;
97}
98
82static ssize_t store_new_id(struct device_driver *driver, 99static ssize_t store_new_id(struct device_driver *driver,
83 const char *buf, size_t count) 100 const char *buf, size_t count)
84{ 101{
@@ -86,7 +103,7 @@ static ssize_t store_new_id(struct device_driver *driver,
86 103
87 return usb_store_new_id(&usb_drv->dynids, driver, buf, count); 104 return usb_store_new_id(&usb_drv->dynids, driver, buf, count);
88} 105}
89static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id); 106static DRIVER_ATTR(new_id, S_IRUGO | S_IWUSR, show_dynids, store_new_id);
90 107
91/** 108/**
92 * store_remove_id - remove a USB device ID from this driver 109 * store_remove_id - remove a USB device ID from this driver
@@ -127,7 +144,7 @@ store_remove_id(struct device_driver *driver, const char *buf, size_t count)
127 return retval; 144 return retval;
128 return count; 145 return count;
129} 146}
130static DRIVER_ATTR(remove_id, S_IWUSR, NULL, store_remove_id); 147static DRIVER_ATTR(remove_id, S_IRUGO | S_IWUSR, show_dynids, store_remove_id);
131 148
132static int usb_create_newid_files(struct usb_driver *usb_drv) 149static int usb_create_newid_files(struct usb_driver *usb_drv)
133{ 150{