Skip to content

Commit 08c5cd3

Browse files
AlanSterngregkh
authored andcommitted
USB: change bInterval default to 10 ms
Some full-speed mceusb infrared transceivers contain invalid endpoint descriptors for their interrupt endpoints, with bInterval set to 0. In the past they have worked out okay with the mceusb driver, because the driver sets the bInterval field in the descriptor to 1, overwriting whatever value may have been there before. However, this approach was never sanctioned by the USB core, and in fact it does not work with xHCI controllers, because they use the bInterval value that was present when the configuration was installed. Currently usbcore uses 32 ms as the default interval if the value in the endpoint descriptor is invalid. It turns out that these IR transceivers don't work properly unless the interval is set to 10 ms or below. To work around this mceusb problem, this patch changes the endpoint-descriptor parsing routine, making the default interval value be 10 ms rather than 32 ms. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Tested-by: Wade Berrier <wberrier@gmail.com> CC: <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ed3d6d0 commit 08c5cd3

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

drivers/usb/core/config.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,10 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
240240
memcpy(&endpoint->desc, d, n);
241241
INIT_LIST_HEAD(&endpoint->urb_list);
242242

243-
/* Fix up bInterval values outside the legal range. Use 32 ms if no
244-
* proper value can be guessed. */
243+
/*
244+
* Fix up bInterval values outside the legal range.
245+
* Use 10 or 8 ms if no proper value can be guessed.
246+
*/
245247
i = 0; /* i = min, j = max, n = default */
246248
j = 255;
247249
if (usb_endpoint_xfer_int(d)) {
@@ -250,13 +252,15 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
250252
case USB_SPEED_SUPER_PLUS:
251253
case USB_SPEED_SUPER:
252254
case USB_SPEED_HIGH:
253-
/* Many device manufacturers are using full-speed
255+
/*
256+
* Many device manufacturers are using full-speed
254257
* bInterval values in high-speed interrupt endpoint
255-
* descriptors. Try to fix those and fall back to a
256-
* 32 ms default value otherwise. */
258+
* descriptors. Try to fix those and fall back to an
259+
* 8-ms default value otherwise.
260+
*/
257261
n = fls(d->bInterval*8);
258262
if (n == 0)
259-
n = 9; /* 32 ms = 2^(9-1) uframes */
263+
n = 7; /* 8 ms = 2^(7-1) uframes */
260264
j = 16;
261265

262266
/*
@@ -271,21 +275,23 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
271275
}
272276
break;
273277
default: /* USB_SPEED_FULL or _LOW */
274-
/* For low-speed, 10 ms is the official minimum.
278+
/*
279+
* For low-speed, 10 ms is the official minimum.
275280
* But some "overclocked" devices might want faster
276-
* polling so we'll allow it. */
277-
n = 32;
281+
* polling so we'll allow it.
282+
*/
283+
n = 10;
278284
break;
279285
}
280286
} else if (usb_endpoint_xfer_isoc(d)) {
281287
i = 1;
282288
j = 16;
283289
switch (to_usb_device(ddev)->speed) {
284290
case USB_SPEED_HIGH:
285-
n = 9; /* 32 ms = 2^(9-1) uframes */
291+
n = 7; /* 8 ms = 2^(7-1) uframes */
286292
break;
287293
default: /* USB_SPEED_FULL */
288-
n = 6; /* 32 ms = 2^(6-1) frames */
294+
n = 4; /* 8 ms = 2^(4-1) frames */
289295
break;
290296
}
291297
}

0 commit comments

Comments
 (0)