* [PATCH v2] usb: core: new quirk to handle devices with zero configurations
@ 2026-02-27 6:04 Jie Deng
2026-02-27 6:06 ` Greg Kroah-Hartman
0 siblings, 1 reply; 3+ messages in thread
From: Jie Deng @ 2026-02-27 6:04 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Alan Stern, linux-usb, linux-kernel, Jie Deng
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>
---
Changes in v2:
- Modify the sequence number of the quirks parameter
- Add the judgment condition of ncfg < 1
Link to v1: https://lore.kernel.org/linux-usb/
f7999b43-b6e2-44f4-b8e1-c2b5f5d04a5c@kylinos.cn/T/#mb5246d3b3e3bbb334c046bfa9a69b988f2d0688a
---
Documentation/admin-guide/kernel-parameters.txt | 3 +++
drivers/usb/core/config.c | 7 ++++++-
drivers/usb/core/quirks.c | 5 +++++
include/linux/usb/quirks.h | 3 +++
4 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index cb850e5290c2..7d907efe9f49 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -8183,6 +8183,9 @@ Kernel parameters
p = USB_QUIRK_SHORT_SET_ADDRESS_REQ_TIMEOUT
(Reduce timeout of the SET_ADDRESS
request from 5000 ms to 500 ms);
+ q = USB_QUIRK_FORCE_ONE_CONFIG (Device
+ claims zero configurations,
+ forcing to 1);
Example: quirks=0781:5580:bk,0a5c:5834:gij
usbhid.mousepoll=
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 1cd5fa61dc76..832717549515 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -927,7 +927,12 @@ int usb_get_configuration(struct usb_device *dev)
dev->descriptor.bNumConfigurations = ncfg = USB_MAXCONFIG;
}
- if (ncfg < 1) {
+ if (ncfg < 1 && dev->quirks & USB_QUIRK_FORCE_ONE_CONFIG) {
+ dev_info(ddev, "Device claims zero configurations, "
+ "forcing to 1\n");
+ dev->descriptor.bNumConfigurations = 1;
+ ncfg = 1;
+ } else if (ncfg < 1) {
dev_err(ddev, "no configurations\n");
return -EINVAL;
}
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index e347236d83e8..7bd408db05f4 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -140,6 +140,8 @@ static int quirks_param_set(const char *value, const struct kernel_param *kp)
case 'p':
flags |= USB_QUIRK_SHORT_SET_ADDRESS_REQ_TIMEOUT;
break;
+ case 'q':
+ flags |= USB_QUIRK_FORCE_ONE_CONFIG;
/* Ignore unrecognized flag characters */
}
}
@@ -589,6 +591,9 @@ static const struct usb_device_id usb_quirk_list[] = {
/* VCOM device */
{ USB_DEVICE(0x4296, 0x7570), .driver_info = USB_QUIRK_CONFIG_INTF_STRINGS },
+ /* Noji-MCS SmartCard Reader */
+ { USB_DEVICE(0x5131, 0x2007), .driver_info = USB_QUIRK_FORCE_ONE_CONFIG },
+
/* INTEL VALUE SSD */
{ USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME },
diff --git a/include/linux/usb/quirks.h b/include/linux/usb/quirks.h
index 2f7bd2fdc616..b3cc7beab4a3 100644
--- a/include/linux/usb/quirks.h
+++ b/include/linux/usb/quirks.h
@@ -78,4 +78,7 @@
/* skip BOS descriptor request */
#define USB_QUIRK_NO_BOS BIT(17)
+/* Device claims zero configurations, forcing to 1 */
+#define USB_QUIRK_FORCE_ONE_CONFIG BIT(18)
+
#endif /* __LINUX_USB_QUIRKS_H */
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] usb: core: new quirk to handle devices with zero configurations
2026-02-27 6:04 [PATCH v2] usb: core: new quirk to handle devices with zero configurations Jie Deng
@ 2026-02-27 6:06 ` Greg Kroah-Hartman
2026-02-27 8:44 ` Jie Deng
0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2026-02-27 6:06 UTC (permalink / raw)
To: Jie Deng; +Cc: Alan Stern, linux-usb, linux-kernel
On Fri, Feb 27, 2026 at 02:04:00PM +0800, Jie Deng wrote:
> 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>
> ---
>
> Changes in v2:
> - Modify the sequence number of the quirks parameter
> - Add the judgment condition of ncfg < 1
> Link to v1: https://lore.kernel.org/linux-usb/
> f7999b43-b6e2-44f4-b8e1-c2b5f5d04a5c@kylinos.cn/T/#mb5246d3b3e3bbb334c046bfa9a69b988f2d0688a
> ---
> Documentation/admin-guide/kernel-parameters.txt | 3 +++
> drivers/usb/core/config.c | 7 ++++++-
> drivers/usb/core/quirks.c | 5 +++++
> include/linux/usb/quirks.h | 3 +++
> 4 files changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index cb850e5290c2..7d907efe9f49 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -8183,6 +8183,9 @@ Kernel parameters
> p = USB_QUIRK_SHORT_SET_ADDRESS_REQ_TIMEOUT
> (Reduce timeout of the SET_ADDRESS
> request from 5000 ms to 500 ms);
> + q = USB_QUIRK_FORCE_ONE_CONFIG (Device
> + claims zero configurations,
> + forcing to 1);
> Example: quirks=0781:5580:bk,0a5c:5834:gij
>
> usbhid.mousepoll=
> diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
> index 1cd5fa61dc76..832717549515 100644
> --- a/drivers/usb/core/config.c
> +++ b/drivers/usb/core/config.c
> @@ -927,7 +927,12 @@ int usb_get_configuration(struct usb_device *dev)
> dev->descriptor.bNumConfigurations = ncfg = USB_MAXCONFIG;
> }
>
> - if (ncfg < 1) {
> + if (ncfg < 1 && dev->quirks & USB_QUIRK_FORCE_ONE_CONFIG) {
> + dev_info(ddev, "Device claims zero configurations, "
> + "forcing to 1\n");
Do not break a string like this, make it all one line please.
checkpatch should have warned you about this?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] usb: core: new quirk to handle devices with zero configurations
2026-02-27 6:06 ` Greg Kroah-Hartman
@ 2026-02-27 8:44 ` Jie Deng
0 siblings, 0 replies; 3+ messages in thread
From: Jie Deng @ 2026-02-27 8:44 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Alan Stern, linux-usb, linux-kernel
在 2026/2/27 14:06, Greg Kroah-Hartman 写道:
> On Fri, Feb 27, 2026 at 02:04:00PM +0800, Jie Deng wrote:
>> diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
>> index 1cd5fa61dc76..832717549515 100644
>> --- a/drivers/usb/core/config.c
>> +++ b/drivers/usb/core/config.c
>> @@ -927,7 +927,12 @@ int usb_get_configuration(struct usb_device *dev)
>> dev->descriptor.bNumConfigurations = ncfg = USB_MAXCONFIG;
>> }
>>
>> - if (ncfg < 1) {
>> + if (ncfg < 1 && dev->quirks & USB_QUIRK_FORCE_ONE_CONFIG) {
>> + dev_info(ddev, "Device claims zero configurations, "
>> + "forcing to 1\n");
> Do not break a string like this, make it all one line please.
> checkpatch should have warned you about this?
>
> thanks,
>
> greg k-h
Thank you for your reply. I will make the necessary revisions and submit
the updated patch.
Jie Deng
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-02-27 8:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-27 6:04 [PATCH v2] usb: core: new quirk to handle devices with zero configurations Jie Deng
2026-02-27 6:06 ` Greg Kroah-Hartman
2026-02-27 8:44 ` Jie Deng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox