FreeBSD/sys/dev/usb/usb_handle_request.c
/*------------------------------------------------------------------------*
 *	usb_handle_request_callback
 *
 * This function is the USB callback for generic USB Device control
 * transfers.
 *------------------------------------------------------------------------*/
usb_handle_request_callback
This function is the USB callback for generic USB Device control
transfers.
usb_handle_request_callback This function is the USB callback for generic USB Device control transfers .
void
usb_handle_request_callback(struct usb_xfer *xfer, usb_error_t error)
{
	usb_error_t err;
	switch (USB_GET_STATE(xfer)) {
	case USB_ST_SETUP:
	case USB_ST_TRANSFERRED:
		err = usb_handle_request(xfer);
		if (err) {
			if (err == USB_ERR_BAD_CONTEXT) {
				usb_needs_explore(xfer->xroot->bus, 0);
				break;
			}
			goto tr_restart;
		}
		usbd_transfer_submit(xfer);
		break;
	default:
		if (xfer->flags_int.control_rem != 0xFFFF) {
			err = usb_handle_request(xfer);
		}
		if (xfer->error != USB_ERR_CANCELLED) {
			goto tr_restart;
		}
		break;
	}
	return;
tr_restart:
	usbd_xfer_set_frame_len(xfer, 0, sizeof(struct usb_device_request));
	xfer->nframes = 1;
	xfer->flags.manual_status = 1;
	xfer->flags.force_short_xfer = 0;
	usbd_xfer_set_stall(xfer);	
	usbd_transfer_submit(xfer);
}
void usb_handle_request_callback ( struct usb_xfer * xfer , usb_error_t error ) { usb_error_t err ; switch ( USB_GET_STATE ( xfer ) ) { case USB_ST_SETUP : case USB_ST_TRANSFERRED : err = usb_handle_request ( xfer ) ; if ( err ) { if ( err == USB_ERR_BAD_CONTEXT ) { usb_needs_explore ( xfer -> xroot -> bus , 0 ) ; break ; } goto tr_restart ; } usbd_transfer_submit ( xfer ) ; break ; default : if ( xfer -> flags_int . control_rem != 0xFFFF ) { err = usb_handle_request ( xfer ) ; } if ( xfer -> error != USB_ERR_CANCELLED ) { goto tr_restart ; } break ; } return ; tr_restart : usbd_xfer_set_frame_len ( xfer , 0 , sizeof ( struct usb_device_request ) ) ; xfer -> nframes = 1 ; xfer -> flags . manual_status = 1 ; xfer -> flags . force_short_xfer = 0 ; usbd_xfer_set_stall ( xfer ) ; usbd_transfer_submit ( xfer ) ; }
usb_handle_request_callback
 This function is the USB callback for generic USB Device control
 transfers.
usb_handle_request_callback This function is the USB callback for generic USB Device control transfers .
/* check the current transfer state */ /* handle the request */ /* we need to re-setup the control transfer */ /* check if a control transfer is active */ /* handle the request */ /* should not happen - try stalling */ /*
	 * If a control transfer is active, stall it, and wait for the
	 * next control transfer.
	 */ /* cancel previous transfer, if any */