From: Michal Pecio <michal.pecio@gmail.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Nikhil Solanke <nikhilsolanke5@gmail.com>,
linux-usb@vger.kernel.org, gregkh@linuxfoundation.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
corbet@lwn.net, skhan@linuxfoundation.org,
linux-doc@vger.kernel.org
Subject: Re: [PATCH v2] usbcore: Add quirk for 255-bytes initial config read
Date: Sun, 28 Jun 2026 19:22:03 +0200 [thread overview]
Message-ID: <20260628192203.5fb9daac.michal.pecio@gmail.com> (raw)
In-Reply-To: <20260628190201.00afdccf.michal.pecio@gmail.com>
I really think it could (and should) be a simple patch.
This is what I wrote a few weeks ago. It's an unconditional change
for all devices, but it would be easy to turn it into a quirk.
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -938,15 +938,14 @@ int usb_get_configuration(struct usb_device *dev)
if (!dev->rawdescriptors)
return -ENOMEM;
- desc = kmalloc(USB_DT_CONFIG_SIZE, GFP_KERNEL);
+ desc = kmalloc(255, GFP_KERNEL);
if (!desc)
return -ENOMEM;
for (cfgno = 0; cfgno < ncfg; cfgno++) {
- /* We grab just the first descriptor so we know how long
- * the whole configuration is */
+ /* Try 255 bytes first because that's what Windows does */
result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno,
- desc, USB_DT_CONFIG_SIZE);
+ desc, 255);
if (result < 0) {
dev_err(ddev, "unable to read config index %d "
"descriptor/%s: %d\n", cfgno, "start", result);
@@ -975,8 +974,12 @@ int usb_get_configuration(struct usb_device *dev)
if (dev->quirks & USB_QUIRK_DELAY_INIT)
msleep(200);
- result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno,
- bigbuffer, length);
+ /* Don't bother if we already have it all */
+ if (length <= result)
+ memcpy(bigbuffer, desc, length);
+ else
+ result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno,
+ bigbuffer, length);
if (result < 0) {
dev_err(ddev, "unable to read config index %d "
"descriptor/%s\n", cfgno, "all");
next prev parent reply other threads:[~2026-06-28 17:22 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-23 16:10 [PATCH v2] usbcore: Add quirk for 255-bytes initial config read Nikhil Solanke
2026-06-23 18:35 ` Randy Dunlap
2026-06-23 19:08 ` Nikhil Solanke
2026-06-23 20:24 ` Alan Stern
2026-06-23 21:14 ` Nikhil Solanke
2026-06-24 1:35 ` Alan Stern
2026-06-24 8:06 ` Nikhil Solanke
2026-06-24 14:00 ` Alan Stern
2026-06-28 6:23 ` Nikhil Solanke
2026-06-28 13:55 ` Alan Stern
2026-06-28 14:50 ` Michal Pecio
2026-06-28 15:48 ` Alan Stern
2026-06-28 17:02 ` Michal Pecio
2026-06-28 17:22 ` Michal Pecio [this message]
2026-06-28 19:18 ` Alan Stern
2026-06-28 20:41 ` Michal Pecio
2026-06-28 16:38 ` Nikhil Solanke
2026-06-28 16:31 ` Nikhil Solanke
2026-06-28 19:21 ` Alan Stern
2026-06-25 13:56 ` Greg KH
2026-06-28 21:16 ` Michal Pecio
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260628192203.5fb9daac.michal.pecio@gmail.com \
--to=michal.pecio@gmail.com \
--cc=corbet@lwn.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=nikhilsolanke5@gmail.com \
--cc=skhan@linuxfoundation.org \
--cc=stable@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox