mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-15 04:43:53 +00:00
usb: use only usb_devinfo() in device_set_usb_desc()
device_set_usb_desc() first tries to fetch device information through the iInterface descriptor, otherwise it falls back to usb_devinfo(). Since usb_devinfo() is both guaranteed to work, and is more verbose, get rid of the initial iInterface attempt. Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Reviewed by: imp, markj Differential Revision: https://reviews.freebsd.org/D43383
This commit is contained in:
parent
ebc9b69c77
commit
45cd29412e
|
@ -73,9 +73,7 @@ device_set_usb_desc(device_t dev)
|
|||
{
|
||||
struct usb_attach_arg *uaa;
|
||||
struct usb_device *udev;
|
||||
struct usb_interface *iface;
|
||||
char *temp_p;
|
||||
usb_error_t err;
|
||||
uint8_t do_unlock;
|
||||
|
||||
if (dev == NULL) {
|
||||
|
@ -88,33 +86,11 @@ device_set_usb_desc(device_t dev)
|
|||
return;
|
||||
}
|
||||
udev = uaa->device;
|
||||
iface = uaa->iface;
|
||||
|
||||
if ((iface == NULL) ||
|
||||
(iface->idesc == NULL) ||
|
||||
(iface->idesc->iInterface == 0)) {
|
||||
err = USB_ERR_INVAL;
|
||||
} else {
|
||||
err = 0;
|
||||
}
|
||||
|
||||
/* Protect scratch area */
|
||||
do_unlock = usbd_ctrl_lock(udev);
|
||||
|
||||
temp_p = (char *)udev->scratch.data;
|
||||
|
||||
if (err == 0) {
|
||||
/* try to get the interface string ! */
|
||||
err = usbd_req_get_string_any(udev, NULL, temp_p,
|
||||
sizeof(udev->scratch.data),
|
||||
iface->idesc->iInterface);
|
||||
}
|
||||
if (err != 0) {
|
||||
/* use default description */
|
||||
usb_devinfo(udev, temp_p,
|
||||
sizeof(udev->scratch.data));
|
||||
}
|
||||
|
||||
usb_devinfo(udev, temp_p, sizeof(udev->scratch.data));
|
||||
if (do_unlock)
|
||||
usbd_ctrl_unlock(udev);
|
||||
|
||||
|
|
Loading…
Reference in a new issue