Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754927AbcCBTjp (ORCPT ); Wed, 2 Mar 2016 14:39:45 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:33730 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753396AbcCBTix (ORCPT ); Wed, 2 Mar 2016 14:38:53 -0500 From: "Felipe F. Tonello" To: linux-usb@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Felipe Balbi , Michal Nazarewicz , Clemens Ladisch Subject: [PATCH 3/5] usb: gadget: gmidi: remove bus powered requirement on bmAttributes Date: Wed, 2 Mar 2016 19:40:38 +0000 Message-Id: <1456947640-20673-4-git-send-email-eu@felipetonello.com> X-Mailer: git-send-email 2.7.2 In-Reply-To: <1456947640-20673-1-git-send-email-eu@felipetonello.com> References: <1456947640-20673-1-git-send-email-eu@felipetonello.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2256 Lines: 54 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 = 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"); + /* Thanks to Grey Innovation for donating this product ID. * * DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!! @@ -119,8 +127,8 @@ static struct usb_configuration midi_config = { .label = "MIDI Gadget", .bConfigurationValue = 1, /* .iConfiguration = DYNAMIC */ - .bmAttributes = USB_CONFIG_ATT_ONE, - .MaxPower = CONFIG_USB_GADGET_VBUS_DRAW, + /* .bmAttributes = DYNAMIC */ + /* .MaxPower = DYNAMIC */ }; static int midi_bind_config(struct usb_configuration *c) @@ -163,6 +171,8 @@ static int midi_bind(struct usb_composite_dev *cdev) device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; midi_config.iConfiguration = strings_dev[STRING_DESCRIPTION_IDX].id; + midi_config.bmAttributes = bmAttributes; + midi_config.MaxPower = MaxPower; status = usb_add_config(cdev, &midi_config, midi_bind_config); if (status < 0) -- 2.7.2