usb: gadget: uvc: Fix coding style issues introduced by SS support
[deliverable/linux.git] / drivers / usb / gadget / f_uvc.c
index 92efd6ec48afde2333f2edf2a6000d70bbfbd098..c13b8b07c791917fb63322c4825d7c6aec031dcb 100644 (file)
@@ -79,7 +79,7 @@ static struct usb_gadget_strings *uvc_function_strings[] = {
 #define UVC_INTF_VIDEO_CONTROL                 0
 #define UVC_INTF_VIDEO_STREAMING               1
 
-#define STATUS_BYTECOUNT                       16      /* 16 bytes status */
+#define UVC_STATUS_MAX_PACKET_SIZE             16      /* 16 bytes status */
 
 static struct usb_interface_assoc_descriptor uvc_iad __initdata = {
        .bLength                = sizeof(uvc_iad),
@@ -109,7 +109,7 @@ static struct usb_endpoint_descriptor uvc_fs_control_ep __initdata = {
        .bDescriptorType        = USB_DT_ENDPOINT,
        .bEndpointAddress       = USB_DIR_IN,
        .bmAttributes           = USB_ENDPOINT_XFER_INT,
-       .wMaxPacketSize         = cpu_to_le16(STATUS_BYTECOUNT),
+       .wMaxPacketSize         = cpu_to_le16(UVC_STATUS_MAX_PACKET_SIZE),
        .bInterval              = 8,
 };
 
@@ -117,7 +117,7 @@ static struct uvc_control_endpoint_descriptor uvc_control_cs_ep __initdata = {
        .bLength                = UVC_DT_CONTROL_ENDPOINT_SIZE,
        .bDescriptorType        = USB_DT_CS_ENDPOINT,
        .bDescriptorSubType     = UVC_EP_INTERRUPT,
-       .wMaxTransferSize       = cpu_to_le16(STATUS_BYTECOUNT),
+       .wMaxTransferSize       = cpu_to_le16(UVC_STATUS_MAX_PACKET_SIZE),
 };
 
 static struct usb_interface_descriptor uvc_streaming_intf_alt0 __initdata = {
@@ -164,43 +164,43 @@ static struct usb_endpoint_descriptor uvc_hs_streaming_ep = {
 
 /* super speed support */
 static struct usb_endpoint_descriptor uvc_ss_control_ep __initdata = {
-       .bLength =              USB_DT_ENDPOINT_SIZE,
-       .bDescriptorType =      USB_DT_ENDPOINT,
+       .bLength                = USB_DT_ENDPOINT_SIZE,
+       .bDescriptorType        = USB_DT_ENDPOINT,
 
-       .bEndpointAddress =     USB_DIR_IN,
-       .bmAttributes =         USB_ENDPOINT_XFER_INT,
-       .wMaxPacketSize =       cpu_to_le16(STATUS_BYTECOUNT),
-       .bInterval =            8,
+       .bEndpointAddress       = USB_DIR_IN,
+       .bmAttributes           = USB_ENDPOINT_XFER_INT,
+       .wMaxPacketSize         = cpu_to_le16(UVC_STATUS_MAX_PACKET_SIZE),
+       .bInterval              = 8,
 };
 
 static struct usb_ss_ep_comp_descriptor uvc_ss_control_comp __initdata = {
-       .bLength =              sizeof uvc_ss_control_comp,
-       .bDescriptorType =      USB_DT_SS_ENDPOINT_COMP,
+       .bLength                = sizeof(uvc_ss_control_comp),
+       .bDescriptorType        = USB_DT_SS_ENDPOINT_COMP,
 
        /* the following 3 values can be tweaked if necessary */
-       /* .bMaxBurst =         0, */
-       /* .bmAttributes =      0, */
-       .wBytesPerInterval =    cpu_to_le16(STATUS_BYTECOUNT),
+       .bMaxBurst              = 0,
+       .bmAttributes           = 0,
+       .wBytesPerInterval      = cpu_to_le16(UVC_STATUS_MAX_PACKET_SIZE),
 };
 
 static struct usb_endpoint_descriptor uvc_ss_streaming_ep __initdata = {
-       .bLength =              USB_DT_ENDPOINT_SIZE,
-       .bDescriptorType =      USB_DT_ENDPOINT,
+       .bLength                = USB_DT_ENDPOINT_SIZE,
+       .bDescriptorType        = USB_DT_ENDPOINT,
 
-       .bEndpointAddress =     USB_DIR_IN,
-       .bmAttributes =         USB_ENDPOINT_XFER_ISOC,
-       .wMaxPacketSize =       cpu_to_le16(1024),
-       .bInterval =            4,
+       .bEndpointAddress       = USB_DIR_IN,
+       .bmAttributes           = USB_ENDPOINT_XFER_ISOC,
+       .wMaxPacketSize         = cpu_to_le16(1024),
+       .bInterval              = 4,
 };
 
 static struct usb_ss_ep_comp_descriptor uvc_ss_streaming_comp = {
-       .bLength =              sizeof uvc_ss_streaming_comp,
-       .bDescriptorType =      USB_DT_SS_ENDPOINT_COMP,
+       .bLength                = sizeof(uvc_ss_streaming_comp),
+       .bDescriptorType        = USB_DT_SS_ENDPOINT_COMP,
 
        /* the following 3 values can be tweaked if necessary */
-       .bMaxBurst =            0,
-       .bmAttributes = 0,
-       .wBytesPerInterval =    cpu_to_le16(1024),
+       .bMaxBurst              = 0,
+       .bmAttributes           = 0,
+       .wBytesPerInterval      = cpu_to_le16(1024),
 };
 
 static const struct usb_descriptor_header * const uvc_fs_streaming[] = {
@@ -514,13 +514,13 @@ uvc_copy_descriptors(struct uvc_device *uvc, enum usb_device_speed speed)
        }
 
        for (src = (const struct usb_descriptor_header **)uvc_control_desc;
-                       *src; ++src) {
+            *src; ++src) {
                control_size += (*src)->bLength;
                bytes += (*src)->bLength;
                n_desc++;
        }
        for (src = (const struct usb_descriptor_header **)uvc_streaming_cls;
-                       *src; ++src) {
+            *src; ++src) {
                streaming_size += (*src)->bLength;
                bytes += (*src)->bLength;
                n_desc++;
@@ -775,23 +775,23 @@ uvc_bind_config(struct usb_configuration *c,
 
        /* Validate the descriptors. */
        if (fs_control == NULL || fs_control[0] == NULL ||
-               fs_control[0]->bDescriptorSubType != UVC_VC_HEADER)
+           fs_control[0]->bDescriptorSubType != UVC_VC_HEADER)
                goto error;
 
        if (ss_control == NULL || ss_control[0] == NULL ||
-               ss_control[0]->bDescriptorSubType != UVC_VC_HEADER)
+           ss_control[0]->bDescriptorSubType != UVC_VC_HEADER)
                goto error;
 
        if (fs_streaming == NULL || fs_streaming[0] == NULL ||
-               fs_streaming[0]->bDescriptorSubType != UVC_VS_INPUT_HEADER)
+           fs_streaming[0]->bDescriptorSubType != UVC_VS_INPUT_HEADER)
                goto error;
 
        if (hs_streaming == NULL || hs_streaming[0] == NULL ||
-               hs_streaming[0]->bDescriptorSubType != UVC_VS_INPUT_HEADER)
+           hs_streaming[0]->bDescriptorSubType != UVC_VS_INPUT_HEADER)
                goto error;
 
        if (ss_streaming == NULL || ss_streaming[0] == NULL ||
-               ss_streaming[0]->bDescriptorSubType != UVC_VS_INPUT_HEADER)
+           ss_streaming[0]->bDescriptorSubType != UVC_VS_INPUT_HEADER)
                goto error;
 
        uvc->desc.fs_control = fs_control;
@@ -800,7 +800,10 @@ uvc_bind_config(struct usb_configuration *c,
        uvc->desc.hs_streaming = hs_streaming;
        uvc->desc.ss_streaming = ss_streaming;
 
-       /* Allocate string descriptor numbers. */
+       /* String descriptors are global, we only need to allocate string IDs
+        * for the first UVC function. UVC functions beyond the first (if any)
+        * will reuse the same IDs.
+        */
        if (uvc_en_us_strings[UVC_STRING_ASSOCIATION_IDX].id == 0) {
                ret = usb_string_ids_tab(c->cdev, uvc_en_us_strings);
                if (ret)
This page took 0.048444 seconds and 5 git commands to generate.