/** * bi_device_feature - handle set/clear feature requests * @device: device * @endpoint: endpoint to check * @flag: set or clear * * Used by the USB Device Core to check endpoint halt status. */ int bi_device_feature (struct usb_device_instance *device, int endpoint_address, int flag) { int ep = 0; struct usb_endpoint_instance *endpoint = NULL; dbg_ep0 (0, "endpoint: %d flag: %d", endpoint_address, flag); if (device && device->bus && device->bus->endpoint_array) { endpoint = device->bus->endpoint_array; for (ep = 0; ep < udc_max_endpoints (); ep++) { if (endpoint->endpoint_address == endpoint_address) break; endpoint++; } if (ep == udc_max_endpoints ()) endpoint = NULL; } if (endpoint) { dbg_ep0 (1, "endpoint: %d status: %d", ep, endpoint->status); if (flag && !endpoint->status) { dbg_ep0 (1, "stalling endpoint"); udc_stall_ep (ep); endpoint->status = 1; } else if (!flag && endpoint->status){ dbg_ep0 (1, "reseting endpoint %d", ep); udc_reset_ep (ep); endpoint->status = 0; } return 0; } dbg_ep0 (0, "endpoint: %d NOT FOUND", endpoint_address); return -EINVAL; }
/** * bi_endpoint_halted - check if endpoint halted * @device: device * @endpoint: endpoint to check * * Used by the USB Device Core to check endpoint halt status. */ int bi_endpoint_halted (struct usb_device_instance *device, int endpoint_address) { struct usb_endpoint_instance *endpoint; if ((endpoint = bi_find_endpoint(device, endpoint_address))) { dbg_ep0 (1, "endpoint: %d status: %d", endpoint_address, endpoint->status); return endpoint->status; } dbg_ep0 (0, "endpoint: %02x NOT FOUND", endpoint_address); return 0; }
/** * bi_device_feature - handle set/clear feature requests * @device: device * @endpoint: endpoint to check * @flag: set or clear * * Used by the USB Device Core to check endpoint halt status. */ int bi_device_feature(struct usb_device_instance *device, int endpoint, int flag) { if (flag) { dbg_ep0(1,"stalling endpoint"); // XXX logical to physical? udc_stall_ep(endpoint, device); return 0; } dbg_ep0(1,"reseting endpoint %d", endpoint); udc_reset_ep(endpoint, device); return 0; }