Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752305AbcCGHfK (ORCPT ); Mon, 7 Mar 2016 02:35:10 -0500 Received: from mga14.intel.com ([192.55.52.115]:36136 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752023AbcCGHfI (ORCPT ); Mon, 7 Mar 2016 02:35:08 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,550,1449561600"; d="asc'?scan'208";a="759377352" From: Felipe Balbi To: Felipe Ferreri Tonello , linux-usb@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Michal Nazarewicz , Clemens Ladisch Subject: Re: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on bmAttributes In-Reply-To: <270D9ECD-1810-48BC-BBE9-9C9DD5E44D4F@felipetonello.com> References: <1456947640-20673-1-git-send-email-eu@felipetonello.com> <1456947640-20673-4-git-send-email-eu@felipetonello.com> <87wppi67c5.fsf@ti.com> <270D9ECD-1810-48BC-BBE9-9C9DD5E44D4F@felipetonello.com> User-Agent: Notmuch/0.21 (http://notmuchmail.org) Emacs/25.0.90.3 (x86_64-pc-linux-gnu) Date: Mon, 07 Mar 2016 09:34:19 +0200 Message-ID: <87egbmkah0.fsf@intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3802 Lines: 113 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi, Felipe Ferreri Tonello writes: > [ text/plain ] > Hi Balbi,=20 > > On March 4, 2016 7:16:42 AM GMT+00:00, Felipe Balbi wr= ote: >> >>Hi, >> >>"Felipe F. Tonello" writes: >>> [ text/plain ] >>> This gadget uses a bmAttributes and MaxPower that requires the USB >>bus to be >>> powered from the host, which is not correct because this >>configuration is device >>> specific, not a USB-MIDI requirement. >>> >>> This patch adds two modules parameters, bmAttributes and MaxPower, >>that allows >>> the user to set those flags. The default values are what the gadget >>used to use >>> for backward compatibility. >>> >>> Signed-off-by: Felipe F. Tonello >>> --- >>> drivers/usb/gadget/legacy/gmidi.c | 14 ++++++++++++-- >>> 1 file changed, 12 insertions(+), 2 deletions(-) >>> >>> diff --git a/drivers/usb/gadget/legacy/gmidi.c >>b/drivers/usb/gadget/legacy/gmidi.c >>> index fc2ac150f5ff..0553435cc360 100644 >>> --- a/drivers/usb/gadget/legacy/gmidi.c >>> +++ b/drivers/usb/gadget/legacy/gmidi.c >>> @@ -63,6 +63,14 @@ static unsigned int out_ports =3D 1; >>> module_param(out_ports, uint, S_IRUGO); >>> MODULE_PARM_DESC(out_ports, "Number of MIDI output ports"); >>>=20=20 >>> +static unsigned int bmAttributes =3D USB_CONFIG_ATT_ONE; >>> +module_param(bmAttributes, uint, S_IRUGO); >>> +MODULE_PARM_DESC(bmAttributes, "Configuration Descriptor's >>bmAttributes parameter"); >>> + >>> +static unsigned int MaxPower =3D CONFIG_USB_GADGET_VBUS_DRAW; >>> +module_param(MaxPower, uint, S_IRUGO); >>> +MODULE_PARM_DESC(MaxPower, "Used to calculate Configuration >>Descriptor's bMaxPower parameter"); >> >>you didn't run checkpatch, did you ? Also, are you sure you will need >>to >>change this by simply reloading the module ? I'm not convinced. > > Yes I always run checkpatch :) do you really ? Why do you have a 98-character line, then ? > What do you mean by reloading the module? modprobe g_midi MaxPower=3D4 modprobe -r g_midi modprobe g_midi MaxPower=3D10 I'm not convinced this is a valid use-case. Specially since you can just provide several configurations and let the host choose the one it suits it best. >>> @@ -119,8 +127,8 @@ static struct usb_configuration midi_config =3D { >>> .label =3D "MIDI Gadget", >>> .bConfigurationValue =3D 1, >>> /* .iConfiguration =3D DYNAMIC */ >>> - .bmAttributes =3D USB_CONFIG_ATT_ONE, >> >>nack, nackety nack nack nack :-) >> >>USB_CONFIG_ATT_ONE *must* always be set. With your module parameter you >>give users the oportunity to violate USB spec. > > You are right. It needs to check the value before it assigns to > bmAttributes. why check ? You can just unconditionally or USB_CONFIG_ATT_ONE. In any case, I'm not convinced this is necessary at all. =2D-=20 balbi --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJW3S78AAoJEIaOsuA1yqREdtYQAIFtkGyws0KN8Yj+QpBVteek IHp6exCJnQvdDRac/NfD6tkSaJqL43KoVsm7gXeJP1KRzl4nb+YXKB8O1Hhwn1k9 idfFdZ02EoD5hCT7jkHByvwf79Ws9a9jDJKPQkaUNrOubtnTY70kbTePJwHSxrKh pQQ9FCD7WtofKB9ZWMzuHdqgqk54Fapghm88vpHBR4aRttl6zQxa+AGFq8YS0aBy ywDGPgCU7JpWoRXnBBbYV1V07Y4VgsJg498NkyFq2saOI8b01mYdPYiA4l+UuIqf /un+jH7JZR4Np+bf9YQjLg044JRRm+XI3+mvy+qGSVU6CDADOnfSAkFyYfBXwaHV a+1DJVTXMsuiKwKG7xiXNKr17XUatnZO+dwuNqawAbfUJ0xjmHaTgXFxd2Id5jrD Tq+YnZsq4tnd5rLO27xwX6rD6TXdmmCr43t4JbXQBbs0W03oWHS8Y6pJaYno0KQt CB4n5pJ+4rEWD4b+PtXUObteg1b4xsuaLBQ5gRgGP2GZpUdfsLTtGPWY4OiAFhX1 ooxKUltkVDqjo5Hig91t6lT+Q395B4Li90L+3oLA7GOyGsHgsVCdgauU4p7cAiJz bCtiHoSBCapUNZhefsxLtugrCRE047N3K7vTkrtW+o1RdZm7Xl7pS2TXY7Yx0YkB cZsJUmo4tmqG04fdtBsa =4bVS -----END PGP SIGNATURE----- --=-=-=--