aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--Documentation/ABI/testing/sysfs-bus-usb15
-rw-r--r--drivers/usb/core/driver.c21
2 files changed, 34 insertions, 2 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-usb b/Documentation/ABI/testing/sysfs-bus-usb
index 7c22a532fdfb..6ae9fec8e07d 100644
--- a/Documentation/ABI/testing/sysfs-bus-usb
+++ b/Documentation/ABI/testing/sysfs-bus-usb
@@ -135,6 +135,17 @@ Description:
135 for the device and attempt to bind to it. For example: 135 for the device and attempt to bind to it. For example:
136 # echo "8086 10f5" > /sys/bus/usb/drivers/foo/new_id 136 # echo "8086 10f5" > /sys/bus/usb/drivers/foo/new_id
137 137
138 Reading from this file will list all dynamically added
139 device IDs in the same format, with one entry per
140 line. For example:
141 # cat /sys/bus/usb/drivers/foo/new_id
142 8086 10f5
143 dead beef 06
144 f00d cafe
145
146 The list will be truncated at PAGE_SIZE bytes due to
147 sysfs restrictions.
148
138What: /sys/bus/usb-serial/drivers/.../new_id 149What: /sys/bus/usb-serial/drivers/.../new_id
139Date: October 2011 150Date: October 2011
140Contact: linux-usb@vger.kernel.org 151Contact: linux-usb@vger.kernel.org
@@ -157,6 +168,10 @@ Description:
157 match the driver to the device. For example: 168 match the driver to the device. For example:
158 # echo "046d c315" > /sys/bus/usb/drivers/foo/remove_id 169 # echo "046d c315" > /sys/bus/usb/drivers/foo/remove_id
159 170
171 Reading from this file will list the dynamically added
172 device IDs, exactly like reading from the entry
173 "/sys/bus/usb/drivers/.../new_id"
174
160What: /sys/bus/usb/device/.../avoid_reset_quirk 175What: /sys/bus/usb/device/.../avoid_reset_quirk
161Date: December 2009 176Date: December 2009
162Contact: Oliver Neukum <oliver@neukum.org> 177Contact: Oliver Neukum <oliver@neukum.org>
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{