From mboxrd@z Thu Jan 1 00:00:00 1970 From: balbi@kernel.org (Felipe Balbi) Date: Fri, 27 Jan 2017 17:01:53 +0200 Subject: [PATCH linux-next v2 1/1] usb: gadget: udc: atmel: Update endpoint allocation scheme In-Reply-To: References: <1485182759-17165-1-git-send-email-cristian.birsan@microchip.com> <1485182759-17165-2-git-send-email-cristian.birsan@microchip.com> <84fe6fa4-7cf7-22cb-b4b7-47e2cb202a68@atmel.com> Message-ID: <878tpw7di6.fsf@linux.intel.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Hi, Cristian Birsan writes: >>> + /* It might be a little bit late to set this */ >> >> Is it too late or not? This comment is frightening... We may need some >> feedback from the USB guys here... >> > > If someone from USB can comment a bit on this topic I will be grateful. it is not too late :-) Just look at the implementation of usb_ep_autoconfig_ss(). That said, I haven't considered if gadget drivers might want this value to be valid before calling usb_ep_autoconfig_ss(). I can't see why they would, but still; just a little warning. struct usb_ep *usb_ep_autoconfig_ss( struct usb_gadget *gadget, struct usb_endpoint_descriptor *desc, struct usb_ss_ep_comp_descriptor *ep_comp ) { struct usb_ep *ep; u8 type; type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; if (gadget->ops->match_ep) { ep = gadget->ops->match_ep(gadget, desc, ep_comp); if (ep) goto found_ep; } /* Second, look at endpoints until an unclaimed one looks usable */ list_for_each_entry (ep, &gadget->ep_list, ep_list) { if (usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) goto found_ep; } /* Fail */ return NULL; found_ep: /* * If the protocol driver hasn't yet decided on wMaxPacketSize * and wants to know the maximum possible, provide the info. */ if (desc->wMaxPacketSize == 0) desc->wMaxPacketSize = cpu_to_le16(ep->maxpacket_limit); /* report address */ desc->bEndpointAddress &= USB_DIR_IN; if (isdigit(ep->name[2])) { u8 num = simple_strtoul(&ep->name[2], NULL, 10); desc->bEndpointAddress |= num; } else if (desc->bEndpointAddress & USB_DIR_IN) { if (++gadget->in_epnum > 15) return NULL; desc->bEndpointAddress = USB_DIR_IN | gadget->in_epnum; } else { if (++gadget->out_epnum > 15) return NULL; desc->bEndpointAddress |= gadget->out_epnum; } /* report (variable) full speed bulk maxpacket */ if ((type == USB_ENDPOINT_XFER_BULK) && !ep_comp) { int size = ep->maxpacket_limit; /* min() doesn't work on bitfields with gcc-3.5 */ if (size > 64) size = 64; desc->wMaxPacketSize = cpu_to_le16(size); } ep->address = desc->bEndpointAddress; ep->desc = NULL; ep->comp_desc = NULL; ep->claimed = true; return ep; } -- balbi -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932989AbdA0POn (ORCPT ); Fri, 27 Jan 2017 10:14:43 -0500 Received: from mga01.intel.com ([192.55.52.88]:2593 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932383AbdA0POb (ORCPT ); Fri, 27 Jan 2017 10:14:31 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,295,1477983600"; d="asc'?scan'208";a="58270747" From: Felipe Balbi To: Cristian Birsan , Nicolas Ferre , gregkh@linuxfoundation.org, linux-arm-kernel@lists.infradead.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: ludovic.desroches@atmel.com, alexandre.belloni@free-electrons.com, boris.brezillon@free-electrons.com Subject: Re: [PATCH linux-next v2 1/1] usb: gadget: udc: atmel: Update endpoint allocation scheme In-Reply-To: References: <1485182759-17165-1-git-send-email-cristian.birsan@microchip.com> <1485182759-17165-2-git-send-email-cristian.birsan@microchip.com> <84fe6fa4-7cf7-22cb-b4b7-47e2cb202a68@atmel.com> Date: Fri, 27 Jan 2017 17:01:53 +0200 Message-ID: <878tpw7di6.fsf@linux.intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi, Cristian Birsan writes: >>> + /* It might be a little bit late to set this */ >>=20 >> Is it too late or not? This comment is frightening... We may need some >> feedback from the USB guys here... >> > > If someone from USB can comment a bit on this topic I will be grateful. it is not too late :-) Just look at the implementation of usb_ep_autoconfig_ss(). That said, I haven't considered if gadget drivers might want this value to be valid before calling usb_ep_autoconfig_ss(). I can't see why they would, but still; just a little warning. struct usb_ep *usb_ep_autoconfig_ss( struct usb_gadget *gadget, struct usb_endpoint_descriptor *desc, struct usb_ss_ep_comp_descriptor *ep_comp ) { struct usb_ep *ep; u8 type; type =3D desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; if (gadget->ops->match_ep) { ep =3D gadget->ops->match_ep(gadget, desc, ep_comp); if (ep) goto found_ep; } /* Second, look at endpoints until an unclaimed one looks usable */ list_for_each_entry (ep, &gadget->ep_list, ep_list) { if (usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) goto found_ep; } /* Fail */ return NULL; found_ep: /* * If the protocol driver hasn't yet decided on wMaxPacketSize * and wants to know the maximum possible, provide the info. */ if (desc->wMaxPacketSize =3D=3D 0) desc->wMaxPacketSize =3D cpu_to_le16(ep->maxpacket_limit); /* report address */ desc->bEndpointAddress &=3D USB_DIR_IN; if (isdigit(ep->name[2])) { u8 num =3D simple_strtoul(&ep->name[2], NULL, 10); desc->bEndpointAddress |=3D num; } else if (desc->bEndpointAddress & USB_DIR_IN) { if (++gadget->in_epnum > 15) return NULL; desc->bEndpointAddress =3D USB_DIR_IN | gadget->in_epnum; } else { if (++gadget->out_epnum > 15) return NULL; desc->bEndpointAddress |=3D gadget->out_epnum; } /* report (variable) full speed bulk maxpacket */ if ((type =3D=3D USB_ENDPOINT_XFER_BULK) && !ep_comp) { int size =3D ep->maxpacket_limit; /* min() doesn't work on bitfields with gcc-3.5 */ if (size > 64) size =3D 64; desc->wMaxPacketSize =3D cpu_to_le16(size); } ep->address =3D desc->bEndpointAddress; ep->desc =3D NULL; ep->comp_desc =3D NULL; ep->claimed =3D true; return ep; } =2D-=20 balbi --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEElLzh7wn96CXwjh2IzL64meEamQYFAliLYOEACgkQzL64meEa mQbvvxAA12Gt1DK/HTzXCa4ITOD79rxkNjZTsbH7Mtg4ZlImRF0EfhUi39r6P7Iz hXCf+EFsTwtFvFWXH0Cu39LjvbUu6KLvhpOnhhHck84vGDkYz6JbLibWWyoyc99N 5x3keZ30+zKWEI5tFwBBLjtFqhbx1Kyh02ryM7sLahRaQK6lJduiz9QLudKtlhI2 u/yHeAVD5JJSifNIAVd/ZDuWpgBen6lhs8ujs4So3incR9PAqC1V6/3cyuhZDLoE RQ2J/NOw+NRTFxCdkl3vL5S+Ir14XwadC8cdLH8u25jFIW8F61wasWZMApe33wQ5 0XDGttmTd+fQLPPaS6F9gnp3bkhKCuPYiQpC/UiNDU3EbgjWlruMOD/Ex6/FefGG NClZ6YgVkgThMkqN833sielVVWkmbYfJjDyV1GI4//anMVbJUf83AdBSSK2zsXV2 KofwX9LY1bLVghb/cQlAujcDfGf2YpwjI9oMy9Pna84Z46mCWIZ6d3OKt8i6UmHJ 5J1yDLByr9IjeqC9lD3GqXynCqOkKWoL4NXHQ4V/DKvJ1uj1bBMG9fXf181+U3mg AlpBrMqpos9aQQBBShWfyG+vQ9kpYZHMHCMY9T1Nycreonom5jpXe0dtqLxMFs6e xe9eLboxeTC1Ec0opPoJSaNyUZq9l0LJjOhwgeDdpGPnPwlwEF8= =xECp -----END PGP SIGNATURE----- --=-=-=--