ChangeSet 1.1673.8.31, 2004/03/26 12:31:15-08:00, david-b@pacbell.net [PATCH] USB: define USB feature bit indices This patch provides standard symbols for the various USB device and endpoint feature bits, so that drivers can use symbolic names for them. It also changes the code relating to endpoint halts so it uses those symbols. drivers/usb/core/hcd.h | 4 ---- drivers/usb/core/message.c | 3 ++- drivers/usb/gadget/goku_udc.c | 3 +-- drivers/usb/gadget/net2280.c | 4 ++-- drivers/usb/misc/usbtest.c | 3 ++- drivers/usb/storage/transport.c | 5 +++-- include/linux/usb_ch9.h | 14 ++++++++++++++ 7 files changed, 24 insertions(+), 12 deletions(-) diff -Nru a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h --- a/drivers/usb/core/hcd.h Wed Apr 14 14:37:41 2004 +++ b/drivers/usb/core/hcd.h Wed Apr 14 14:37:41 2004 @@ -275,10 +275,6 @@ #define EndpointOutRequest \ ((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8) -/* table 9.6 standard features */ -#define DEVICE_REMOTE_WAKEUP 1 -#define ENDPOINT_HALT 0 - /* class requests from the USB 2.0 hub spec, table 11-15 */ /* GetBusState and SetHubDescriptor are optional, omitted */ #define ClearHubFeature (0x2000 | USB_REQ_CLEAR_FEATURE) diff -Nru a/drivers/usb/core/message.c b/drivers/usb/core/message.c --- a/drivers/usb/core/message.c Wed Apr 14 14:37:41 2004 +++ b/drivers/usb/core/message.c Wed Apr 14 14:37:41 2004 @@ -722,7 +722,8 @@ * this request for iso endpoints, which can't halt! */ result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, 0, endp, NULL, 0, + USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, + USB_ENDPOINT_HALT, endp, NULL, 0, HZ * USB_CTRL_SET_TIMEOUT); /* don't un-halt or force to DATA0 except on success */ diff -Nru a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c --- a/drivers/usb/gadget/goku_udc.c Wed Apr 14 14:37:41 2004 +++ b/drivers/usb/gadget/goku_udc.c Wed Apr 14 14:37:41 2004 @@ -1562,8 +1562,7 @@ if (dev->ep[tmp].is_in) goto stall; } - /* endpoint halt */ - if (ctrl.wValue != 0) + if (ctrl.wValue != USB_ENDPOINT_HALT) goto stall; if (tmp) goku_clear_halt(&dev->ep[tmp]); diff -Nru a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c --- a/drivers/usb/gadget/net2280.c Wed Apr 14 14:37:41 2004 +++ b/drivers/usb/gadget/net2280.c Wed Apr 14 14:37:41 2004 @@ -2401,7 +2401,7 @@ /* hw handles device features */ if (u.r.bRequestType != USB_RECIP_ENDPOINT) goto delegate; - if (u.r.wValue != 0 /* HALT feature */ + if (u.r.wValue != USB_ENDPOINT_HALT || u.r.wLength != 0) goto do_stall; if ((e = get_ep_by_addr (dev, u.r.wIndex)) == 0) @@ -2418,7 +2418,7 @@ /* hw handles device features */ if (u.r.bRequestType != USB_RECIP_ENDPOINT) goto delegate; - if (u.r.wValue != 0 /* HALT feature */ + if (u.r.wValue != USB_ENDPOINT_HALT || u.r.wLength != 0) goto do_stall; if ((e = get_ep_by_addr (dev, u.r.wIndex)) == 0) diff -Nru a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c --- a/drivers/usb/misc/usbtest.c Wed Apr 14 14:37:41 2004 +++ b/drivers/usb/misc/usbtest.c Wed Apr 14 14:37:41 2004 @@ -1169,7 +1169,8 @@ /* set halt (protocol test only), verify it worked */ retval = usb_control_msg (urb->dev, usb_sndctrlpipe (urb->dev, 0), - USB_REQ_SET_FEATURE, USB_RECIP_ENDPOINT, 0, ep, + USB_REQ_SET_FEATURE, USB_RECIP_ENDPOINT, + USB_ENDPOINT_HALT, ep, NULL, 0, HZ * USB_CTRL_SET_TIMEOUT); if (retval < 0) { dbg ("ep %02x couldn't set halt, %d", ep, retval); diff -Nru a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c --- a/drivers/usb/storage/transport.c Wed Apr 14 14:37:41 2004 +++ b/drivers/usb/storage/transport.c Wed Apr 14 14:37:41 2004 @@ -256,8 +256,9 @@ endp |= USB_DIR_IN; result = usb_stor_control_msg(us, us->send_ctrl_pipe, - USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, 0, - endp, NULL, 0, 3*HZ); + USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, + USB_ENDPOINT_HALT, endp, + NULL, 0, 3*HZ); /* reset the toggles and endpoint flags */ usb_endpoint_running(us->pusb_dev, usb_pipeendpoint(pipe), diff -Nru a/include/linux/usb_ch9.h b/include/linux/usb_ch9.h --- a/include/linux/usb_ch9.h Wed Apr 14 14:37:41 2004 +++ b/include/linux/usb_ch9.h Wed Apr 14 14:37:41 2004 @@ -68,6 +68,20 @@ #define USB_REQ_SET_INTERFACE 0x0B #define USB_REQ_SYNCH_FRAME 0x0C +/* + * USB feature flags are written using USB_REQ_{CLEAR,SET}_FEATURE, and + * are read as a bit array returned by USB_REQ_GET_STATUS. (So there + * are at most sixteen features of each type.) + */ +#define USB_DEVICE_SELF_POWERED 0 /* (read only) */ +#define USB_DEVICE_REMOTE_WAKEUP 1 /* dev may initiate wakeup */ +#define USB_DEVICE_TEST_MODE 2 /* (high speed only) */ +#define USB_DEVICE_B_HNP_ENABLE 3 /* dev may initiate HNP */ +#define USB_DEVICE_A_HNP_SUPPORT 4 /* RH port supports HNP */ +#define USB_DEVICE_A_ALT_HNP_SUPPORT 5 /* other RH port does */ + +#define USB_ENDPOINT_HALT 0 /* IN/OUT will STALL */ + /** * struct usb_ctrlrequest - SETUP data for a USB device control request