]> git.hungrycats.org Git - linux/commitdiff
[PATCH] USB: define USB feature bit indices
authorDavid Brownell <david-b@pacbell.net>
Fri, 26 Mar 2004 04:31:15 +0000 (20:31 -0800)
committerGreg Kroah-Hartman <greg@kroah.com>
Fri, 26 Mar 2004 04:31:15 +0000 (20:31 -0800)
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
drivers/usb/core/message.c
drivers/usb/gadget/goku_udc.c
drivers/usb/gadget/net2280.c
drivers/usb/misc/usbtest.c
drivers/usb/storage/transport.c
include/linux/usb_ch9.h

index 798c7227936278fd5ba60a7c3896d143300e3302..57143644b3ac2813d0412c1a98620cd01363494c 100644 (file)
@@ -275,10 +275,6 @@ extern int usb_set_address(struct usb_device *dev);
 #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)
index 3af6e2108e38aef8f4fd2109183905b5d81ff712..558c974ce5c98e54c758d5a1b0c6533b22cb69a9 100644 (file)
@@ -722,7 +722,8 @@ int usb_clear_halt(struct usb_device *dev, int pipe)
         * 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 */
index f39a67c1ba5ea83f092aa09b429aa9162e103a7a..61ce5b2eea41f6e8abe4a028c29fa8560cd5a9f9 100644 (file)
@@ -1562,8 +1562,7 @@ static void ep0_setup(struct goku_udc *dev)
                                        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]);
index 9a71c7b732811158917842e6abd979ebacfaa2aa..2ae8309600bb0b82fcf0c02cc142d1c5561628b3 100644 (file)
@@ -2401,7 +2401,7 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
                        /* 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 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
                        /* 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)
index 646a7884f496b7a7b060b3bf37e027c4dc7df8b6..f7be4dc9a06c4bd01de1a64ecebc91dc6d6e7103 100644 (file)
@@ -1169,7 +1169,8 @@ static int test_halt (int ep, struct urb *urb)
 
        /* 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);
index c0c05910fafb7c79fe101ef4fe5d39f6f2888473..bb738c8d99e5614f742161d24464c039078b30dd 100644 (file)
@@ -256,8 +256,9 @@ int usb_stor_clear_halt(struct us_data *us, unsigned int pipe)
                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),
index 682e9511487001be4cb13c091645948c34a3f886..2a9e19b10c648f0f7ce911df57b7a8f4eb621660 100644 (file)
 #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