From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754764AbcGHNWh (ORCPT ); Fri, 8 Jul 2016 09:22:37 -0400 Received: from mga14.intel.com ([192.55.52.115]:12013 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755006AbcGHNW2 (ORCPT ); Fri, 8 Jul 2016 09:22:28 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,330,1464678000"; d="asc'?scan'208";a="731418472" From: Felipe Balbi To: Baolin Wang Cc: gregkh@linuxfoundation.org, eu@felipetonello.com, mina86@mina86.com, r.baldyga@samsung.com, dan.carpenter@oracle.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, broonie@kernel.org, baolin.wang@linaro.org Subject: Re: [PATCH] usb: gadget: f_midi: Add checking if it need align buffer's size to an ep's maxpacketsize In-Reply-To: <8ff4f814afc70cf9c00cc6718d7ae93fae94884a.1467881565.git.baolin.wang@linaro.org> References: <8ff4f814afc70cf9c00cc6718d7ae93fae94884a.1467881565.git.baolin.wang@linaro.org> User-Agent: Notmuch/0.22+58~g3a45d29 (https://notmuchmail.org) Emacs/25.0.95.1 (x86_64-pc-linux-gnu) Date: Fri, 08 Jul 2016 16:21:34 +0300 Message-ID: <87lh1ci7tt.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, Baolin Wang writes: > Some gadget device (such as dwc3 gadget) requires quirk_ep_out_aligned_si= ze > attribute, which means it need to align the request buffer's size to an e= p's > maxpacketsize. > > Thus we add usb_ep_align_maybe() function to check if it is need to align > the request buffer's size to an ep's maxpacketsize. > > Signed-off-by: Baolin Wang > --- > drivers/usb/gadget/function/f_midi.c | 18 +++++++++++------- > 1 file changed, 11 insertions(+), 7 deletions(-) > > diff --git a/drivers/usb/gadget/function/f_midi.c b/drivers/usb/gadget/fu= nction/f_midi.c > index 58fc199..2e3f11e 100644 > --- a/drivers/usb/gadget/function/f_midi.c > +++ b/drivers/usb/gadget/function/f_midi.c > @@ -328,7 +328,7 @@ static int f_midi_start_ep(struct f_midi *midi, > static int f_midi_set_alt(struct usb_function *f, unsigned intf, unsigne= d alt) > { > struct f_midi *midi =3D func_to_midi(f); > - unsigned i; > + unsigned i, length; > int err; >=20=20 > /* we only set alt for MIDIStreaming interface */ > @@ -345,9 +345,11 @@ static int f_midi_set_alt(struct usb_function *f, un= signed intf, unsigned alt) >=20=20 > /* pre-allocate write usb requests to use on f_midi_transmit. */ > while (kfifo_avail(&midi->in_req_fifo)) { > - struct usb_request *req =3D > - midi_alloc_ep_req(midi->in_ep, midi->buflen); > + struct usb_request *req; >=20=20 > + length =3D usb_ep_align_maybe(midi->gadget, midi->in_ep, > + midi->buflen); this is not needed for in_ep, only out_ep, right? > + req =3D midi_alloc_ep_req(midi->in_ep, length); > if (req =3D=3D NULL) > return -ENOMEM; >=20=20 > @@ -359,10 +361,12 @@ static int f_midi_set_alt(struct usb_function *f, u= nsigned intf, unsigned alt) >=20=20 > /* allocate a bunch of read buffers and queue them all at once. */ > for (i =3D 0; i < midi->qlen && err =3D=3D 0; i++) { > - struct usb_request *req =3D > - midi_alloc_ep_req(midi->out_ep, > - max_t(unsigned, midi->buflen, > - bulk_out_desc.wMaxPacketSize)); > + struct usb_request *req; > + > + length =3D usb_ep_align_maybe(midi->gadget, midi->out_ep, > + midi->buflen); after calling usb_ep_align_maybe()... > + req =3D midi_alloc_ep_req(midi->out_ep, > + max_t(unsigned, length, bulk_out_desc.wMaxPacketSize)); ... max_t() is pointless. length will *always* >=3D wMaxPacketSize. =2D-=20 balbi --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXf6jeAAoJEIaOsuA1yqREohAP/RR4Edik/h5qn1ZABjoCVLx8 t3lq0oo2tLXZHk0jN99yjHMmMU0rA8jMyE9KNVN8486bic6DTClGskJPXMvXOKQD 6r2pdcriok30ar9XCEv3mmBAu58g4DpxxLhZAlAOKHqqmNze1Fg+G836sCC47u99 9TIR6ybCU2hyx+j3T3NqjsMSFI0M3fGoAVo5K09nxxbzAbv+NTSIDRaXfhyUHndd CArCDjEFZmbz/pMBeTtzLD26aYolqunQONV7V6Ko4N9AJO/EKjoAkC934FU2DNGj 4aZakIYlo0esVeYmUMqbSNvnNDuer5NuwkYD/UOyLmbrLT4GROSK78Wff7AUNRke V5MXgcwksM6lvN8QY37Hp1AjDoNxNhyxtcA3SSpWzMV3gBGEY/pFUNFrL3FTvsSb JYHu6EJ8K+4T1iK1raNzuf8V4GbzCWQBZN+47HagC3AjB0zwHBIKluy6ip1pc9G/ Cu9mvZsFoYIuJrbfHSINVFGUYUiQwRCtODVmK7XS0LqcMQH040rojmsT63JnMi/5 Rb8GWiJKY8x3WPxEEQHlg7iqOmfywWDtjrZfXC7ZxrAiHFkHvLHA+NZztnxYBplB x4BCW+jGWIAQHpoSLipwpN8+q0VGuNC3guWnhTjkBPm2UVvrBXWRSmPGPMb3o369 WBQVGGmUCUrz2HE343kS =s8Nc -----END PGP SIGNATURE----- --=-=-=--