On Mon, 24 Aug 2015, Peter Chen wrote: > Thanks, that's much clear. > > At udc driver: > > __set_halt(struct usb_ep *ep, int value, bool may_fail) > { > if (may_fail && ep queue is not empty) { > return false > } else { > do stall; > return true; > } > } > > gadget_ops: > .set_halt = ep_set_halt, > > ep_set_halt(struct usb_ep *ep, int value) > { > __set_halt(ep, value, true); > } > > And call __set_halt(ep, value, false) at below conditions: > - SET(CLEAR)_FEATURE for Set(Clear)-Halt > - If ep0 request has failed Yes, that should work. In fact, when a control request fails, you could even call ep_set_halt instead of __set_halt, because the ep0 queue will certainly be empty. > Do we need to update kernel doc for usb_ep_set_halt that > say it should only for bulk and interrupt endpoints? I don't think we need to change it. The USB spec says that isochronous endpoints never stall; section 5.6.5 says: An endpoint for isochronous transfers never halts because there is no handshake to report a halt condition. Also, Figure 8-39 does not include any STALL packets. Lastly, usb_ep_set_halt should be called for ep0 when the gadget is unable to respond to a request. Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html