| .. | .. |
|---|
| 67 | 67 | ) |
|---|
| 68 | 68 | { |
|---|
| 69 | 69 | struct usb_ep *ep; |
|---|
| 70 | | - u8 type; |
|---|
| 71 | | - |
|---|
| 72 | | - type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; |
|---|
| 73 | 70 | |
|---|
| 74 | 71 | if (gadget->ops->match_ep) { |
|---|
| 75 | 72 | ep = gadget->ops->match_ep(gadget, desc, ep_comp); |
|---|
| .. | .. |
|---|
| 109 | 106 | desc->bEndpointAddress |= gadget->out_epnum; |
|---|
| 110 | 107 | } |
|---|
| 111 | 108 | |
|---|
| 112 | | - /* report (variable) full speed bulk maxpacket */ |
|---|
| 113 | | - if ((type == USB_ENDPOINT_XFER_BULK) && !ep_comp) { |
|---|
| 114 | | - int size = ep->maxpacket_limit; |
|---|
| 115 | | - |
|---|
| 116 | | - /* min() doesn't work on bitfields with gcc-3.5 */ |
|---|
| 117 | | - if (size > 64) |
|---|
| 118 | | - size = 64; |
|---|
| 119 | | - desc->wMaxPacketSize = cpu_to_le16(size); |
|---|
| 120 | | - } |
|---|
| 121 | | - |
|---|
| 122 | 109 | ep->address = desc->bEndpointAddress; |
|---|
| 123 | 110 | ep->desc = NULL; |
|---|
| 124 | 111 | ep->comp_desc = NULL; |
|---|
| 125 | 112 | ep->claimed = true; |
|---|
| 126 | | -#ifdef CONFIG_ARCH_ROCKCHIP |
|---|
| 127 | | - ep->transfer_type = type; |
|---|
| 128 | | - if (gadget_is_superspeed(gadget) && ep_comp) { |
|---|
| 129 | | - switch (type) { |
|---|
| 130 | | - case USB_ENDPOINT_XFER_ISOC: |
|---|
| 131 | | - /* mult: bits 1:0 of bmAttributes */ |
|---|
| 132 | | - ep->mult = (ep_comp->bmAttributes & 0x3) + 1; |
|---|
| 133 | | - /* fall through */ |
|---|
| 134 | | - case USB_ENDPOINT_XFER_BULK: |
|---|
| 135 | | - case USB_ENDPOINT_XFER_INT: |
|---|
| 136 | | - ep->maxburst = ep_comp->bMaxBurst + 1; |
|---|
| 137 | | - break; |
|---|
| 138 | | - default: |
|---|
| 139 | | - break; |
|---|
| 140 | | - } |
|---|
| 141 | | - } else if (gadget_is_dualspeed(gadget) && |
|---|
| 142 | | - (type == USB_ENDPOINT_XFER_ISOC || |
|---|
| 143 | | - type == USB_ENDPOINT_XFER_INT)) { |
|---|
| 144 | | - ep->mult = usb_endpoint_maxp_mult(desc); |
|---|
| 145 | | - } |
|---|
| 146 | | -#endif |
|---|
| 147 | 113 | return ep; |
|---|
| 148 | 114 | } |
|---|
| 149 | 115 | EXPORT_SYMBOL_GPL(usb_ep_autoconfig_ss); |
|---|
| .. | .. |
|---|
| 173 | 139 | * |
|---|
| 174 | 140 | * On success, this returns an claimed usb_ep, and modifies the endpoint |
|---|
| 175 | 141 | * descriptor bEndpointAddress. For bulk endpoints, the wMaxPacket value |
|---|
| 176 | | - * is initialized as if the endpoint were used at full speed. To prevent |
|---|
| 177 | | - * the endpoint from being returned by a later autoconfig call, claims it |
|---|
| 178 | | - * by assigning ep->claimed to true. |
|---|
| 142 | + * is initialized as if the endpoint were used at full speed. Because of |
|---|
| 143 | + * that the users must consider adjusting the autoconfigured descriptor. |
|---|
| 144 | + * To prevent the endpoint from being returned by a later autoconfig call, |
|---|
| 145 | + * claims it by assigning ep->claimed to true. |
|---|
| 179 | 146 | * |
|---|
| 180 | 147 | * On failure, this returns a null endpoint descriptor. |
|---|
| 181 | 148 | */ |
|---|
| .. | .. |
|---|
| 184 | 151 | struct usb_endpoint_descriptor *desc |
|---|
| 185 | 152 | ) |
|---|
| 186 | 153 | { |
|---|
| 187 | | - return usb_ep_autoconfig_ss(gadget, desc, NULL); |
|---|
| 154 | + struct usb_ep *ep; |
|---|
| 155 | + u8 type; |
|---|
| 156 | + |
|---|
| 157 | + ep = usb_ep_autoconfig_ss(gadget, desc, NULL); |
|---|
| 158 | + if (!ep) |
|---|
| 159 | + return NULL; |
|---|
| 160 | + |
|---|
| 161 | + type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; |
|---|
| 162 | + |
|---|
| 163 | + /* report (variable) full speed bulk maxpacket */ |
|---|
| 164 | + if (type == USB_ENDPOINT_XFER_BULK) { |
|---|
| 165 | + int size = ep->maxpacket_limit; |
|---|
| 166 | + |
|---|
| 167 | + /* min() doesn't work on bitfields with gcc-3.5 */ |
|---|
| 168 | + if (size > 64) |
|---|
| 169 | + size = 64; |
|---|
| 170 | + desc->wMaxPacketSize = cpu_to_le16(size); |
|---|
| 171 | + } |
|---|
| 172 | + |
|---|
| 173 | + return ep; |
|---|
| 188 | 174 | } |
|---|
| 189 | 175 | EXPORT_SYMBOL_GPL(usb_ep_autoconfig); |
|---|
| 190 | 176 | |
|---|
| .. | .. |
|---|
| 226 | 212 | gadget->out_epnum = 0; |
|---|
| 227 | 213 | } |
|---|
| 228 | 214 | EXPORT_SYMBOL_GPL(usb_ep_autoconfig_reset); |
|---|
| 229 | | - |
|---|
| 230 | | -/** |
|---|
| 231 | | - * usb_ep_autoconfig_by_name - Used to pick the endpoint by name. eg gsi-epin1 |
|---|
| 232 | | - * @gadget: The device to which the endpoint must belong. |
|---|
| 233 | | - * @desc: Endpoint descriptor, with endpoint direction and transfer mode |
|---|
| 234 | | - * initialized. |
|---|
| 235 | | - * @ep_name: EP name that is to be searched. |
|---|
| 236 | | - * |
|---|
| 237 | | - */ |
|---|
| 238 | | -struct usb_ep *usb_ep_autoconfig_by_name( |
|---|
| 239 | | - struct usb_gadget *gadget, |
|---|
| 240 | | - struct usb_endpoint_descriptor *desc, |
|---|
| 241 | | - const char *ep_name |
|---|
| 242 | | -) |
|---|
| 243 | | -{ |
|---|
| 244 | | - struct usb_ep *ep; |
|---|
| 245 | | - bool ep_found = false; |
|---|
| 246 | | - |
|---|
| 247 | | - if (!ep_name || !strlen(ep_name)) |
|---|
| 248 | | - goto err; |
|---|
| 249 | | - |
|---|
| 250 | | - list_for_each_entry(ep, &gadget->ep_list, ep_list) |
|---|
| 251 | | - if (strncmp(ep->name, ep_name, strlen(ep_name)) == 0 && |
|---|
| 252 | | - !ep->driver_data) { |
|---|
| 253 | | - ep_found = true; |
|---|
| 254 | | - break; |
|---|
| 255 | | - } |
|---|
| 256 | | - |
|---|
| 257 | | - if (ep_found) { |
|---|
| 258 | | - desc->bEndpointAddress &= USB_DIR_IN; |
|---|
| 259 | | - desc->bEndpointAddress |= ep->ep_num; |
|---|
| 260 | | - ep->address = desc->bEndpointAddress; |
|---|
| 261 | | - pr_debug("Allocating ep address:%x\n", ep->address); |
|---|
| 262 | | - ep->desc = NULL; |
|---|
| 263 | | - ep->comp_desc = NULL; |
|---|
| 264 | | - return ep; |
|---|
| 265 | | - } |
|---|
| 266 | | - |
|---|
| 267 | | -err: |
|---|
| 268 | | - pr_err("%s:error finding ep %s\n", __func__, ep_name); |
|---|
| 269 | | - return NULL; |
|---|
| 270 | | -} |
|---|
| 271 | | -EXPORT_SYMBOL_GPL(usb_ep_autoconfig_by_name); |
|---|