[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87ziuaimf8.fsf@intel.com>
Date: Mon, 07 Mar 2016 12:59:07 +0200
From: Felipe Balbi <balbi@...nel.org>
To: Felipe Ferreri Tonello <eu@...ipetonello.com>,
linux-usb@...r.kernel.org
Cc: linux-kernel@...r.kernel.org,
Michal Nazarewicz <mina86@...a86.com>,
Clemens Ladisch <clemens@...isch.de>
Subject: Re: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on bmAttributes
Hi,
Felipe Ferreri Tonello <eu@...ipetonello.com> writes:
>>>> "Felipe F. Tonello" <eu@...ipetonello.com> 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 <eu@...ipetonello.com>
>>>>> ---
>>>>> 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 = 1;
>>>>> module_param(out_ports, uint, S_IRUGO);
>>>>> MODULE_PARM_DESC(out_ports, "Number of MIDI output ports");
>>>>>
>>>>> +static unsigned int bmAttributes = USB_CONFIG_ATT_ONE;
>>>>> +module_param(bmAttributes, uint, S_IRUGO);
>>>>> +MODULE_PARM_DESC(bmAttributes, "Configuration Descriptor's
>>>> bmAttributes parameter");
>>>>> +
>>>>> +static unsigned int MaxPower = 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=4
>> modprobe -r g_midi
>> modprobe g_midi MaxPower=10
>>
>> 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.
>
> Ok, I will further test it.
>
>>
>>>>> @@ -119,8 +127,8 @@ static struct usb_configuration midi_config = {
>>>>> .label = "MIDI Gadget",
>>>>> .bConfigurationValue = 1,
>>>>> /* .iConfiguration = DYNAMIC */
>>>>> - .bmAttributes = 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.
>
> Right.
>
> This is necessary because this driver is actually wrong in which is
> asking for the host to power itself. This is not specified on USB-MIDI
> specification, neither makes any sense since this configuration is
> device specific.
>
> What is your suggestion to make it configurable? Maybe at compile-time?
> I really don't know what is the best solution if this is not something
> you like it.
well, you could use our configfs-based gadget interface. You don't
really need to use gmidi.ko at all. In fact, we wanna do away with any
static modules and rely only on configfs. If configfs doesn't let you
change what you want/need, then we can talk about adding support for
those.
bMaxPower and bmAttributes sound like good things to have configurable
over configfs but beware of what the USB specification says about them,
we cannot let users violate the spec by passing bogus values on these
fields.
cheers
--
balbi
Download attachment "signature.asc" of type "application/pgp-signature" (819 bytes)
Powered by blists - more mailing lists