Skip to content

Commit 9f6a983

Browse files
Jie Denggregkh
authored andcommitted
usb: core: new quirk to handle devices with zero configurations
Some USB devices incorrectly report bNumConfigurations as 0 in their device descriptor, which causes the USB core to reject them during enumeration. logs: usb 1-2: device descriptor read/64, error -71 usb 1-2: no configurations usb 1-2: can't read configurations, error -22 However, these devices actually work correctly when treated as having a single configuration. Add a new quirk USB_QUIRK_FORCE_ONE_CONFIG to handle such devices. When this quirk is set, assume the device has 1 configuration instead of failing with -EINVAL. This quirk is applied to the device with VID:PID 5131:2007 which exhibits this behavior. Signed-off-by: Jie Deng <dengjie03@kylinos.cn> Link: https://patch.msgid.link/20260227084931.1527461-1-dengjie03@kylinos.cn Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 45dba80 commit 9f6a983

4 files changed

Lines changed: 16 additions & 1 deletion

File tree

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8183,6 +8183,9 @@ Kernel parameters
81838183
p = USB_QUIRK_SHORT_SET_ADDRESS_REQ_TIMEOUT
81848184
(Reduce timeout of the SET_ADDRESS
81858185
request from 5000 ms to 500 ms);
8186+
q = USB_QUIRK_FORCE_ONE_CONFIG (Device
8187+
claims zero configurations,
8188+
forcing to 1);
81868189
Example: quirks=0781:5580:bk,0a5c:5834:gij
81878190

81888191
usbhid.mousepoll=

drivers/usb/core/config.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,11 @@ int usb_get_configuration(struct usb_device *dev)
927927
dev->descriptor.bNumConfigurations = ncfg = USB_MAXCONFIG;
928928
}
929929

930-
if (ncfg < 1) {
930+
if (ncfg < 1 && dev->quirks & USB_QUIRK_FORCE_ONE_CONFIG) {
931+
dev_info(ddev, "Device claims zero configurations, forcing to 1\n");
932+
dev->descriptor.bNumConfigurations = 1;
933+
ncfg = 1;
934+
} else if (ncfg < 1) {
931935
dev_err(ddev, "no configurations\n");
932936
return -EINVAL;
933937
}

drivers/usb/core/quirks.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ static int quirks_param_set(const char *value, const struct kernel_param *kp)
140140
case 'p':
141141
flags |= USB_QUIRK_SHORT_SET_ADDRESS_REQ_TIMEOUT;
142142
break;
143+
case 'q':
144+
flags |= USB_QUIRK_FORCE_ONE_CONFIG;
143145
/* Ignore unrecognized flag characters */
144146
}
145147
}
@@ -589,6 +591,9 @@ static const struct usb_device_id usb_quirk_list[] = {
589591
/* VCOM device */
590592
{ USB_DEVICE(0x4296, 0x7570), .driver_info = USB_QUIRK_CONFIG_INTF_STRINGS },
591593

594+
/* Noji-MCS SmartCard Reader */
595+
{ USB_DEVICE(0x5131, 0x2007), .driver_info = USB_QUIRK_FORCE_ONE_CONFIG },
596+
592597
/* INTEL VALUE SSD */
593598
{ USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME },
594599

include/linux/usb/quirks.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,7 @@
7878
/* skip BOS descriptor request */
7979
#define USB_QUIRK_NO_BOS BIT(17)
8080

81+
/* Device claims zero configurations, forcing to 1 */
82+
#define USB_QUIRK_FORCE_ONE_CONFIG BIT(18)
83+
8184
#endif /* __LINUX_USB_QUIRKS_H */

0 commit comments

Comments
 (0)