Date: Sun, 23 Dec 2007 09:07:16 GMT From: Hans Petter Selasky <hselasky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 131459 for review Message-ID: <200712230907.lBN97Gx8052642@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=131459 Change 131459 by hselasky@hselasky_laptop001 on 2007/12/23 09:06:44 Bugfixes and improvements for "usb_template.c". Affected files ... .. //depot/projects/usb/src/sys/dev/usb/usb_template.c#6 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb/usb_template.c#6 (text+ko) ==== @@ -672,7 +672,7 @@ dd = (void *)desc; /* get HW control endpoint 0 profile */ - (methods->get_hw_ep_profile) (ues->udev, &pf, 0); + (methods->get_hw_ep_profile) (udev, &pf, 0); if (pf == NULL) { return (USBD_INVAL); } @@ -713,6 +713,7 @@ return (USBD_INVAL); } } + return (0); /* success */ } if (desc->bDescriptorType != UDESC_CONFIG) { return (USBD_INVAL); @@ -735,6 +736,7 @@ usbd_hw_ep_get_needs(ues, UE_INTERRUPT, 0) || usbd_hw_ep_get_needs(ues, UE_CONTROL, 0) || usbd_hw_ep_get_needs(ues, UE_BULK, 0)) { + PRINTFN(-1, ("Could not get needs\n")); return (USBD_INVAL); } for (ep = ues->ep; ep != ues->ep_max; ep++) { @@ -747,6 +749,7 @@ */ if (usbd_hw_ep_find_match(ues, ep, 1) && usbd_hw_ep_find_match(ues, ep, 0)) { + PRINTFN(-1, ("Could not find match\n")); return (USBD_INVAL); } } @@ -760,6 +763,7 @@ usbd_hw_ep_get_needs(ues, UE_INTERRUPT, 1) || usbd_hw_ep_get_needs(ues, UE_CONTROL, 1) || usbd_hw_ep_get_needs(ues, UE_BULK, 1)) { + PRINTFN(-1, ("Could not update endpoint address\n")); return (USBD_INVAL); } return (0); /* success */ @@ -1002,14 +1006,16 @@ /* some error happened */ return (uts->err); } + /* sanity check */ + if (uts->size == 0) { + return (USBD_INVAL); + } /* allocate zeroed memory */ - if (uts->size > 0) { uts->buf = malloc(uts->size, M_USB, M_WAITOK | M_ZERO); if (uts->buf == NULL) { /* could not allocate memory */ return (USBD_NOMEM); } - } /* second pass */ uts->size = 0; @@ -1025,6 +1031,7 @@ /* some error happened during second pass */ goto error; } + /* * Resolve all endpoint addresses ! */ @@ -1032,19 +1039,22 @@ uts->err = usbd_hw_ep_resolve(udev, buf); if (uts->err) { PRINTFN(-1, ("Could not resolve endpoints for " - "Device Descriptor\n")); + "Device Descriptor, error = %s\n", + usbd_errstr(uts->err))); goto error; } + for (n = 0;; n++) { buf = usbd_temp_get_config_desc(udev, NULL, n); + if (buf == NULL) { + break; + } uts->err = usbd_hw_ep_resolve(udev, buf); if (uts->err) { - if (buf == NULL) { - break; - } PRINTFN(-1, ("Could not resolve endpoints for " - "Config Descriptor %u\n", n)); + "Config Descriptor %u, error = %s\n", n, + usbd_errstr(uts->err))); goto error; } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200712230907.lBN97Gx8052642>