MFNetBSD: usbdi.c (1.85), usbdi.h (1.54), usbdi_util.c (1.37)

date: 2001/11/15 15:15:59;  author: augustss;
    usbd_interface2device_handle() cannot fail.
This commit is contained in:
joe 2002-04-07 10:50:41 +00:00
parent 1d37d823cc
commit ae51d67588
3 changed files with 9 additions and 30 deletions

View File

@ -642,12 +642,11 @@ usbd_interface_count(usbd_device_handle dev, u_int8_t *count)
return (USBD_NORMAL_COMPLETION); return (USBD_NORMAL_COMPLETION);
} }
usbd_status void
usbd_interface2device_handle(usbd_interface_handle iface, usbd_interface2device_handle(usbd_interface_handle iface,
usbd_device_handle *dev) usbd_device_handle *dev)
{ {
*dev = iface->device; *dev = iface->device;
return (USBD_NORMAL_COMPLETION);
} }
usbd_status usbd_status

View File

@ -122,7 +122,7 @@ usbd_status usbd_clear_endpoint_stall_async(usbd_pipe_handle pipe);
void usbd_clear_endpoint_toggle(usbd_pipe_handle pipe); void usbd_clear_endpoint_toggle(usbd_pipe_handle pipe);
usbd_status usbd_endpoint_count(usbd_interface_handle dev, u_int8_t *count); usbd_status usbd_endpoint_count(usbd_interface_handle dev, u_int8_t *count);
usbd_status usbd_interface_count(usbd_device_handle dev, u_int8_t *count); usbd_status usbd_interface_count(usbd_device_handle dev, u_int8_t *count);
usbd_status usbd_interface2device_handle(usbd_interface_handle iface, void usbd_interface2device_handle(usbd_interface_handle iface,
usbd_device_handle *dev); usbd_device_handle *dev);
usbd_status usbd_device2interface_handle(usbd_device_handle dev, usbd_status usbd_device2interface_handle(usbd_device_handle dev,
u_int8_t ifaceno, usbd_interface_handle *iface); u_int8_t ifaceno, usbd_interface_handle *iface);

View File

@ -226,15 +226,12 @@ usbd_set_protocol(usbd_interface_handle iface, int report)
usb_interface_descriptor_t *id = usbd_get_interface_descriptor(iface); usb_interface_descriptor_t *id = usbd_get_interface_descriptor(iface);
usbd_device_handle dev; usbd_device_handle dev;
usb_device_request_t req; usb_device_request_t req;
usbd_status err;
DPRINTFN(4, ("usbd_set_protocol: iface=%p, report=%d, endpt=%d\n", DPRINTFN(4, ("usbd_set_protocol: iface=%p, report=%d, endpt=%d\n",
iface, report, id->bInterfaceNumber)); iface, report, id->bInterfaceNumber));
if (id == NULL) if (id == NULL)
return (USBD_IOERROR); return (USBD_IOERROR);
err = usbd_interface2device_handle(iface, &dev); usbd_interface2device_handle(iface, &dev);
if (err)
return (err);
req.bmRequestType = UT_WRITE_CLASS_INTERFACE; req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
req.bRequest = UR_SET_PROTOCOL; req.bRequest = UR_SET_PROTOCOL;
USETW(req.wValue, report); USETW(req.wValue, report);
@ -250,14 +247,11 @@ usbd_set_report(usbd_interface_handle iface, int type, int id, void *data,
usb_interface_descriptor_t *ifd = usbd_get_interface_descriptor(iface); usb_interface_descriptor_t *ifd = usbd_get_interface_descriptor(iface);
usbd_device_handle dev; usbd_device_handle dev;
usb_device_request_t req; usb_device_request_t req;
usbd_status err;
DPRINTFN(4, ("usbd_set_report: len=%d\n", len)); DPRINTFN(4, ("usbd_set_report: len=%d\n", len));
if (ifd == NULL) if (ifd == NULL)
return (USBD_IOERROR); return (USBD_IOERROR);
err = usbd_interface2device_handle(iface, &dev); usbd_interface2device_handle(iface, &dev);
if (err)
return (err);
req.bmRequestType = UT_WRITE_CLASS_INTERFACE; req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
req.bRequest = UR_SET_REPORT; req.bRequest = UR_SET_REPORT;
USETW2(req.wValue, type, id); USETW2(req.wValue, type, id);
@ -273,14 +267,11 @@ usbd_set_report_async(usbd_interface_handle iface, int type, int id, void *data,
usb_interface_descriptor_t *ifd = usbd_get_interface_descriptor(iface); usb_interface_descriptor_t *ifd = usbd_get_interface_descriptor(iface);
usbd_device_handle dev; usbd_device_handle dev;
usb_device_request_t req; usb_device_request_t req;
usbd_status err;
DPRINTFN(4, ("usbd_set_report_async: len=%d\n", len)); DPRINTFN(4, ("usbd_set_report_async: len=%d\n", len));
if (ifd == NULL) if (ifd == NULL)
return (USBD_IOERROR); return (USBD_IOERROR);
err = usbd_interface2device_handle(iface, &dev); usbd_interface2device_handle(iface, &dev);
if (err)
return (err);
req.bmRequestType = UT_WRITE_CLASS_INTERFACE; req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
req.bRequest = UR_SET_REPORT; req.bRequest = UR_SET_REPORT;
USETW2(req.wValue, type, id); USETW2(req.wValue, type, id);
@ -296,14 +287,11 @@ usbd_get_report(usbd_interface_handle iface, int type, int id, void *data,
usb_interface_descriptor_t *ifd = usbd_get_interface_descriptor(iface); usb_interface_descriptor_t *ifd = usbd_get_interface_descriptor(iface);
usbd_device_handle dev; usbd_device_handle dev;
usb_device_request_t req; usb_device_request_t req;
usbd_status err;
DPRINTFN(4, ("usbd_set_report: len=%d\n", len)); DPRINTFN(4, ("usbd_set_report: len=%d\n", len));
if (id == NULL) if (id == NULL)
return (USBD_IOERROR); return (USBD_IOERROR);
err = usbd_interface2device_handle(iface, &dev); usbd_interface2device_handle(iface, &dev);
if (err)
return (err);
req.bmRequestType = UT_READ_CLASS_INTERFACE; req.bmRequestType = UT_READ_CLASS_INTERFACE;
req.bRequest = UR_GET_REPORT; req.bRequest = UR_GET_REPORT;
USETW2(req.wValue, type, id); USETW2(req.wValue, type, id);
@ -318,14 +306,11 @@ usbd_set_idle(usbd_interface_handle iface, int duration, int id)
usb_interface_descriptor_t *ifd = usbd_get_interface_descriptor(iface); usb_interface_descriptor_t *ifd = usbd_get_interface_descriptor(iface);
usbd_device_handle dev; usbd_device_handle dev;
usb_device_request_t req; usb_device_request_t req;
usbd_status err;
DPRINTFN(4, ("usbd_set_idle: %d %d\n", duration, id)); DPRINTFN(4, ("usbd_set_idle: %d %d\n", duration, id));
if (ifd == NULL) if (ifd == NULL)
return (USBD_IOERROR); return (USBD_IOERROR);
err = usbd_interface2device_handle(iface, &dev); usbd_interface2device_handle(iface, &dev);
if (err)
return (err);
req.bmRequestType = UT_WRITE_CLASS_INTERFACE; req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
req.bRequest = UR_SET_IDLE; req.bRequest = UR_SET_IDLE;
USETW2(req.wValue, duration, id); USETW2(req.wValue, duration, id);
@ -356,13 +341,10 @@ usbd_get_hid_descriptor(usbd_interface_handle ifc)
usb_config_descriptor_t *cdesc; usb_config_descriptor_t *cdesc;
usb_hid_descriptor_t *hd; usb_hid_descriptor_t *hd;
char *p, *end; char *p, *end;
usbd_status err;
if (idesc == NULL) if (idesc == NULL)
return (0); return (0);
err = usbd_interface2device_handle(ifc, &dev); usbd_interface2device_handle(ifc, &dev);
if (err)
return (0);
cdesc = usbd_get_config_descriptor(dev); cdesc = usbd_get_config_descriptor(dev);
p = (char *)idesc + idesc->bLength; p = (char *)idesc + idesc->bLength;
@ -387,9 +369,7 @@ usbd_alloc_report_desc(usbd_interface_handle ifc, void **descp, int *sizep,
usbd_device_handle dev; usbd_device_handle dev;
usbd_status err; usbd_status err;
err = usbd_interface2device_handle(ifc, &dev); usbd_interface2device_handle(ifc, &dev);
if (err)
return (err);
id = usbd_get_interface_descriptor(ifc); id = usbd_get_interface_descriptor(ifc);
if (id == NULL) if (id == NULL)
return (USBD_INVAL); return (USBD_INVAL);