Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

xhci: dbc: allow setting product string through sysfs

Add dbc_product sysfs attribute to allow changing the product description
presented by the debug device when a host requests a string descriptor
with iProduct index.

Value can only be changed while debug capability (DbC) is in disabled
state to prevent USB device descriptor change while connected to a USB
host.

The default value is "Linux USB Debug Target".
The field length can be from 1 to 126 characters.
String is terminated at null or newline, driver does not support empty
string.

[ mn: Improve commit message and sysfs entry documentation ]

Signed-off-by: Łukasz Bartosik <ukaszb@chromium.org>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://patch.msgid.link/20260120181148.128712-4-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Łukasz Bartosik and committed by
Greg Kroah-Hartman
33d15312 412de639

+50
+14
Documentation/ABI/testing/sysfs-bus-pci-drivers-xhci_hcd
··· 100 100 connected to a USB host. 101 101 The default value is "0001". 102 102 The field length can be from 1 to 126 characters. 103 + 104 + What: /sys/bus/pci/drivers/xhci_hcd/.../dbc_product 105 + Date: January 2026 106 + Contact: Łukasz Bartosik <ukaszb@chromium.org> 107 + Description: 108 + The dbc_product attribute allows to change the product string 109 + descriptor presented by the debug device when a host requests 110 + a string descriptor with iProduct index. 111 + Index is found in the iProduct field in the device descriptor. 112 + Value can only be changed while debug capability (DbC) is in 113 + disabled state to prevent USB device descriptor change while 114 + connected to a USB host. 115 + The default value is "Linux USB Debug Target". 116 + The field length can be from 1 to 126 characters.
+36
drivers/usb/host/xhci-dbgcap.c
··· 1210 1210 return size; 1211 1211 } 1212 1212 1213 + static ssize_t dbc_product_show(struct device *dev, 1214 + struct device_attribute *attr, 1215 + char *buf) 1216 + { 1217 + struct xhci_hcd *xhci = hcd_to_xhci(dev_get_drvdata(dev)); 1218 + struct xhci_dbc *dbc = xhci->dbc; 1219 + 1220 + return sysfs_emit(buf, "%s\n", dbc->str.product); 1221 + } 1222 + 1223 + static ssize_t dbc_product_store(struct device *dev, 1224 + struct device_attribute *attr, 1225 + const char *buf, size_t size) 1226 + { 1227 + struct xhci_hcd *xhci = hcd_to_xhci(dev_get_drvdata(dev)); 1228 + struct xhci_dbc *dbc = xhci->dbc; 1229 + size_t len; 1230 + 1231 + if (dbc->state != DS_DISABLED) 1232 + return -EBUSY; 1233 + 1234 + len = strcspn(buf, "\n"); 1235 + if (!len) 1236 + return -EINVAL; 1237 + 1238 + if (len > USB_MAX_STRING_LEN) 1239 + return -E2BIG; 1240 + 1241 + memcpy(dbc->str.product, buf, len); 1242 + dbc->str.product[len] = '\0'; 1243 + 1244 + return size; 1245 + } 1246 + 1213 1247 static ssize_t dbc_serial_show(struct device *dev, 1214 1248 struct device_attribute *attr, 1215 1249 char *buf) ··· 1366 1332 static DEVICE_ATTR_RW(dbc_idProduct); 1367 1333 static DEVICE_ATTR_RW(dbc_bcdDevice); 1368 1334 static DEVICE_ATTR_RW(dbc_serial); 1335 + static DEVICE_ATTR_RW(dbc_product); 1369 1336 static DEVICE_ATTR_RW(dbc_bInterfaceProtocol); 1370 1337 static DEVICE_ATTR_RW(dbc_poll_interval_ms); 1371 1338 ··· 1376 1341 &dev_attr_dbc_idProduct.attr, 1377 1342 &dev_attr_dbc_bcdDevice.attr, 1378 1343 &dev_attr_dbc_serial.attr, 1344 + &dev_attr_dbc_product.attr, 1379 1345 &dev_attr_dbc_bInterfaceProtocol.attr, 1380 1346 &dev_attr_dbc_poll_interval_ms.attr, 1381 1347 NULL