Re: [PATCH 3/3] usb: mxs-phy: register phy as USB_PHY_TYPE_USB2

2012-08-24 Thread Richard Zhao
On Thu, Aug 23, 2012 at 07:22:54PM +0200, Marc Kleine-Budde wrote:
 This patch registers the msx-phy as an USB_PHY_TYPE_USB2. This is needed to 
 get
 reference to the phy with devm_usb_get_phy_by_phandle(), which will be added 
 in
 a later patch.
 
 Signed-off-by: Marc Kleine-Budde m...@pengutronix.de
 ---
  drivers/usb/otg/mxs-phy.c |5 -
  1 file changed, 4 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/usb/otg/mxs-phy.c b/drivers/usb/otg/mxs-phy.c
 index c1a67cb..240b945 100644
 --- a/drivers/usb/otg/mxs-phy.c
 +++ b/drivers/usb/otg/mxs-phy.c
 @@ -141,11 +141,14 @@ static int mxs_phy_probe(struct platform_device *pdev)
  
   platform_set_drvdata(pdev, mxs_phy-phy);
  
 - return 0;
 + return usb_add_phy(mxs_phy-phy, USB_PHY_TYPE_USB2);
Why is it usb2? It's kind of USB_PHY_TYPE_DT.
  }
  
  static int __devexit mxs_phy_remove(struct platform_device *pdev)
  {
 + struct mxs_phy *mxs_phy = platform_get_drvdata(pdev);
drvdata is usb_phy.

Thanks
Richard
 +
 + usb_remove_phy(mxs_phy-phy);
   platform_set_drvdata(pdev, NULL);
  
   return 0;
 -- 
 1.7.10.4
 
 

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: linux 3.6-rc2, undefined reference to omap_musb_mailbox

2012-08-24 Thread Felipe Balbi
On Thu, Aug 23, 2012 at 10:38:59PM +0200, Peter Meerwald wrote:
 On Mon, 20 Aug 2012, Felipe Balbi wrote:
 
  On Mon, Aug 20, 2012 at 04:37:28PM +0530, ABRAHAM, KISHON VIJAY wrote:
   Hi,
   
   On Mon, Aug 20, 2012 at 3:56 PM, Felipe Balbi ba...@ti.com wrote:
On Mon, Aug 20, 2012 at 03:46:07PM +0530, ABRAHAM, KISHON VIJAY wrote:
Hi,
   
On Mon, Aug 20, 2012 at 3:24 PM, Felipe Balbi ba...@ti.com wrote:
 On Mon, Aug 20, 2012 at 11:06:34AM +0530, ABRAHAM, KISHON VIJAY 
 wrote:
 Hi,

 On Sat, Aug 18, 2012 at 9:34 PM, Peter Meerwald pme...@pmeerw.net 
 wrote:
 
  3.6-rc2 fails to compile with
  CONFIG_USB_MUSB_HDRC=m
  CONFIG_USB_MUSB_OMAP2PLUS=m
 
LD  init/built-in.o
  drivers/built-in.o: In function `twl4030_usb_irq':
  /home/pmeerw/linux-3.6-rc2/drivers/usb/otg/twl4030-usb.c:518: 
  undefined reference to `omap_musb_mailbox'
  drivers/built-in.o: In function `twl4030_usb_phy_init':
  /home/pmeerw/linux-3.6-rc2/drivers/usb/otg/twl4030-usb.c:540: 
  undefined reference to `omap_musb_mailbox'

 Having TWL4030_USB as a module will get rid of this.
 I'll see how this can be resolved when some modules are *built-in* 
 and
 some are made as *modules*.

 EXPORT_SYMBOL_GPL() should sort that out, right ?
   
No :-( I already have EXPORT_SYMBOL_GPL() in omap2430.c.
   
I see you're missing an extern on the function prototype (on the
header). Not sure how modules.dep is generated, but maybe it needs the
extern there. Can you check it out ?
   
   That isn't helping either.
  
  oh, ok... twl4030-usb is built-in... now that makes sense. Since
  twl4030-usb uses a symbol from omap2430, then it should depend on it,
  otherwise this will always happen.
 
 so add USB_MUSB_OMAP2PLUS to the depends of TWL4030_USB in 
 drivers/usb/otg/Kconfig?

correct ;-)

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb otg: TWL4030_USB depends on USB_MUSB_OMAP2PLUS in Kconfig

2012-08-24 Thread Felipe Balbi
On Thu, Aug 23, 2012 at 10:38:44PM +0200, Peter Meerwald wrote:
 Signed-off-by: Peter Meerwald pme...@pmeerw.net

I need a commit log explaining why we need to add this extra depend ;-)

 ---
  drivers/usb/otg/Kconfig |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig
 index 13fd1ddf..fefca18 100644
 --- a/drivers/usb/otg/Kconfig
 +++ b/drivers/usb/otg/Kconfig
 @@ -58,7 +58,7 @@ config USB_ULPI_VIEWPORT
  
  config TWL4030_USB
   tristate TWL4030 USB Transceiver Driver
 - depends on TWL4030_CORE  REGULATOR_TWL4030
 + depends on TWL4030_CORE  REGULATOR_TWL4030  USB_MUSB_OMAP2PLUS
   select USB_OTG_UTILS
   help
 Enable this to support the USB OTG transceiver on TWL4030
 -- 
 1.7.9.5
 

-- 
balbi


signature.asc
Description: Digital signature


Re: chipidea driver

2012-08-24 Thread Alexander Shishkin
Richard Zhao richard.z...@freescale.com writes:

 On Thu, Aug 23, 2012 at 06:57:03PM +0200, Marc Kleine-Budde wrote:
 Hello,

Hi,

 Michael and I have a bunch of updates and improvement for the chipidea
 driver. They apply to Richard's tree:
 
 https://github.com/riczhao/kernel-imx/commits/topics/usb-driver
 
 What's the status of these patches? It would be fine if someone queues
 them for upstream.
 My patches is pending on Alex to review. The otg patch series was sent
 on Jul 12. I don't know whether Alex has been back from vacation, or
 what else I can do.

 otg patch: 
 http://lists.infradead.org/pipermail/linux-arm-kernel/2012-July/109020.html
 usbmisc: 
 http://lists.infradead.org/pipermail/linux-arm-kernel/2012-July/111945.html

Thanks for the ping, will have a look soon.

Regards,
--
Alex
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/4] usb: chipidea: udc: set endpoint to undefined maxpacket size on start

2012-08-24 Thread Felipe Balbi
Hi,

On Thu, Aug 23, 2012 at 07:30:45PM +0200, Marc Kleine-Budde wrote:
 From: Michael Grzeschik m.grzesc...@pengutronix.de
 
 Non control endpoints have an undefined maxpacket size on udc start. Some
 gadget drivers check for the maxpacket size before they enable the endpoint,
 which leads to a wrong state.
 
 Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de
 Signed-off-by: Marc Kleine-Budde m...@pengutronix.de

which gadget drivers ? This doesn't look right to me. On dwc3 we
initialize endpoints as early as module probe (before gadget-start() is
even close to being called) and we have no issues at all setting ep0's
maxpacket to 512. Or were you setting maxpacket for all endpoints ??

If that was the case, then this is a fix which should even go to stable
;-)

  drivers/usb/chipidea/udc.c |8 +++-
  1 file changed, 7 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
 index e4db7af..75a96ec 100644
 --- a/drivers/usb/chipidea/udc.c
 +++ b/drivers/usb/chipidea/udc.c
 @@ -1455,7 +1455,12 @@ static int init_eps(struct ci13xxx *ci)
  
   mEp-ep.name  = mEp-name;
   mEp-ep.ops   = usb_ep_ops;
 - mEp-ep.maxpacket = CTRL_PAYLOAD_MAX;
 + /*
 +  * for ep0: maxP defined in desc, for other
 +  * eps, maxP is set by epautoconfig() called
 +  * by gadget layer
 +  */
 + mEp-ep.maxpacket = (unsigned short)~0;
  
   INIT_LIST_HEAD(mEp-qh.queue);
   mEp-qh.ptr = dma_pool_alloc(ci-qh_pool, GFP_KERNEL,
 @@ -1475,6 +1480,7 @@ static int init_eps(struct ci13xxx *ci)
   else
   ci-ep0in = mEp;
  
 + mEp-ep.maxpacket = CTRL_PAYLOAD_MAX;
   continue;
   }
  
 -- 
 1.7.10.4
 

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 4/4] usb: chipidea: udc: add pullup fuction, needed by the uvc gadget

2012-08-24 Thread Felipe Balbi
On Thu, Aug 23, 2012 at 07:30:47PM +0200, Marc Kleine-Budde wrote:
 From: Michael Grzeschik m.grzesc...@pengutronix.de
 
 Add function to physicaly enable or disable of pullup connection on the USB-D+
 line. The uvc gaget will fail, if this function is not implemented.
 
 Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de
 Signed-off-by: Marc Kleine-Budde m...@pengutronix.de

Acked-by: Felipe Balbi ba...@ti.com

 ---
  drivers/usb/chipidea/udc.c |   21 +
  1 file changed, 17 insertions(+), 4 deletions(-)
 
 diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
 index 3bfc030..5f99b17 100644
 --- a/drivers/usb/chipidea/udc.c
 +++ b/drivers/usb/chipidea/udc.c
 @@ -78,8 +78,7 @@ static inline int ep_to_bit(struct ci13xxx *ci, int n)
  }
  
  /**
 - * hw_device_state: enables/disables interrupts  starts/stops device 
 (execute
 - *  without interruption)
 + * hw_device_state: enables/disables interrupts (execute without 
 interruption)
   * @dma: 0 = disable, !0 = enable and set dma engine
   *
   * This function returns an error code
 @@ -91,9 +90,7 @@ static int hw_device_state(struct ci13xxx *ci, u32 dma)
   /* interrupt, error, port change, reset, sleep/suspend */
   hw_write(ci, OP_USBINTR, ~0,
USBi_UI|USBi_UEI|USBi_PCI|USBi_URI|USBi_SLI);
 - hw_write(ci, OP_USBCMD, USBCMD_RS, USBCMD_RS);
   } else {
 - hw_write(ci, OP_USBCMD, USBCMD_RS, 0);
   hw_write(ci, OP_USBINTR, ~0, 0);
   }
   return 0;
 @@ -1417,6 +1414,21 @@ static int ci13xxx_vbus_draw(struct usb_gadget 
 *_gadget, unsigned mA)
   return -ENOTSUPP;
  }
  
 +/* Change Data+ pullup status
 + * this func is used by usb_gadget_connect/disconnet
 + */
 +static int ci13xxx_pullup(struct usb_gadget *_gadget, int is_on)
 +{
 + struct ci13xxx *ci = container_of(_gadget, struct ci13xxx, gadget);
 +
 + if (is_on)
 + hw_write(ci, OP_USBCMD, USBCMD_RS, USBCMD_RS);
 + else
 + hw_write(ci, OP_USBCMD, USBCMD_RS, 0);
 +
 + return 0;
 +}
 +
  static int ci13xxx_start(struct usb_gadget *gadget,
struct usb_gadget_driver *driver);
  static int ci13xxx_stop(struct usb_gadget *gadget,
 @@ -1429,6 +1441,7 @@ static int ci13xxx_stop(struct usb_gadget *gadget,
  static const struct usb_gadget_ops usb_gadget_ops = {
   .vbus_session   = ci13xxx_vbus_session,
   .wakeup = ci13xxx_wakeup,
 + .pullup = ci13xxx_pullup,
   .vbus_draw  = ci13xxx_vbus_draw,
   .udc_start  = ci13xxx_start,
   .udc_stop   = ci13xxx_stop,
 -- 
 1.7.10.4
 

-- 
balbi


signature.asc
Description: Digital signature


[PATCH 7/7 v2] usb/gadget: remove global struct usb_composite_driver in composite

2012-08-24 Thread Sebastian Andrzej Siewior
This patch removes the global variable usb_composite_driver() in
composite.c. The private data which was saved there is now passed via
an additional argument to the bind() function in struct
usb_gadget_driver.

Only the old-style UDC drivers have to be touched here, new style are
doing it right because this change is made in udc-core.

Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de
---
v1..v2: hopefully improvoved the commit message

 drivers/usb/gadget/amd5536udc.c   |6 +--
 drivers/usb/gadget/composite.c|   82 -
 drivers/usb/gadget/dbgp.c |3 +-
 drivers/usb/gadget/file_storage.c |3 +-
 drivers/usb/gadget/fsl_udc_core.c |6 +--
 drivers/usb/gadget/fusb300_udc.c  |4 +-
 drivers/usb/gadget/goku_udc.c |6 +--
 drivers/usb/gadget/inode.c|7 ++--
 drivers/usb/gadget/lpc32xx_udc.c  |6 +--
 drivers/usb/gadget/m66592-udc.c   |4 +-
 drivers/usb/gadget/mv_udc_core.c  |6 +--
 drivers/usb/gadget/omap_udc.c |6 +--
 drivers/usb/gadget/pch_udc.c  |6 +--
 drivers/usb/gadget/pxa25x_udc.c   |6 +--
 drivers/usb/gadget/pxa27x_udc.c   |6 +--
 drivers/usb/gadget/s3c2410_udc.c  |7 ++--
 drivers/usb/gadget/udc-core.c |4 +-
 include/linux/usb/composite.h |1 +
 include/linux/usb/gadget.h|6 ++-
 19 files changed, 95 insertions(+), 80 deletions(-)

diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c
index 187d211..fc0ec5e 100644
--- a/drivers/usb/gadget/amd5536udc.c
+++ b/drivers/usb/gadget/amd5536udc.c
@@ -1401,7 +1401,7 @@ static int udc_wakeup(struct usb_gadget *gadget)
 }
 
 static int amd5536_start(struct usb_gadget_driver *driver,
-   int (*bind)(struct usb_gadget *));
+   int (*bind)(struct usb_gadget *, struct usb_gadget_driver *));
 static int amd5536_stop(struct usb_gadget_driver *driver);
 /* gadget operations */
 static const struct usb_gadget_ops udc_ops = {
@@ -1914,7 +1914,7 @@ static int setup_ep0(struct udc *dev)
 
 /* Called by gadget driver to register itself */
 static int amd5536_start(struct usb_gadget_driver *driver,
-   int (*bind)(struct usb_gadget *))
+   int (*bind)(struct usb_gadget *, struct usb_gadget_driver *))
 {
struct udc  *dev = udc;
int retval;
@@ -1932,7 +1932,7 @@ static int amd5536_start(struct usb_gadget_driver *driver,
dev-driver = driver;
dev-gadget.dev.driver = driver-driver;
 
-   retval = bind(dev-gadget);
+   retval = bind(dev-gadget, driver);
 
/* Some gadget drivers use both ep0 directions.
 * NOTE: to gadget driver, ep0 is just one endpoint...
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 29d5f70..598df69 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -31,8 +31,6 @@
 /* big enough to hold our biggest descriptor */
 #define USB_BUFSIZ 1024
 
-static struct usb_composite_driver *composite;
-
 /* Some systems will need runtime overrides for the  product identifiers
  * published in the device descriptor, either numbers or strings or both.
  * String parameters are in UTF-8 (superset of ASCII's 7 bit characters).
@@ -889,6 +887,7 @@ static int lookup_string(
 static int get_string(struct usb_composite_dev *cdev,
void *buf, u16 language, int id)
 {
+   struct usb_composite_driver *cdriver = cdev-driver;
struct usb_configuration*c;
struct usb_function *f;
int len;
@@ -907,7 +906,7 @@ static int get_string(struct usb_composite_dev *cdev,
memset(s, 0, 256);
s-bDescriptorType = USB_DT_STRING;
 
-   sp = composite-strings;
+   sp = cdriver-strings;
if (sp)
collect_langs(sp, s-wData);
 
@@ -936,12 +935,12 @@ static int get_string(struct usb_composite_dev *cdev,
 * check if the string has not been overridden.
 */
if (cdev-manufacturer_override == id)
-   str = iManufacturer ?: composite-iManufacturer ?:
+   str = iManufacturer ?: cdriver-iManufacturer ?:
composite_manufacturer;
else if (cdev-product_override == id)
-   str = iProduct ?: composite-iProduct;
+   str = iProduct ?: cdriver-iProduct;
else if (cdev-serial_override == id)
-   str = iSerialNumber ?: composite-iSerialNumber;
+   str = iSerialNumber ?: cdriver-iSerialNumber;
else
str = NULL;
if (str) {
@@ -956,8 +955,8 @@ static int get_string(struct usb_composite_dev *cdev,
 * table we're told about.  These lookups are infrequent;
 * simpler-is-better here.
 */
-   if (composite-strings) {
-   len = lookup_string(composite-strings, buf, 

Re: [PATCH 2/9] usb/libcomposite: move config.c into libcomposite

2012-08-24 Thread Sebastian Andrzej Siewior

On 08/23/2012 03:10 PM, Michal Nazarewicz wrote:

Sebastian Andrzej Siewiorbige...@linutronix.de  writes:

This moves config.c into libcomposite and updates all gadgets.

Signed-off-by: Sebastian Andrzej Siewiorbige...@linutronix.de


Acked-by: Michal Nazarewiczmin...@mina86.com


btw: thank you for those acks, I'm going to pick them up unless I make
changes to paches…


diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c
index 7542a72..e3a9892 100644
--- a/drivers/usb/gadget/config.c
+++ b/drivers/usb/gadget/config.c
@@ -12,6 +12,7 @@
  #includelinux/errno.h
  #includelinux/slab.h
  #includelinux/kernel.h
+#includelinux/module.h
  #includelinux/list.h
  #includelinux/string.h
  #includelinux/device.h
@@ -53,7 +54,7 @@ usb_descriptor_fillbuf(void *buf, unsigned buflen,
}
return dest - (u8 *)buf;
  }
-
+EXPORT_SYMBOL_GPL(usb_descriptor_fillbuf);


Interestingly, this is only used in composite.c and config.c, so maybe
in the end we would be able to drop this EXPORT_SYMBOL?


Sure, why not.

Sebastian
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Potential fsg-state problem at file_storage.c

2012-08-24 Thread Sebastian Andrzej Siewior
On Wed, Aug 15, 2012 at 09:49:55AM +, Chen Peter-B29397 wrote:
 Hi Alan,
Hi Peter,

 One of my colleagues reports a problem that the enumeration will fail if
 the storage has some problems.

A silghtly different question: do you think you can check if this kind of
problem is also in the tcm_usb_gadget storage driver?

Sebastian
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/4] usb: chipidea: udc: fix error path in udc_start()

2012-08-24 Thread Richard Zhao
On Thu, Aug 23, 2012 at 07:30:44PM +0200, Marc Kleine-Budde wrote:
 This patch fixes the error path of udc_start(). Now NULL is used to
 unset the peripheral with otg_set_peripheral().
 
 Signed-off-by: Marc Kleine-Budde m...@pengutronix.de
Reviewed-by: Richard Zhao richard.z...@freescale.com
 ---
  drivers/usb/chipidea/udc.c |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
 index c7a032a..e4db7af 100644
 --- a/drivers/usb/chipidea/udc.c
 +++ b/drivers/usb/chipidea/udc.c
 @@ -1729,7 +1729,7 @@ static int udc_start(struct ci13xxx *ci)
  
  remove_trans:
   if (!IS_ERR_OR_NULL(ci-transceiver)) {
 - otg_set_peripheral(ci-transceiver-otg, ci-gadget);
 + otg_set_peripheral(ci-transceiver-otg, NULL);
   if (ci-global_phy)
   usb_put_phy(ci-transceiver);
   }
 -- 
 1.7.10.4
 
 

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: Potential fsg-state problem at file_storage.c

2012-08-24 Thread Chen Peter-B29397
 
 
 On Wed, Aug 15, 2012 at 09:49:55AM +, Chen Peter-B29397 wrote:
  Hi Alan,
 Hi Peter,
 
  One of my colleagues reports a problem that the enumeration will fail
 if
  the storage has some problems.
 
 A silghtly different question: do you think you can check if this kind of
 problem is also in the tcm_usb_gadget storage driver?
 

I have checked, but I can't understand tcm code well, so I don't know
this problem exists or not.

 Sebastian


--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/4] usb: chipidea: udc: fix error path in udc_start()

2012-08-24 Thread Marc Kleine-Budde
On 08/24/2012 10:14 AM, Richard Zhao wrote:
 On Thu, Aug 23, 2012 at 07:30:44PM +0200, Marc Kleine-Budde wrote:
 This patch fixes the error path of udc_start(). Now NULL is used to
 unset the peripheral with otg_set_peripheral().

 Signed-off-by: Marc Kleine-Budde m...@pengutronix.de
 Reviewed-by: Richard Zhao richard.z...@freescale.com

Tnx, Marc

-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


Re: [PATCH 2/4] usb: chipidea: udc: set endpoint to undefined maxpacket size on start

2012-08-24 Thread Marc Kleine-Budde
On 08/24/2012 09:36 AM, Felipe Balbi wrote:
 Hi,
 
 On Thu, Aug 23, 2012 at 07:30:45PM +0200, Marc Kleine-Budde wrote:
 From: Michael Grzeschik m.grzesc...@pengutronix.de

 Non control endpoints have an undefined maxpacket size on udc start. Some
 gadget drivers check for the maxpacket size before they enable the endpoint,
 which leads to a wrong state.

 Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de
 Signed-off-by: Marc Kleine-Budde m...@pengutronix.de
 
 which gadget drivers ? This doesn't look right to me. On dwc3 we
 initialize endpoints as early as module probe (before gadget-start() is
 even close to being called) and we have no issues at all setting ep0's
 maxpacket to 512. Or were you setting maxpacket for all endpoints ??

This patch preserves the setting of ep0 to CTRL_PAYLOAD_MAX, but changes
all other endpoint to (unsigned short)~0.

Other drivers have a similar ~0:

[mkl@dude:usb (upstream/chipidea-fixes)]$ git grep (unsigned short) ~0
gadget/fsl_qe_udc.c:ep-ep.maxpacket = (unsigned short) ~0;
gadget/fsl_udc_core.c:  ep-ep.maxpacket = (unsigned short) ~0;
gadget/mv_u3d_core.c:   ep-ep.maxpacket = (unsigned short) ~0;
gadget/mv_udc_core.c:   ep-ep.maxpacket = (unsigned short) ~0;

 If that was the case, then this is a fix which should even go to stable
 ;-)

Michael has discovered the issue, he'll return to the office soon.

  drivers/usb/chipidea/udc.c |8 +++-
  1 file changed, 7 insertions(+), 1 deletion(-)

 diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
 index e4db7af..75a96ec 100644
 --- a/drivers/usb/chipidea/udc.c
 +++ b/drivers/usb/chipidea/udc.c
 @@ -1455,7 +1455,12 @@ static int init_eps(struct ci13xxx *ci)
  
  mEp-ep.name  = mEp-name;
  mEp-ep.ops   = usb_ep_ops;
 -mEp-ep.maxpacket = CTRL_PAYLOAD_MAX;
 +/*
 + * for ep0: maxP defined in desc, for other
 + * eps, maxP is set by epautoconfig() called
 + * by gadget layer
 + */
 +mEp-ep.maxpacket = (unsigned short)~0;

These are endpoint != 0.

  
  INIT_LIST_HEAD(mEp-qh.queue);
  mEp-qh.ptr = dma_pool_alloc(ci-qh_pool, GFP_KERNEL,
 @@ -1475,6 +1480,7 @@ static int init_eps(struct ci13xxx *ci)
  else
  ci-ep0in = mEp;
  
 +mEp-ep.maxpacket = CTRL_PAYLOAD_MAX;

This is ep0.

  continue;
  }
  
 -- 
 1.7.10.4

 

Marc

-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


Re: [PATCH 2/4] usb: chipidea: udc: set endpoint to undefined maxpacket size on start

2012-08-24 Thread Felipe Balbi
On Fri, Aug 24, 2012 at 10:30:54AM +0200, Marc Kleine-Budde wrote:
 On 08/24/2012 09:36 AM, Felipe Balbi wrote:
  Hi,
  
  On Thu, Aug 23, 2012 at 07:30:45PM +0200, Marc Kleine-Budde wrote:
  From: Michael Grzeschik m.grzesc...@pengutronix.de
 
  Non control endpoints have an undefined maxpacket size on udc start. Some
  gadget drivers check for the maxpacket size before they enable the 
  endpoint,
  which leads to a wrong state.
 
  Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de
  Signed-off-by: Marc Kleine-Budde m...@pengutronix.de
  
  which gadget drivers ? This doesn't look right to me. On dwc3 we
  initialize endpoints as early as module probe (before gadget-start() is
  even close to being called) and we have no issues at all setting ep0's
  maxpacket to 512. Or were you setting maxpacket for all endpoints ??
 
 This patch preserves the setting of ep0 to CTRL_PAYLOAD_MAX, but changes
 all other endpoint to (unsigned short)~0.
 
 Other drivers have a similar ~0:
 
 [mkl@dude:usb (upstream/chipidea-fixes)]$ git grep (unsigned short) ~0
 gadget/fsl_qe_udc.c:ep-ep.maxpacket = (unsigned short) ~0;
 gadget/fsl_udc_core.c:  ep-ep.maxpacket = (unsigned short) ~0;
 gadget/mv_u3d_core.c:   ep-ep.maxpacket = (unsigned short) ~0;
 gadget/mv_udc_core.c:   ep-ep.maxpacket = (unsigned short) ~0;
 
  If that was the case, then this is a fix which should even go to stable
  ;-)
 
 Michael has discovered the issue, he'll return to the office soon.
 
   drivers/usb/chipidea/udc.c |8 +++-
   1 file changed, 7 insertions(+), 1 deletion(-)
 
  diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
  index e4db7af..75a96ec 100644
  --- a/drivers/usb/chipidea/udc.c
  +++ b/drivers/usb/chipidea/udc.c
  @@ -1455,7 +1455,12 @@ static int init_eps(struct ci13xxx *ci)
   
 mEp-ep.name  = mEp-name;
 mEp-ep.ops   = usb_ep_ops;
  -  mEp-ep.maxpacket = CTRL_PAYLOAD_MAX;
  +  /*
  +   * for ep0: maxP defined in desc, for other
  +   * eps, maxP is set by epautoconfig() called
  +   * by gadget layer
  +   */
  +  mEp-ep.maxpacket = (unsigned short)~0;
 
 These are endpoint != 0.

Ok, then the change makes a lot of sense and needs to be sent to stable
too.

Acked-by: Felipe Balbi ba...@ti.com


-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 2/4] usb: chipidea: udc: set endpoint to undefined maxpacket size on start

2012-08-24 Thread Marc Kleine-Budde
On 08/24/2012 10:31 AM, Felipe Balbi wrote:
 On Fri, Aug 24, 2012 at 10:30:54AM +0200, Marc Kleine-Budde wrote:
 On 08/24/2012 09:36 AM, Felipe Balbi wrote:
 Hi,

 On Thu, Aug 23, 2012 at 07:30:45PM +0200, Marc Kleine-Budde wrote:
 From: Michael Grzeschik m.grzesc...@pengutronix.de

 Non control endpoints have an undefined maxpacket size on udc start. Some
 gadget drivers check for the maxpacket size before they enable the 
 endpoint,
 which leads to a wrong state.

 Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de
 Signed-off-by: Marc Kleine-Budde m...@pengutronix.de

 which gadget drivers ? This doesn't look right to me. On dwc3 we
 initialize endpoints as early as module probe (before gadget-start() is
 even close to being called) and we have no issues at all setting ep0's
 maxpacket to 512. Or were you setting maxpacket for all endpoints ??

 This patch preserves the setting of ep0 to CTRL_PAYLOAD_MAX, but changes
 all other endpoint to (unsigned short)~0.

 Other drivers have a similar ~0:

 [mkl@dude:usb (upstream/chipidea-fixes)]$ git grep (unsigned short) ~0
 gadget/fsl_qe_udc.c:ep-ep.maxpacket = (unsigned short) ~0;
 gadget/fsl_udc_core.c:  ep-ep.maxpacket = (unsigned short) ~0;
 gadget/mv_u3d_core.c:   ep-ep.maxpacket = (unsigned short) ~0;
 gadget/mv_udc_core.c:   ep-ep.maxpacket = (unsigned short) ~0;

 If that was the case, then this is a fix which should even go to stable
 ;-)

 Michael has discovered the issue, he'll return to the office soon.

  drivers/usb/chipidea/udc.c |8 +++-
  1 file changed, 7 insertions(+), 1 deletion(-)

 diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
 index e4db7af..75a96ec 100644
 --- a/drivers/usb/chipidea/udc.c
 +++ b/drivers/usb/chipidea/udc.c
 @@ -1455,7 +1455,12 @@ static int init_eps(struct ci13xxx *ci)
  
mEp-ep.name  = mEp-name;
mEp-ep.ops   = usb_ep_ops;
 -  mEp-ep.maxpacket = CTRL_PAYLOAD_MAX;
 +  /*
 +   * for ep0: maxP defined in desc, for other
 +   * eps, maxP is set by epautoconfig() called
 +   * by gadget layer
 +   */
 +  mEp-ep.maxpacket = (unsigned short)~0;

 These are endpoint != 0.
 
 Ok, then the change makes a lot of sense and needs to be sent to stable
 too.
 
 Acked-by: Felipe Balbi ba...@ti.com

Thanks, I'll rephrase the descipton a bit.

Marc

-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


[PATCH v2] usb otg: TWL4030_USB to depend on USB_MUSB_OMAP2PLUS in Kconfig

2012-08-24 Thread Peter Meerwald
3.6-rc2 fails to compile with
CONFIG_USB_MUSB_HDRC=m
CONFIG_USB_MUSB_OMAP2PLUS=m
CONFIG_TWL4030_USB=y

LD  init/built-in.o
drivers/built-in.o: In function `twl4030_usb_irq':
/home/pmeerw/linux-3.6-rc2/drivers/usb/otg/twl4030-usb.c:518: undefined 
reference to `omap_musb_mailbox'
drivers/built-in.o: In function `twl4030_usb_phy_init':
/home/pmeerw/linux-3.6-rc2/drivers/usb/otg/twl4030-usb.c:540: undefined 
reference to `omap_musb_mailbox'

twl4030-usb uses a symbol from omap2430, hence it should depend on it

Signed-off-by: Peter Meerwald pme...@pmeerw.net
---
 drivers/usb/otg/Kconfig |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig
index 13fd1ddf..fefca18 100644
--- a/drivers/usb/otg/Kconfig
+++ b/drivers/usb/otg/Kconfig
@@ -58,7 +58,7 @@ config USB_ULPI_VIEWPORT
 
 config TWL4030_USB
tristate TWL4030 USB Transceiver Driver
-   depends on TWL4030_CORE  REGULATOR_TWL4030
+   depends on TWL4030_CORE  REGULATOR_TWL4030  USB_MUSB_OMAP2PLUS
select USB_OTG_UTILS
help
  Enable this to support the USB OTG transceiver on TWL4030
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC ebeam PATCH v4 2/2] input: misc: New USB eBeam input driver.

2012-08-24 Thread Yann Cantin
Hi,

Le 23/08/2012 09:23, Oliver Neukum a écrit :
 On Thursday 23 August 2012 00:11:54 Yann Cantin wrote:
 +static int ebeam_resume(struct usb_interface *intf)
 +{
 +   struct ebeam_device *ebeam = usb_get_intfdata(intf);
 +   struct input_dev *input = ebeam-input;
 +   int result = 0;
 +
 +   mutex_lock(input-mutex);
 +   if (input-users)
 +   result = usb_submit_urb(ebeam-irq, GFP_NOIO);
 +   mutex_unlock(input-mutex);
 +
 +   return result;
 +}
 +
 +static int ebeam_reset_resume(struct usb_interface *intf)
 +{
 +   struct ebeam_device *ebeam = usb_get_intfdata(intf);
 +   struct input_dev *input = ebeam-input;
 +   int err = 0;
 +
 +   /* restart IO if needed */
 +   mutex_lock(input-mutex);
 +   if (input-users)
 +   err = usb_submit_urb(ebeam-irq, GFP_NOIO);
 +   mutex_unlock(input-mutex);
 +
 +   return err;
 +}
 
 These functions are identical. You should unify them.

Removed reset_resume from the driver (optional, and not needed
for this hardware).

Thanks.

-- 
Yann Cantin
A4FEB47F
--
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb otg: TWL4030_USB depends on USB_MUSB_OMAP2PLUS in Kconfig

2012-08-24 Thread ABRAHAM, KISHON VIJAY
Hi,

On Fri, Aug 24, 2012 at 12:57 PM, Felipe Balbi ba...@ti.com wrote:
 On Thu, Aug 23, 2012 at 10:38:44PM +0200, Peter Meerwald wrote:
 Signed-off-by: Peter Meerwald pme...@pmeerw.net

 I need a commit log explaining why we need to add this extra depend ;-)

 ---
  drivers/usb/otg/Kconfig |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig
 index 13fd1ddf..fefca18 100644
 --- a/drivers/usb/otg/Kconfig
 +++ b/drivers/usb/otg/Kconfig
 @@ -58,7 +58,7 @@ config USB_ULPI_VIEWPORT

  config TWL4030_USB
   tristate TWL4030 USB Transceiver Driver
 - depends on TWL4030_CORE  REGULATOR_TWL4030
 + depends on TWL4030_CORE  REGULATOR_TWL4030  USB_MUSB_OMAP2PLUS

Can you add this for twl6030 also?

Thanks
Kishon
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/5] dwc3 fixes

2012-08-24 Thread Pratyush Anand
This fixes are mainly handling missed isoc IN request.
I did not need last patch in my fixing. Still , I think fix is
important.

Pratyush Anand (5):
  usb/dwc3:Move udelay within stop_active_transfe
  usb/dwc3: Fix missed isoc
  usb/dwc3: Fix next request to handle in case of update transfer
  usb/dwc3: Fix skip LINK-TRB on ISOC
  usb/dwc3: fix no request in request_list when start isoc

 drivers/usb/dwc3/core.h   |1 -
 drivers/usb/dwc3/gadget.c |   98 +
 2 files changed, 54 insertions(+), 45 deletions(-)

-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/5] usb/dwc3:Move udelay within stop_active_transfe

2012-08-24 Thread Pratyush Anand
We need udelay(100) after every END TRANSFER, so it is better to keep it
within dwc3_stop_active_transfer.

Signed-off-by: Pratyush Anand pratyush.an...@st.com
---
 drivers/usb/dwc3/gadget.c |   42 +-
 1 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index cc8834c..9699723 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -566,27 +566,6 @@ static void dwc3_remove_requests(struct dwc3 *dwc, struct 
dwc3_ep *dep)
if (!list_empty(dep-req_queued)) {
dwc3_stop_active_transfer(dwc, dep-number);
 
-   /*
-* NOTICE: We are violating what the Databook says about the
-* EndTransfer command. Ideally we would _always_ wait for the
-* EndTransfer Command Completion IRQ, but that's causing too
-* much trouble synchronizing between us and gadget driver.
-*
-* We have discussed this with the IP Provider and it was
-* suggested to giveback all requests here, but give HW some
-* extra time to synchronize with the interconnect. We're using
-* an arbitraty 100us delay for that.
-*
-* Note also that a similar handling was tested by Synopsys
-* (thanks a lot Paul) and nothing bad has come out of it.
-* In short, what we're doing is:
-*
-* - Issue EndTransfer WITH CMDIOC bit set
-* - Wait 100us
-* - giveback all requests to gadget driver
-*/
-   udelay(100);
-
while (!list_empty(dep-req_queued)) {
req = next_request(dep-req_queued);
 
@@ -1927,6 +1906,27 @@ static void dwc3_stop_active_transfer(struct dwc3 *dwc, 
u32 epnum)
ret = dwc3_send_gadget_ep_cmd(dwc, dep-number, cmd, params);
WARN_ON_ONCE(ret);
dep-resource_index = 0;
+
+   /*
+* notice: we are violating what the databook says about the
+* endtransfer command. ideally we would _always_ wait for the
+* endtransfer command completion irq, but that's causing too
+* much trouble synchronizing between us and gadget driver.
+*
+* we have discussed this with the ip provider and it was
+* suggested to giveback all requests here, but give hw some
+* extra time to synchronize with the interconnect. we're using
+* an arbitraty 100us delay for that.
+*
+* note also that a similar handling was tested by synopsys
+* (thanks a lot paul) and nothing bad has come out of it.
+* in short, what we're doing is:
+*
+* - issue endtransfer with cmdioc bit set
+* - wait 100us
+* - giveback all requests to gadget driver
+*/
+   udelay(100);
 }
 
 static void dwc3_stop_active_transfers(struct dwc3 *dwc)
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/5] usb/dwc3: Fix next request to handle in case of update transfer

2012-08-24 Thread Pratyush Anand
req_queued points to the first request for which completion is still to
be called. request_list points to the first request which need to be
queued. dwc3_prepare_trb will change HWO from 0 to 1 for the first
request of request_list.

Signed-off-by: Pratyush Anand pratyush.an...@st.com
---
 drivers/usb/dwc3/gadget.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index d6d31cf..3cc94e6 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -987,12 +987,12 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep 
*dep, u16 cmd_param,
/* req points to the first request which will be sent */
req = next_request(dep-req_queued);
} else {
-   dwc3_prepare_trbs(dep, start_new);
-
/*
 * req points to the first request where HWO changed from 0 to 1
 */
-   req = next_request(dep-req_queued);
+   req = next_request(dep-request_list);
+
+   dwc3_prepare_trbs(dep, start_new);
}
if (!req) {
dep-flags |= DWC3_EP_PENDING_REQUEST;
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/5] usb/dwc3: Fix missed isoc

2012-08-24 Thread Pratyush Anand
There are two reasons to generate missed isoc.

1. when the host does not poll for all the data.
2. because of application-side delays that prevent all the data from
being transferred in programmed microframe.

Current code was able to handle first case only.  Now we take following
approach to handle missed isoc.

If missed isoc occurred and there is no request queued then issue END
TRANSFER, so that core generates next xfernotready and we will issue a
fresh START TRANSFER.
If there are still queued request then wait, do not issue either END or
UPDATE TRANSFER, just attach next request in request_list during giveback.
If any future queued request is successfully transferred then we will issue
UPDATE TRANSFER for all request in the request_list.

Signed-off-by: Pratyush Anand pratyush.an...@st.com
---
 drivers/usb/dwc3/core.h   |1 -
 drivers/usb/dwc3/gadget.c |   36 
 2 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 4470c6f..916a4bf 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -439,7 +439,6 @@ struct dwc3_ep {
u8  number;
u8  type;
u8  resource_index;
-   u16 current_uf;
u32 interval;
 
charname[20];
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 9699723..d6d31cf 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1134,16 +1134,6 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, 
struct dwc3_request *req)
}
}
 
-   /*
-* 3. Missed ISOC Handling. We need to start isoc transfer on the saved
-* uframe number.
-*/
-   if (usb_endpoint_xfer_isoc(dep-endpoint.desc) 
-   (dep-flags  DWC3_EP_MISSED_ISOC)) {
-   __dwc3_gadget_start_isoc(dwc, dep, dep-current_uf);
-   dep-flags = ~DWC3_EP_MISSED_ISOC;
-   }
-
return 0;
 }
 
@@ -1709,14 +1699,29 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, 
struct dwc3_ep *dep,
if (trb_status == DWC3_TRBSTS_MISSED_ISOC) {
dev_dbg(dwc-dev, incomplete IN 
transfer %s\n,
dep-name);
-   dep-current_uf = event-parameters 
-   ~(dep-interval - 1);
+   /*
+* If missed isoc occurred and there is
+* no request queued then issue END
+* TRANSFER, so that core generates
+* next xfernotready and we will issue
+* a fresh START TRANSFER.
+* If there are still queued request
+* then wait, do not issue either END
+* or UPDATE TRANSFER, just attach next
+* request in request_list during
+* giveback.If any future queued request
+* is successfully transferred then we
+* will issue UPDATE TRANSFER for all
+* request in the request_list.
+*/
dep-flags |= DWC3_EP_MISSED_ISOC;
} else {
dev_err(dwc-dev, incomplete IN 
transfer %s\n,
dep-name);
status = -ECONNRESET;
}
+   } else {
+   dep-flags = ~DWC3_EP_MISSED_ISOC;
}
} else {
if (count  (event-status  DEPEVT_STATUS_SHORT))
@@ -1743,6 +1748,13 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, 
struct dwc3_ep *dep,
break;
} while (1);
 
+   if (list_empty(dep-req_queued) 
+   (dep-flags  DWC3_EP_MISSED_ISOC)) {
+   dwc3_stop_active_transfer(dwc, dep-number);
+   dep-flags = ~DWC3_EP_MISSED_ISOC;
+   return 1;
+   }
+
if ((event-status  DEPEVT_STATUS_IOC) 
(trb-ctrl  DWC3_TRB_CTRL_IOC))
return 0;
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/5] usb/dwc3: fix no request in request_list when start isoc

2012-08-24 Thread Pratyush Anand
If xfernotready is received and there is no request in request_list then
PENDING flag must be set, so that next request in ep queue is executed.

Signed-off-by: Pratyush Anand pratyush.an...@st.com
---
 drivers/usb/dwc3/gadget.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 5d41d74..8d3b2d5 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1040,6 +1040,7 @@ static void __dwc3_gadget_start_isoc(struct dwc3 *dwc,
if (list_empty(dep-request_list)) {
dev_vdbg(dwc-dev, ISOC ep %s run out for requests.\n,
dep-name);
+   dep-flags |= DWC3_EP_PENDING_REQUEST;
return;
}
 
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC ebeam PATCH v4 2/2] input: misc: New USB eBeam input driver.

2012-08-24 Thread Oliver Neukum
On Friday 24 August 2012 11:37:45 Yann Cantin wrote:
 Hi,
 
 Le 23/08/2012 09:23, Oliver Neukum a écrit :
  On Thursday 23 August 2012 00:11:54 Yann Cantin wrote:

  These functions are identical. You should unify them.
 
 Removed reset_resume from the driver (optional, and not needed
 for this hardware).

Why did you do that? It is always better to have reset_resume().
And you cannot tell whether it will be needed.

Regards
Oliver

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: usb3 writes fail with transcend rdf8 + ASMedia ASM1042 woes

2012-08-24 Thread Sami Farin
On Sun, Jul 15, 2012 at 11:14:13 -0400, Alan Stern wrote:
...
 In past years I have found that Genesys's devices tend to be rather
 buggy.  This card reader continues the tradition.  Basically, although
 the firmware works reasonably well at high speed, the SuperSpeed
 support is too buggy to be usable.
 
 My advice is to exchange the card reader for one of a different brand.

I got £6 reader from eBay, sanXi usb3 sdcx reader..
It reset itself to usb2 speed when I tried it in usb3 port
and in usb2 port it is quite slow (14 MB/s).
There are benchmarks done by other people with sanXi where they get good
speed (90 MB/s) but presumably they do not have any ASMedia near their 
computers.
Also, (after first use) the usb3 port I used sanXi in was DEAD till I rebooted
the machine; also, other devices were not detected in the port, either.

 Alan Stern
 
 P.S.: Sarah, the lspci information shows this xHCI controller to be an
 ASM1042 controller from ASMedia.  Is this one of those known to have
 the short-packet bug?  The usbmon trace shows a cancelled transfer, for
 which 0 bytes must have been received, but with actual_length equal to
 the transfer_buffer_length.

3.6.0-rc2-g6dab7ede has some funny printk's , but it panics on network use
so I am back to 3.5.0-rc7-g84a1caf:

5[5.163846] scsi 10:0:0:0: bad extra_isize (%u != %u)Direct-Access 
Generic  STORAGE DEVICE TS07 PQ: 0 ANSI: 0
3[ 2277.412255] sd 10:0:0:1: 6mpf: %llx


 This would seem to indicate another type of bug in the host controller.  
 Apparently it reported normal completion for a transfer that was
 cancelled.

Can these be worked around in kernel, or is firmware update needed
for asmedia?  I have latest BIOS from Asus...

-- 
Do what you love because life is too short for anything else.

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/5] usb/dwc3: Fix skip LINK-TRB on ISOC

2012-08-24 Thread Pratyush Anand
When we reach to link trb, we just need to increase free_slot and then
calculate TRB. Return is not correct, as it will cause wrong TRB DMA
address to fetch in case of update transfer.

Signed-off-by: Pratyush Anand pratyush.an...@st.com
---
 drivers/usb/dwc3/gadget.c |   13 +
 1 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 3cc94e6..5d41d74 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -773,21 +773,18 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep,
struct dwc3 *dwc = dep-dwc;
struct dwc3_trb *trb;
 
-   unsigned intcur_slot;
-
dev_vdbg(dwc-dev, %s: req %p dma %08llx length %d%s%s\n,
dep-name, req, (unsigned long long) dma,
length, last ?  last : ,
chain ?  chain : );
 
-   trb = dep-trb_pool[dep-free_slot  DWC3_TRB_MASK];
-   cur_slot = dep-free_slot;
-   dep-free_slot++;
-
/* Skip the LINK-TRB on ISOC */
-   if (((cur_slot  DWC3_TRB_MASK) == DWC3_TRB_NUM - 1) 
+   if (((dep-free_slot  DWC3_TRB_MASK) == DWC3_TRB_NUM - 1) 
usb_endpoint_xfer_isoc(dep-endpoint.desc))
-   return;
+   dep-free_slot++;
+
+   trb = dep-trb_pool[dep-free_slot  DWC3_TRB_MASK];
+   dep-free_slot++;
 
if (!req-trb) {
dwc3_gadget_move_request_queued(req);
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


surfstick K5006-Z in 3.6.0-rc3

2012-08-24 Thread Thomas Schäfer

short status update:

Confirmation: the qmi_wwan works as expected. (/dev/cdc-wdm0 and wwan0 
work)
Missing the option patch for /dev/ttyUSBX for at-commands/classic 
ppp-connections


Thomas




dmesg
[  110.500114] usb 1-1: new high-speed USB device number 3 using ehci_hcd
[  110.635759] usb 1-1: New USB device found, idVendor=19d2, idProduct=1017
[  110.635773] usb 1-1: New USB device strings: Mfr=3, Product=2, 
SerialNumber=4

[  110.635783] usb 1-1: Product: ZTE LTE Technologies MSM
[  110.635791] usb 1-1: Manufacturer: ZTE,Incorporated
[  110.635799] usb 1-1: SerialNumber: MF821VVDFS02
[  110.695096] usbcore: registered new interface driver uas
[  110.702221] Initializing USB Mass Storage driver...
[  110.705608] scsi4 : usb-storage 1-1:1.0
[  110.705938] usbcore: registered new interface driver usb-storage
[  110.705945] USB Mass Storage support registered.
[  113.855485] usb 1-1: USB disconnect, device number 3
[  118.364137] usb 1-1: new high-speed USB device number 4 using ehci_hcd
[  118.499910] usb 1-1: New USB device found, idVendor=19d2, idProduct=1018
[  118.499924] usb 1-1: New USB device strings: Mfr=3, Product=2, 
SerialNumber=4

[  118.499934] usb 1-1: Product: ZTE LTE Technologies MSM
[  118.499942] usb 1-1: Manufacturer: ZTE,Incorporated
[  118.499951] usb 1-1: SerialNumber: MF821VVDFS02
[  118.505565] scsi5 : usb-storage 1-1:1.4
[  118.553541] usbcore: registered new interface driver cdc_wdm
[  118.564997] qmi_wwan 1-1:1.3: cdc-wdm0: USB WDM device
[  118.565530] qmi_wwan 1-1:1.3: wwan0: register 'qmi_wwan' at 
usb-:00:1d.7-1, WWAN/QMI device, 0e:bd:3d:f1:d4:46

[  118.565630] usbcore: registered new interface driver qmi_wwan
[  119.505747] scsi 5:0:0:0: CD-ROMVodafone USB SCSI CD-ROM  
2.31 PQ: 0 ANSI: 0

[  119.506426] scsi 5:0:0:0: Attached scsi generic sg1 type 5
[  119.507764] scsi 5:0:0:1: Direct-Access Vodafone Storage  
2.31 PQ: 0 ANSI: 0

[  119.509072] sd 5:0:0:1: Attached scsi generic sg2 type 0
[  119.51] sd 5:0:0:1: [sdb] Attached SCSI removable disk
[  119.540685] sr0: scsi-1 drive
[  119.540694] cdrom: Uniform CD-ROM driver Revision: 3.20
[  119.541099] sr 5:0:0:0: Attached scsi CD-ROM sr0
[  183.808891] NET: Registered protocol family 17

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 5/5] usb/dwc3: fix no request in request_list when start isoc

2012-08-24 Thread Pratyush Anand

On 8/24/2012 5:10 PM, Pratyush ANAND wrote:

If xfernotready is received and there is no request in request_list then
PENDING flag must be set, so that next request in ep queue is executed.



Although, I did not encounter PENDING in isoc testing. But, if somebody 
hits it, then only this patch might not be sufficient. One might need 
following along with it.


diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 8d3b2d5..c08aa39 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1104,6 +1104,16 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep 
*dep, struct dwc3_request *req)

if (dep-flags  DWC3_EP_PENDING_REQUEST) {
int ret;

+   /*
+* If xfornotready is already elapsed and it is a case
+* of isoc transfer, then issue END TRANSFER, so that
+* you can receive xfernotready again and can have
+* notion of current microframe.
+*/
+   if (usb_endpoint_xfer_isoc(dep-endpoint.desc)) {
+   dwc3_stop_active_transfer(dwc, dep-number);
+   return 0;
+   }
ret = __dwc3_gadget_kick_transfer(dep, 0, true);
if (ret  ret != -EBUSY) {
struct dwc3 *dwc = dep-dwc;


If you agree, then discard this patch only. I will send another one to 
handle pending isoc request.


Regards
Pratyush

Signed-off-by: Pratyush Anand pratyush.an...@st.com
---
  drivers/usb/dwc3/gadget.c |1 +
  1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 5d41d74..8d3b2d5 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1040,6 +1040,7 @@ static void __dwc3_gadget_start_isoc(struct dwc3 *dwc,
if (list_empty(dep-request_list)) {
dev_vdbg(dwc-dev, ISOC ep %s run out for requests.\n,
dep-name);
+   dep-flags |= DWC3_EP_PENDING_REQUEST;
return;
}





--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC ebeam PATCH v4 2/2] input: misc: New USB eBeam input driver.

2012-08-24 Thread Yann Cantin
Hi,

Le 24/08/2012 13:41, Oliver Neukum a écrit :
 On Friday 24 August 2012 11:37:45 Yann Cantin wrote:
 Hi,

 Le 23/08/2012 09:23, Oliver Neukum a écrit :
 On Thursday 23 August 2012 00:11:54 Yann Cantin wrote:
 
 These functions are identical. You should unify them.

 Removed reset_resume from the driver (optional, and not needed
 for this hardware).
 
 Why did you do that? It is always better to have reset_resume().
 And you cannot tell whether it will be needed.

This function was used in usbtouchscreen (which this driver is based on)
for some hardware specific init after reset. eBeam devices doesn't need that,
and i didn't mention the similarity of the 2 functions after stripping the code.

According to power-management.txt, reset_resume is optional, and lot of input
driver lack it. Anyway, if you think it's worth the code, i'll re-add a 
reset_resume function proxing resume like wacom_sys.c do.

-- 
Yann Cantin
A4FEB47F
--
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH 2/2] USB: Set usb port's DevicerRemovable according acpi information in EHCI

2012-08-24 Thread Alan Stern
On Fri, 24 Aug 2012, Lan Tianyu wrote:

  But if other places got hub descriptor, they can't get DeviceRemovable
  value since we only set DeviceRemovable in the hub_configure().(e.g lsusb).

Note: This isn't true.  You now set desc-u.hs.DeviceRemovable in 
ehci_hub_descriptor().

  I don't understand.  lsusb will be able to see the DeviceRemovable 
  values in sysfs, won't it?
 lsusb will issue get hub descriptor request in the usr space and print
 DeviceRemovable.

Sure, that's right.  But that's not what I was complaining about -- I 
was complaining about the fact the you want to call 
get_hub_descriptor() twice.

 So if we put setting DeviceRemovable in the hcd's hub descriptor request
 routine, usr space could also get acpi information via getting hub
 descriptor and we don't need to expose DeviceRemovable sysfs file.

Userspace doesn't use get_hub_descriptor() (it calls usb_control_msg()  
directly).  Therefore you don't need to set any DeviceRemovable
information in that routine.

  Another problem is that some hcds will set DeviceRemovable themselves.
  There will be a conflict between hcd and acpi information. Different
  hcds may have different processes.
  
  There is always the possibility of a conflict.  This remains true 
  whether you get the hub descriptor once or twice.
 Yeah. how to deal with conflict
 First time of getting the hub descriptor is to initialize hub and create
 port devices. The second time is to update DeviceRemovable after
 port devices create.

Look, I can't tell exactly what's going on here because I can't see
your code.  It isn't present in any trees that I have access to, and I
can't see what's going on by trying to read multiple patches spread
over several email threads.

The simple fact is, get_hub_descriptor() is the wrong place to do
anything related to ports.

Furthermore, I don't see why you need to update
hub-descriptor-u.hs.DeviceRemovable at all.  The value returned by
hub_configure() the first time will be correct; there's no reason to
call get_hub_descriptor() a second time.

 Another proposal is to set DeviceRemovable both in the hcd driver and
 hub_configue() since hub probe maybe a special case. We have to get port
 number first and then create port devices. Does this make sense?

As of this latest patch, you _do_ set desc-u.hs.DeviceRemovable in
ehci-hcd.  This means you don't need to set
hub-descriptor-u.hs.DeviceRemovable in hub_configure(), because it
will use the value returned by ehci-hcd.

Alan Stern

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 7/7 v2] usb/gadget: remove global struct usb_composite_driver in composite

2012-08-24 Thread Alan Stern
On Fri, 24 Aug 2012, Sebastian Andrzej Siewior wrote:

 This patch removes the global variable usb_composite_driver() in
 composite.c. The private data which was saved there is now passed via
 an additional argument to the bind() function in struct
 usb_gadget_driver.
 
 Only the old-style UDC drivers have to be touched here, new style are
 doing it right because this change is made in udc-core.

Much better, thank you.  Except that the global variable is named
composite, not usb_composite_driver, and it is a pointer to a
usb_composite_driver structure, not a function.

 --- a/drivers/usb/gadget/composite.c
 +++ b/drivers/usb/gadget/composite.c
 @@ -31,8 +31,6 @@
  /* big enough to hold our biggest descriptor */
  #define USB_BUFSIZ   1024
  
 -static struct usb_composite_driver *composite;

Alan Stern

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: Potential fsg-state problem at file_storage.c

2012-08-24 Thread Alan Stern
On Fri, 24 Aug 2012, Chen Peter-B29397 wrote:

  
  
  On Wed, Aug 15, 2012 at 09:49:55AM +, Chen Peter-B29397 wrote:
   Hi Alan,
  Hi Peter,
  
   One of my colleagues reports a problem that the enumeration will fail
  if
   the storage has some problems.
  
  A silghtly different question: do you think you can check if this kind of
  problem is also in the tcm_usb_gadget storage driver?
  
 
 I have checked, but I can't understand tcm code well, so I don't know
 this problem exists or not.

Sebastian, you might be able to check this yourself.  What does 
tcm_usb_gadget do when it gets a USB port reset?  Does it tell the 
storage layer to sync all the dirty pages?

Also, does it sync the dirty pages when it gets a USB disconnect?

Alan Stern

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


USB sound issue / status

2012-08-24 Thread Dr. Ing. Dieter Jurzitza
Hi folks,
regarding the problems with my sound card (ESI Phonorama) I have an update. 
Using kernel 3.5.2 the error messages still show, however, the sound card 
isn't kicked out any more, what is a plaster and helps me but does not solve 
the issue as such.

[432106.466106] xhci_hcd :08:00.0: ERROR: unexpected command completion 
code 0x11.
[432106.466111] usb 5-2: Not enough bandwidth for altsetting 0
[432106.558779] xhci_hcd :08:00.0: ERROR: unexpected command completion 
code 0x11.
[432106.558784] usb 5-2: Not enough bandwidth for altsetting 1
[432106.558785] ALSA pcm.c:322 2:2:1: usb_set_interface failed (-22)
[432106.560303] xhci_hcd :08:00.0: ERROR: unexpected command completion 
code 0x11.
[432106.560307] usb 5-2: Not enough bandwidth for altsetting 1
[432106.560308] ALSA pcm.c:322 2:2:1: usb_set_interface failed (-22)
[432106.581079] xhci_hcd :08:00.0: ERROR: unexpected command completion 
code 0x11.
[432106.581083] usb 5-2: Not enough bandwidth for altsetting 0
[432106.606094] xhci_hcd :08:00.0: ERROR: unexpected command completion 
code 0x11.
[432106.606099] usb 5-2: Not enough bandwidth for altsetting 0

so, I will be out of reach for the next two weeks, however, I am willing to 
test in case you are interested in further debugging what is going on here - 
just let me know. I personally can easily live with the current situation now, 

Take care,
thank you for your support so far




Dieter Jurzitza

-- 
---

   |
\
 /\_/\   |
| ~x~ |/-\   /
 \   /-   \_/
  ^^__   _/  _     /
 °°__ \- \_/ |  |/|  |
  ||  || _| _|_| _|

if you really want to see the pictures above - use some font
with constant spacing like courier! :-)
---
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 7/7 v2] usb/gadget: remove global struct usb_composite_driver in composite

2012-08-24 Thread Michal Nazarewicz
Sebastian Andrzej Siewior bige...@linutronix.de writes:
 This patch removes the global variable usb_composite_driver() in

s/()//, otherwise it looks like a function name. :)

 composite.c. The private data which was saved there is now passed via
 an additional argument to the bind() function in struct
 usb_gadget_driver.

 Only the old-style UDC drivers have to be touched here, new style are
 doing it right because this change is made in udc-core.

 Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de

 diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c
 index 187d211..fc0ec5e 100644
 --- a/drivers/usb/gadget/amd5536udc.c
 +++ b/drivers/usb/gadget/amd5536udc.c
 @@ -1401,7 +1401,7 @@ static int udc_wakeup(struct usb_gadget *gadget)
  }
  
  static int amd5536_start(struct usb_gadget_driver *driver,
 - int (*bind)(struct usb_gadget *));
 + int (*bind)(struct usb_gadget *, struct usb_gadget_driver *));
  static int amd5536_stop(struct usb_gadget_driver *driver);
  /* gadget operations */
  static const struct usb_gadget_ops udc_ops = {
 @@ -1914,7 +1914,7 @@ static int setup_ep0(struct udc *dev)
  
  /* Called by gadget driver to register itself */
  static int amd5536_start(struct usb_gadget_driver *driver,
 - int (*bind)(struct usb_gadget *))
 + int (*bind)(struct usb_gadget *, struct usb_gadget_driver *))
  {
   struct udc  *dev = udc;
   int retval;
 @@ -1932,7 +1932,7 @@ static int amd5536_start(struct usb_gadget_driver 
 *driver,
   dev-driver = driver;
   dev-gadget.dev.driver = driver-driver;
  
 - retval = bind(dev-gadget);
 + retval = bind(dev-gadget, driver);
  
   /* Some gadget drivers use both ep0 directions.
* NOTE: to gadget driver, ep0 is just one endpoint...
 diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
 index 29d5f70..598df69 100644
 --- a/drivers/usb/gadget/composite.c
 +++ b/drivers/usb/gadget/composite.c
 @@ -31,8 +31,6 @@
  /* big enough to hold our biggest descriptor */
  #define USB_BUFSIZ   1024
  
 -static struct usb_composite_driver *composite;
 -
  /* Some systems will need runtime overrides for the  product identifiers
   * published in the device descriptor, either numbers or strings or both.
   * String parameters are in UTF-8 (superset of ASCII's 7 bit characters).
 @@ -889,6 +887,7 @@ static int lookup_string(
  static int get_string(struct usb_composite_dev *cdev,
   void *buf, u16 language, int id)
  {
 + struct usb_composite_driver *cdriver = cdev-driver;

Should you keep the “composite” name for the variable, the rest of the
patch would be a bit shorter. :)

   struct usb_configuration*c;
   struct usb_function *f;
   int len;

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +email/xmpp: m...@google.com--ooO--(_)--Ooo--

pgpdpLq3Hi9fI.pgp
Description: PGP signature


[PATCH 7/7 v3] usb/gadget: remove global struct usb_composite_driver in composite

2012-08-24 Thread Sebastian Andrzej Siewior
This patch removes the global variable usb_composite_driver() in
composite.c. The private data which was saved there is now passed via
an additional argument to the bind() function in struct
usb_gadget_driver.

Only the old-style UDC drivers have to be touched here, new style are
doing it right because this change is made in udc-core.

Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de
---
v2..v3: did not give up hope and tried to improve the commit message.
v1..v2: hopefully improvoved the commit message

 drivers/usb/gadget/amd5536udc.c   |6 +--
 drivers/usb/gadget/composite.c|   82 -
 drivers/usb/gadget/dbgp.c |3 +-
 drivers/usb/gadget/file_storage.c |3 +-
 drivers/usb/gadget/fsl_udc_core.c |6 +--
 drivers/usb/gadget/fusb300_udc.c  |4 +-
 drivers/usb/gadget/goku_udc.c |6 +--
 drivers/usb/gadget/inode.c|7 ++--
 drivers/usb/gadget/lpc32xx_udc.c  |6 +--
 drivers/usb/gadget/m66592-udc.c   |4 +-
 drivers/usb/gadget/mv_udc_core.c  |6 +--
 drivers/usb/gadget/omap_udc.c |6 +--
 drivers/usb/gadget/pch_udc.c  |6 +--
 drivers/usb/gadget/pxa25x_udc.c   |6 +--
 drivers/usb/gadget/pxa27x_udc.c   |6 +--
 drivers/usb/gadget/s3c2410_udc.c  |7 ++--
 drivers/usb/gadget/udc-core.c |4 +-
 include/linux/usb/composite.h |1 +
 include/linux/usb/gadget.h|6 ++-
 19 files changed, 95 insertions(+), 80 deletions(-)

diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c
index 187d211..fc0ec5e 100644
--- a/drivers/usb/gadget/amd5536udc.c
+++ b/drivers/usb/gadget/amd5536udc.c
@@ -1401,7 +1401,7 @@ static int udc_wakeup(struct usb_gadget *gadget)
 }
 
 static int amd5536_start(struct usb_gadget_driver *driver,
-   int (*bind)(struct usb_gadget *));
+   int (*bind)(struct usb_gadget *, struct usb_gadget_driver *));
 static int amd5536_stop(struct usb_gadget_driver *driver);
 /* gadget operations */
 static const struct usb_gadget_ops udc_ops = {
@@ -1914,7 +1914,7 @@ static int setup_ep0(struct udc *dev)
 
 /* Called by gadget driver to register itself */
 static int amd5536_start(struct usb_gadget_driver *driver,
-   int (*bind)(struct usb_gadget *))
+   int (*bind)(struct usb_gadget *, struct usb_gadget_driver *))
 {
struct udc  *dev = udc;
int retval;
@@ -1932,7 +1932,7 @@ static int amd5536_start(struct usb_gadget_driver *driver,
dev-driver = driver;
dev-gadget.dev.driver = driver-driver;
 
-   retval = bind(dev-gadget);
+   retval = bind(dev-gadget, driver);
 
/* Some gadget drivers use both ep0 directions.
 * NOTE: to gadget driver, ep0 is just one endpoint...
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 29d5f70..598df69 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -31,8 +31,6 @@
 /* big enough to hold our biggest descriptor */
 #define USB_BUFSIZ 1024
 
-static struct usb_composite_driver *composite;
-
 /* Some systems will need runtime overrides for the  product identifiers
  * published in the device descriptor, either numbers or strings or both.
  * String parameters are in UTF-8 (superset of ASCII's 7 bit characters).
@@ -889,6 +887,7 @@ static int lookup_string(
 static int get_string(struct usb_composite_dev *cdev,
void *buf, u16 language, int id)
 {
+   struct usb_composite_driver *cdriver = cdev-driver;
struct usb_configuration*c;
struct usb_function *f;
int len;
@@ -907,7 +906,7 @@ static int get_string(struct usb_composite_dev *cdev,
memset(s, 0, 256);
s-bDescriptorType = USB_DT_STRING;
 
-   sp = composite-strings;
+   sp = cdriver-strings;
if (sp)
collect_langs(sp, s-wData);
 
@@ -936,12 +935,12 @@ static int get_string(struct usb_composite_dev *cdev,
 * check if the string has not been overridden.
 */
if (cdev-manufacturer_override == id)
-   str = iManufacturer ?: composite-iManufacturer ?:
+   str = iManufacturer ?: cdriver-iManufacturer ?:
composite_manufacturer;
else if (cdev-product_override == id)
-   str = iProduct ?: composite-iProduct;
+   str = iProduct ?: cdriver-iProduct;
else if (cdev-serial_override == id)
-   str = iSerialNumber ?: composite-iSerialNumber;
+   str = iSerialNumber ?: cdriver-iSerialNumber;
else
str = NULL;
if (str) {
@@ -956,8 +955,8 @@ static int get_string(struct usb_composite_dev *cdev,
 * table we're told about.  These lookups are infrequent;
 * simpler-is-better here.
 */
-   if 

[PATCH] usb: gadget: get rid of USB_GADGET_{DUAL,SUPER}SPEED

2012-08-24 Thread Michal Nazarewicz
From: Michal Nazarewicz min...@mina86.com

This commit removes USB_GADGET_DUALSPEED and USB_GADGET_SUPERSPEED
Kconfig options.  Since now kernel allows many UDC drivers to be
compiled, those options may turn to no longer be valid.  For
instance, if someone decides to build UDC that supports super
speed and UDC that supports high speed only, the latter will be
assumed to support super speed since USB_GADGET_SUPERSPEED will
be selected by the former.

The test of whether CONFIG_USB_GADGET_*SPEED was defined was just
an optimisation which removed otherwise dead code (ie. if UDC is
not dual speed, there is no need to handle cases that can happen
if speed is high).  This commit removes those checks.

Signed-off-by: Michal Nazarewicz min...@mina86.com
---
 Hi,

 I've sent this patch quite a while ago but it did not got picked up
 for some reason.  Looking at the archives[1] I could not figure out
 a reason why this patch should be omitted so I'm resending it.

 This is rebase on top of v3.6-rc3.

 [1] 
https://groups.google.com/forum/?fromgroups=#!topic/linux.kernel/cUOFAhPGNhE

 drivers/usb/chipidea/Kconfig   |1 -
 drivers/usb/dwc3/Kconfig   |2 --
 drivers/usb/gadget/Kconfig |   25 -
 drivers/usb/gadget/composite.c |9 +
 drivers/usb/gadget/inode.c |   15 ---
 drivers/usb/gadget/u_ether.c   |7 ---
 drivers/usb/musb/Kconfig   |1 -
 include/linux/usb/gadget.h |   19 ++-
 8 files changed, 7 insertions(+), 72 deletions(-)

diff --git a/drivers/usb/chipidea/Kconfig b/drivers/usb/chipidea/Kconfig
index 47e499c..1ea932a 100644
--- a/drivers/usb/chipidea/Kconfig
+++ b/drivers/usb/chipidea/Kconfig
@@ -13,7 +13,6 @@ if USB_CHIPIDEA
 config USB_CHIPIDEA_UDC
bool ChipIdea device controller
depends on USB_GADGET=y || USB_GADGET=USB_CHIPIDEA
-   select USB_GADGET_DUALSPEED
help
  Say Y here to enable device controller functionality of the
  ChipIdea driver.
diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index d13c60f..f6a6e07 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -2,8 +2,6 @@ config USB_DWC3
tristate DesignWare USB3 DRD Core Support
depends on (USB  USB_GADGET)
select USB_OTG_UTILS
-   select USB_GADGET_DUALSPEED
-   select USB_GADGET_SUPERSPEED
select USB_XHCI_PLATFORM if USB_SUPPORT  USB_XHCI_HCD
help
  Say Y or M here if your system has a Dual Role SuperSpeed
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 51ab5fd..2ba0d0e 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -154,7 +154,6 @@ config USB_LPC32XX
 
 config USB_ATMEL_USBA
tristate Atmel USBA
-   select USB_GADGET_DUALSPEED
depends on AVR32 || ARCH_AT91SAM9RL || ARCH_AT91SAM9G45
help
  USBA is the integrated high-speed USB Device controller on
@@ -163,7 +162,6 @@ config USB_ATMEL_USBA
 config USB_FSL_USB2
tristate Freescale Highspeed USB DR Peripheral Controller
depends on FSL_SOC || ARCH_MXC
-   select USB_GADGET_DUALSPEED
select USB_FSL_MPH_DR_OF if OF
help
   Some of Freescale PowerPC and i.MX processors have a High Speed
@@ -179,7 +177,6 @@ config USB_FSL_USB2
 config USB_FUSB300
tristate Faraday FUSB300 USB Peripheral Controller
depends on !PHYS_ADDR_T_64BIT
-   select USB_GADGET_DUALSPEED
help
   Faraday usb device controller FUSB300 driver
 
@@ -227,7 +224,6 @@ config USB_PXA25X_SMALL
 
 config USB_R8A66597
tristate Renesas R8A66597 USB Peripheral Controller
-   select USB_GADGET_DUALSPEED
help
   R8A66597 is a discrete USB host and peripheral controller chip that
   supports both full and high speed USB 2.0 data transfers.
@@ -240,7 +236,6 @@ config USB_R8A66597
 config USB_RENESAS_USBHS_UDC
tristate 'Renesas USBHS controller'
depends on USB_RENESAS_USBHS
-   select USB_GADGET_DUALSPEED
help
   Renesas USBHS is a discrete USB host and peripheral controller chip
   that supports both full and high speed USB 2.0 data transfers.
@@ -268,7 +263,6 @@ config USB_PXA27X
 config USB_S3C_HSOTG
tristate S3C HS/OtG USB Device controller
depends on S3C_DEV_USB_HSOTG
-   select USB_GADGET_DUALSPEED
help
  The Samsung S3C64XX USB2.0 high-speed gadget controller
  integrated into the S3C64XX series SoC.
@@ -305,7 +299,6 @@ config USB_S3C2410_DEBUG
 config USB_S3C_HSUDC
tristate S3C2416, S3C2443 and S3C2450 USB Device Controller
depends on ARCH_S3C24XX
-   select USB_GADGET_DUALSPEED
help
  Samsung's S3C2416, S3C2443 and S3C2450 is an ARM9 based SoC
  integrated with dual speed USB 2.0 device controller. It has
@@ -315,7 +308,6 @@ config USB_S3C_HSUDC
 
 config USB_MV_UDC
tristate 

Re: [PATCH 7/7 v2] usb/gadget: remove global struct usb_composite_driver in composite

2012-08-24 Thread Sebastian Andrzej Siewior
* Michal Nazarewicz | 2012-08-24 19:09:06 [+0200]:

Sebastian Andrzej Siewior bige...@linutronix.de writes:
 This patch removes the global variable usb_composite_driver() in

s/()//, otherwise it looks like a function name. :)
fixed in v3.

 @@ -1401,7 +1401,7 @@ static int udc_wakeup(struct usb_gadget *gadget)
 index 29d5f70..598df69 100644
 --- a/drivers/usb/gadget/composite.c
 +++ b/drivers/usb/gadget/composite.c
   * String parameters are in UTF-8 (superset of ASCII's 7 bit characters).
 @@ -889,6 +887,7 @@ static int lookup_string(
  static int get_string(struct usb_composite_dev *cdev,
  void *buf, u16 language, int id)
  {
 +struct usb_composite_driver *cdriver = cdev-driver;

Should you keep the ???composite??? name for the variable, the rest of the
patch would be a bit shorter. :)

Seriously? I have it now consistent within the file. The second series
which little large would clash here. I would prefer to avoid this if
possible.

Sebastian
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/9] usb/gadget: start with libcomposite

2012-08-24 Thread Sebastian Andrzej Siewior
* Alan Stern | 2012-08-23 10:15:16 [-0400]:

 --- a/drivers/usb/gadget/Kconfig
 +++ b/drivers/usb/gadget/Kconfig
 @@ -507,6 +507,16 @@ config USB_GADGET_SUPERSPEED
  #
  # USB Gadget Drivers
  #
 +
 +# composite based drivers
 +config USB_LIBCOMPOSITE
 +tristate Lib composite based gadgets
 +depends on USB_GADGET

Shouldn't this have default USB_GADGET?  There will be very few cases
where anyone wants to configure a system with gadget support but
without libcomposite.

I changed this to a hidden symbol which selected by each gadget except
inode.c

 +help
 +  Most gadgets are using the composite framework. There are only three

s/framework/library/

 +  gadgets left which do not use the composite framework and two of them

Ditto.

This is gone now.

 +  have been replaced by alternatives.

Alan Stern

Sebastian
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 7/7 v3] usb/gadget: remove global struct usb_composite_driver in composite

2012-08-24 Thread Alan Stern
On Fri, 24 Aug 2012, Sebastian Andrzej Siewior wrote:

 This patch removes the global variable usb_composite_driver() in
 composite.c. The private data which was saved there is now passed via
 an additional argument to the bind() function in struct
 usb_gadget_driver.
 
 Only the old-style UDC drivers have to be touched here, new style are
 doing it right because this change is made in udc-core.
 
 Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de
 ---
 v2..v3: did not give up hope and tried to improve the commit message.

I don't see any changes in the commit message at all.  :-(

Alan Stern

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 7/7 v2] usb/gadget: remove global struct usb_composite_driver in composite

2012-08-24 Thread Michal Nazarewicz
Sebastian Andrzej Siewior bige...@linutronix.de writes:
 @@ -889,6 +887,7 @@ static int lookup_string(
  static int get_string(struct usb_composite_dev *cdev,
 void *buf, u16 language, int id)
  {
 +   struct usb_composite_driver *cdriver = cdev-driver;

 * Michal Nazarewicz | 2012-08-24 19:09:06 [+0200]:
Should you keep the ???composite??? name for the variable, the rest of the
patch would be a bit shorter. :)

Sebastian Andrzej Siewior bige...@linutronix.de writes:
 Seriously? I have it now consistent within the file. The second series
 which little large would clash here. I would prefer to avoid this if
 possible.

I'm fine either way.  If you have a reason to rename the variable,
please do.  I'm just pointing that the patch would be smaller if you
wouldn't. :)

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +email/xmpp: m...@google.com--ooO--(_)--Ooo--

pgpjBBvnt3gtC.pgp
Description: PGP signature


[PATCH 7/7 really v3] usb/gadget: remove global variable composite in composite.c

2012-08-24 Thread Sebastian Andrzej Siewior
This patch removes the global variable composite in composite.c.
The private data which was saved there is now passed via an additional
argument to the bind() function in struct usb_gadget_driver.

Only the old-style UDC drivers have to be touched here, new style are
doing it right because this change is made in udc-core.

Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de
---
* Alan Stern | 2012-08-24 14:51:03 [-0400]:
 v2..v3: did not give up hope and tried to improve the commit message.

I don't see any changes in the commit message at all.  :-(

I'm sorry, I managed to send out the same patch again :/

Alan Stern

 drivers/usb/gadget/amd5536udc.c   |6 +--
 drivers/usb/gadget/composite.c|   82 -
 drivers/usb/gadget/dbgp.c |3 +-
 drivers/usb/gadget/file_storage.c |3 +-
 drivers/usb/gadget/fsl_udc_core.c |6 +--
 drivers/usb/gadget/fusb300_udc.c  |4 +-
 drivers/usb/gadget/goku_udc.c |6 +--
 drivers/usb/gadget/inode.c|7 ++--
 drivers/usb/gadget/lpc32xx_udc.c  |6 +--
 drivers/usb/gadget/m66592-udc.c   |4 +-
 drivers/usb/gadget/mv_udc_core.c  |6 +--
 drivers/usb/gadget/omap_udc.c |6 +--
 drivers/usb/gadget/pch_udc.c  |6 +--
 drivers/usb/gadget/pxa25x_udc.c   |6 +--
 drivers/usb/gadget/pxa27x_udc.c   |6 +--
 drivers/usb/gadget/s3c2410_udc.c  |7 ++--
 drivers/usb/gadget/udc-core.c |4 +-
 include/linux/usb/composite.h |1 +
 include/linux/usb/gadget.h|6 ++-
 19 files changed, 95 insertions(+), 80 deletions(-)

diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c
index 187d211..fc0ec5e 100644
--- a/drivers/usb/gadget/amd5536udc.c
+++ b/drivers/usb/gadget/amd5536udc.c
@@ -1401,7 +1401,7 @@ static int udc_wakeup(struct usb_gadget *gadget)
 }
 
 static int amd5536_start(struct usb_gadget_driver *driver,
-   int (*bind)(struct usb_gadget *));
+   int (*bind)(struct usb_gadget *, struct usb_gadget_driver *));
 static int amd5536_stop(struct usb_gadget_driver *driver);
 /* gadget operations */
 static const struct usb_gadget_ops udc_ops = {
@@ -1914,7 +1914,7 @@ static int setup_ep0(struct udc *dev)
 
 /* Called by gadget driver to register itself */
 static int amd5536_start(struct usb_gadget_driver *driver,
-   int (*bind)(struct usb_gadget *))
+   int (*bind)(struct usb_gadget *, struct usb_gadget_driver *))
 {
struct udc  *dev = udc;
int retval;
@@ -1932,7 +1932,7 @@ static int amd5536_start(struct usb_gadget_driver *driver,
dev-driver = driver;
dev-gadget.dev.driver = driver-driver;
 
-   retval = bind(dev-gadget);
+   retval = bind(dev-gadget, driver);
 
/* Some gadget drivers use both ep0 directions.
 * NOTE: to gadget driver, ep0 is just one endpoint...
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 29d5f70..598df69 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -31,8 +31,6 @@
 /* big enough to hold our biggest descriptor */
 #define USB_BUFSIZ 1024
 
-static struct usb_composite_driver *composite;
-
 /* Some systems will need runtime overrides for the  product identifiers
  * published in the device descriptor, either numbers or strings or both.
  * String parameters are in UTF-8 (superset of ASCII's 7 bit characters).
@@ -889,6 +887,7 @@ static int lookup_string(
 static int get_string(struct usb_composite_dev *cdev,
void *buf, u16 language, int id)
 {
+   struct usb_composite_driver *cdriver = cdev-driver;
struct usb_configuration*c;
struct usb_function *f;
int len;
@@ -907,7 +906,7 @@ static int get_string(struct usb_composite_dev *cdev,
memset(s, 0, 256);
s-bDescriptorType = USB_DT_STRING;
 
-   sp = composite-strings;
+   sp = cdriver-strings;
if (sp)
collect_langs(sp, s-wData);
 
@@ -936,12 +935,12 @@ static int get_string(struct usb_composite_dev *cdev,
 * check if the string has not been overridden.
 */
if (cdev-manufacturer_override == id)
-   str = iManufacturer ?: composite-iManufacturer ?:
+   str = iManufacturer ?: cdriver-iManufacturer ?:
composite_manufacturer;
else if (cdev-product_override == id)
-   str = iProduct ?: composite-iProduct;
+   str = iProduct ?: cdriver-iProduct;
else if (cdev-serial_override == id)
-   str = iSerialNumber ?: composite-iSerialNumber;
+   str = iSerialNumber ?: cdriver-iSerialNumber;
else
str = NULL;
if (str) {
@@ -956,8 +955,8 @@ static int get_string(struct usb_composite_dev *cdev,
 * table we're told 

Re: [PATCH 0/3]: ezusb cleanup, FX2 support, firmware downloading support

2012-08-24 Thread Greg KH
On Wed, Aug 22, 2012 at 09:26:41AM +0200, Rene Buergel wrote:
 
   - Although i removed the dependency from ezusb to usb_serial,
 ezusb.c still resides in drivers/usb/serial.
 Can you give me a hint, where to put it instead?
 I would like to do that with an additional patch.
  
  Why do you want to move it?
 
 because is has nothing to do with any serial stuff anymore...

Fair enough, how about drivers/usb/misc/ instead?

greg k-h
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: USB sound card device complains about error -28: not enough bandwidth only on specific PC hardware, seems not kernel specific

2012-08-24 Thread David Ranch


[re-send dropping the HTML format to work around VGER's silly 
plain-text-only rule]



Hello Alan,

First off, thanks for the response and sorry for the delay here.. very 
busy here!



The problem is caused by the ehci-hcd driver's not-so-great support 
for scheduling periodic transfers to full-speed devices. That's why 
the HP and Dell systems have no trouble but your Gateway laptop can't 
handle it. 


There are various reports that the Windows driver has an option to FORCE 
this X-Fi device to use USB high speed which solves some specific sound 
quality issues, etc. but I have not seen anything about needing that 
switch to support 96khz at.  There was a similar trick done on the 
Audigy2 NX card and I'd be willing to try some code that could force the 
device to high speed that but it's unclear what's needed for the X-Fi card.


   Audigy 2 NX required a hack to go into highspeed mode
http://comments.gmane.org/gmane.linux.usb.general/20816


I've also researched around where some people recommended to remove the 
EHCI module to use the OHCI but that doesn't seem to work on this 
specific laptop's chipset.



To be clear, I'm ONLY looking to record two channel (stereo) from this 
sound card's line-in.  I'm more than happy to disable any playback, etc. 
if that might allow this USB device to stay under the Full speed 
bandwidth limit



You can provide some more details: The output from lsusb -v for the 
sound card, and a usbmon trace showing the RECORD failure (see 
Documentation/usb/usbmon.txt for instructions). 


Absolutely.  Please see here:

http://www.trinityos.com/SCRATCH/

--David

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/20] usb/libcomposite: move config.c into libcomposite

2012-08-24 Thread Sebastian Andrzej Siewior
This patch moves config.c into libcomposite and updates all gadgets.

Acked-by: Michal Nazarewicz min...@mina86.com
Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de
---
 drivers/staging/ccg/ccg.c   |1 -
 drivers/usb/gadget/Makefile |2 +-
 drivers/usb/gadget/acm_ms.c |1 -
 drivers/usb/gadget/audio.c  |1 -
 drivers/usb/gadget/cdc2.c   |1 -
 drivers/usb/gadget/config.c |6 --
 drivers/usb/gadget/ether.c  |1 -
 drivers/usb/gadget/file_storage.c   |1 -
 drivers/usb/gadget/g_ffs.c  |1 -
 drivers/usb/gadget/gmidi.c  |1 -
 drivers/usb/gadget/hid.c|1 -
 drivers/usb/gadget/mass_storage.c   |1 -
 drivers/usb/gadget/multi.c  |1 -
 drivers/usb/gadget/ncm.c|1 -
 drivers/usb/gadget/nokia.c  |1 -
 drivers/usb/gadget/printer.c|1 -
 drivers/usb/gadget/serial.c |1 -
 drivers/usb/gadget/tcm_usb_gadget.c |1 -
 drivers/usb/gadget/webcam.c |1 -
 drivers/usb/gadget/zero.c   |1 -
 20 files changed, 5 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/ccg/ccg.c b/drivers/staging/ccg/ccg.c
index c379b9f..0b31369 100644
--- a/drivers/staging/ccg/ccg.c
+++ b/drivers/staging/ccg/ccg.c
@@ -44,7 +44,6 @@
  * the runtime footprint, and giving us at least some parts of what
  * a gcc --combine ... part1.c part2.c part3.c ...  build would.
  */
-#include ../../usb/gadget/config.c
 #include ../../usb/gadget/epautoconf.c
 #include composite.c
 
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 4ff3f0c..f6387b4 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -5,7 +5,7 @@ ccflags-$(CONFIG_USB_GADGET_DEBUG) := -DDEBUG
 
 obj-$(CONFIG_USB_GADGET)   += udc-core.o
 obj-$(CONFIG_USB_LIBCOMPOSITE) += libcomposite.o
-libcomposite-y := usbstring.o
+libcomposite-y := usbstring.o config.o
 obj-$(CONFIG_USB_DUMMY_HCD)+= dummy_hcd.o
 obj-$(CONFIG_USB_NET2272)  += net2272.o
 obj-$(CONFIG_USB_NET2280)  += net2280.o
diff --git a/drivers/usb/gadget/acm_ms.c b/drivers/usb/gadget/acm_ms.c
index 9820960..3078d79 100644
--- a/drivers/usb/gadget/acm_ms.c
+++ b/drivers/usb/gadget/acm_ms.c
@@ -42,7 +42,6 @@
  */
 
 #include composite.c
-#include config.c
 #include epautoconf.c
 #include u_serial.c
 #include f_acm.c
diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c
index 76e54b4..9e85df2 100644
--- a/drivers/usb/gadget/audio.c
+++ b/drivers/usb/gadget/audio.c
@@ -27,7 +27,6 @@
  * a gcc --combine ... part1.c part2.c part3.c ...  build would.
  */
 #include composite.c
-#include config.c
 #include epautoconf.c
 
 /* string IDs are assigned dynamically */
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c
index 74a9c7f..d06d079 100644
--- a/drivers/usb/gadget/cdc2.c
+++ b/drivers/usb/gadget/cdc2.c
@@ -44,7 +44,6 @@
  */
 
 #include composite.c
-#include config.c
 #include epautoconf.c
 #include u_serial.c
 #include f_acm.c
diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c
index 7542a72..e3a9892 100644
--- a/drivers/usb/gadget/config.c
+++ b/drivers/usb/gadget/config.c
@@ -12,6 +12,7 @@
 #include linux/errno.h
 #include linux/slab.h
 #include linux/kernel.h
+#include linux/module.h
 #include linux/list.h
 #include linux/string.h
 #include linux/device.h
@@ -53,7 +54,7 @@ usb_descriptor_fillbuf(void *buf, unsigned buflen,
}
return dest - (u8 *)buf;
 }
-
+EXPORT_SYMBOL_GPL(usb_descriptor_fillbuf);
 
 /**
  * usb_gadget_config_buf - builts a complete configuration descriptor
@@ -106,6 +107,7 @@ int usb_gadget_config_buf(
cp-bmAttributes |= USB_CONFIG_ATT_ONE;
return len;
 }
+EXPORT_SYMBOL_GPL(usb_gadget_config_buf);
 
 /**
  * usb_copy_descriptors - copy a vector of USB descriptors
@@ -155,4 +157,4 @@ usb_copy_descriptors(struct usb_descriptor_header **src)
 
return ret;
 }
-
+EXPORT_SYMBOL_GPL(usb_copy_descriptors);
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index e16094e..557021e 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -103,7 +103,6 @@ static inline bool has_rndis(void)
  * a gcc --combine ... part1.c part2.c part3.c ...  build would.
  */
 #include composite.c
-#include config.c
 #include epautoconf.c
 
 #include f_ecm.c
diff --git a/drivers/usb/gadget/file_storage.c 
b/drivers/usb/gadget/file_storage.c
index 8d0166b..77cf108 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -265,7 +265,6 @@
  * the runtime footprint, and giving us at least some parts of what
  * a gcc --combine ... part1.c part2.c part3.c ...  build would.
  */
-#include config.c
 #include epautoconf.c
 
 /*-*/
diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c
index 

[PATCH 04/20] usb/libcomposite: add epautoconf.c to libcomposite

2012-08-24 Thread Sebastian Andrzej Siewior
This patch adds epautoconf.c into libcomposite and updates all gadgets.

Acked-by: Michal Nazarewicz min...@mina86.com
Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de
---
 drivers/staging/ccg/ccg.c   |1 -
 drivers/usb/gadget/Makefile |2 +-
 drivers/usb/gadget/acm_ms.c |1 -
 drivers/usb/gadget/audio.c  |2 +-
 drivers/usb/gadget/cdc2.c   |1 -
 drivers/usb/gadget/dbgp.c   |3 ---
 drivers/usb/gadget/epautoconf.c |6 --
 drivers/usb/gadget/ether.c  |1 -
 drivers/usb/gadget/file_storage.c   |   13 -
 drivers/usb/gadget/g_ffs.c  |1 -
 drivers/usb/gadget/gadget_chips.h   |2 ++
 drivers/usb/gadget/gmidi.c  |1 -
 drivers/usb/gadget/hid.c|2 +-
 drivers/usb/gadget/mass_storage.c   |1 -
 drivers/usb/gadget/multi.c  |1 -
 drivers/usb/gadget/ncm.c|1 -
 drivers/usb/gadget/nokia.c  |1 -
 drivers/usb/gadget/printer.c|1 -
 drivers/usb/gadget/serial.c |1 -
 drivers/usb/gadget/tcm_usb_gadget.c |1 -
 drivers/usb/gadget/webcam.c |1 -
 drivers/usb/gadget/zero.c   |1 -
 22 files changed, 9 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/ccg/ccg.c b/drivers/staging/ccg/ccg.c
index 0b31369..1f6c249 100644
--- a/drivers/staging/ccg/ccg.c
+++ b/drivers/staging/ccg/ccg.c
@@ -44,7 +44,6 @@
  * the runtime footprint, and giving us at least some parts of what
  * a gcc --combine ... part1.c part2.c part3.c ...  build would.
  */
-#include ../../usb/gadget/epautoconf.c
 #include composite.c
 
 #include ../../usb/gadget/f_mass_storage.c
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index f6387b4..d394162 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -5,7 +5,7 @@ ccflags-$(CONFIG_USB_GADGET_DEBUG) := -DDEBUG
 
 obj-$(CONFIG_USB_GADGET)   += udc-core.o
 obj-$(CONFIG_USB_LIBCOMPOSITE) += libcomposite.o
-libcomposite-y := usbstring.o config.o
+libcomposite-y := usbstring.o config.o epautoconf.o
 obj-$(CONFIG_USB_DUMMY_HCD)+= dummy_hcd.o
 obj-$(CONFIG_USB_NET2272)  += net2272.o
 obj-$(CONFIG_USB_NET2280)  += net2280.o
diff --git a/drivers/usb/gadget/acm_ms.c b/drivers/usb/gadget/acm_ms.c
index 3078d79..5db661d 100644
--- a/drivers/usb/gadget/acm_ms.c
+++ b/drivers/usb/gadget/acm_ms.c
@@ -42,7 +42,6 @@
  */
 
 #include composite.c
-#include epautoconf.c
 #include u_serial.c
 #include f_acm.c
 #include f_mass_storage.c
diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c
index 9e85df2..689d142 100644
--- a/drivers/usb/gadget/audio.c
+++ b/drivers/usb/gadget/audio.c
@@ -14,6 +14,7 @@
 #include linux/kernel.h
 #include linux/utsname.h
 
+#include gadget_chips.h
 #define DRIVER_DESCLinux USB Audio Gadget
 #define DRIVER_VERSION Feb 2, 2012
 
@@ -27,7 +28,6 @@
  * a gcc --combine ... part1.c part2.c part3.c ...  build would.
  */
 #include composite.c
-#include epautoconf.c
 
 /* string IDs are assigned dynamically */
 
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c
index d06d079..8e386cf 100644
--- a/drivers/usb/gadget/cdc2.c
+++ b/drivers/usb/gadget/cdc2.c
@@ -44,7 +44,6 @@
  */
 
 #include composite.c
-#include epautoconf.c
 #include u_serial.c
 #include f_acm.c
 #include f_ecm.c
diff --git a/drivers/usb/gadget/dbgp.c b/drivers/usb/gadget/dbgp.c
index cc17465..87d1650 100644
--- a/drivers/usb/gadget/dbgp.c
+++ b/drivers/usb/gadget/dbgp.c
@@ -13,9 +13,6 @@
 #include linux/usb/ch9.h
 #include linux/usb/gadget.h
 
-/* See comments in zero.c */
-#include epautoconf.c
-
 #ifdef CONFIG_USB_G_DBGP_SERIAL
 #include u_serial.c
 #endif
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index d5a905d..a777f7b 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -10,6 +10,7 @@
  */
 
 #include linux/kernel.h
+#include linux/module.h
 #include linux/init.h
 #include linux/types.h
 #include linux/device.h
@@ -315,6 +316,7 @@ found_ep:
ep-comp_desc = NULL;
return ep;
 }
+EXPORT_SYMBOL_GPL(usb_ep_autoconfig_ss);
 
 /**
  * usb_ep_autoconfig() - choose an endpoint matching the
@@ -354,7 +356,7 @@ struct usb_ep *usb_ep_autoconfig(
 {
return usb_ep_autoconfig_ss(gadget, desc, NULL);
 }
-
+EXPORT_SYMBOL_GPL(usb_ep_autoconfig);
 
 /**
  * usb_ep_autoconfig_reset - reset endpoint autoconfig state
@@ -375,4 +377,4 @@ void usb_ep_autoconfig_reset (struct usb_gadget *gadget)
gadget-in_epnum = 0;
gadget-out_epnum = 0;
 }
-
+EXPORT_SYMBOL_GPL(usb_ep_autoconfig_reset);
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 557021e..39eb718 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -103,7 +103,6 @@ static inline bool has_rndis(void)
  * a gcc --combine ... part1.c part2.c part3.c ...  build 

[PATCH 06/20] usb/gadget: move USB_BUFSIZ into global composite.h

2012-08-24 Thread Sebastian Andrzej Siewior
This patch moves USB_BUFSIZ into global header file as
USB_COMP_EP0_BUFSIZ. There is currently only one user (f_sourcesink)
besides composite which need it. Ideally f_sourcesink would have its
own ep0 buffer. Lets keep it that way it was for now.

Acked-by: Michal Nazarewicz min...@mina86.com
Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de
---
 drivers/usb/gadget/composite.c|   10 --
 drivers/usb/gadget/f_sourcesink.c |2 +-
 include/linux/usb/composite.h |3 +++
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 598df69..e380a05 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -28,9 +28,6 @@
  * with the relevant device-wide data.
  */
 
-/* big enough to hold our biggest descriptor */
-#define USB_BUFSIZ 1024
-
 /* Some systems will need runtime overrides for the  product identifiers
  * published in the device descriptor, either numbers or strings or both.
  * String parameters are in UTF-8 (superset of ASCII's 7 bit characters).
@@ -355,10 +352,11 @@ static int config_buf(struct usb_configuration *config,
 {
struct usb_config_descriptor*c = buf;
void*next = buf + USB_DT_CONFIG_SIZE;
-   int len = USB_BUFSIZ - USB_DT_CONFIG_SIZE;
+   int len;
struct usb_function *f;
int status;
 
+   len = USB_COMP_EP0_BUFSIZ - USB_DT_CONFIG_SIZE;
/* write the config descriptor */
c = buf;
c-bLength = USB_DT_CONFIG_SIZE;
@@ -1445,13 +1443,13 @@ static int composite_bind(struct usb_gadget *gadget,
cdev-req = usb_ep_alloc_request(gadget-ep0, GFP_KERNEL);
if (!cdev-req)
goto fail;
-   cdev-req-buf = kmalloc(USB_BUFSIZ, GFP_KERNEL);
+   cdev-req-buf = kmalloc(USB_COMP_EP0_BUFSIZ, GFP_KERNEL);
if (!cdev-req-buf)
goto fail;
cdev-req-complete = composite_setup_complete;
gadget-ep0-driver_data = cdev;
 
-   cdev-bufsiz = USB_BUFSIZ;
+   cdev-bufsiz = USB_COMP_EP0_BUFSIZ;
cdev-driver = cdriver;
 
/*
diff --git a/drivers/usb/gadget/f_sourcesink.c 
b/drivers/usb/gadget/f_sourcesink.c
index 5c1b68b..3c126fd 100644
--- a/drivers/usb/gadget/f_sourcesink.c
+++ b/drivers/usb/gadget/f_sourcesink.c
@@ -795,7 +795,7 @@ static int sourcesink_setup(struct usb_configuration *c,
u16 w_value = le16_to_cpu(ctrl-wValue);
u16 w_length = le16_to_cpu(ctrl-wLength);
 
-   req-length = USB_BUFSIZ;
+   req-length = USB_COMP_EP0_BUFSIZ;
 
/* composite driver infrastructure handles everything except
 * the two control test requests.
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index 43d6b9c..89d91b6 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -46,6 +46,9 @@
  */
 #define USB_GADGET_DELAYED_STATUS   0x7fff /* Impossibly large value */
 
+/* big enough to hold our biggest descriptor */
+#define USB_COMP_EP0_BUFSIZ1024
+
 struct usb_configuration;
 
 /**
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/20] usb/gadget: move global vars from epautoconf into struct usb_gadget

2012-08-24 Thread Sebastian Andrzej Siewior
epautoconf has two global variables which count the endpoint number of
last assigned endpoint.
This patch removes the global variable and keeps it as per (UDC) gadget.
While here, the ifdef is removed and now the in and outpoint are
enumerated unconditionally. The dwc3 for instance supports 32 endpoints
in total.

Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de
---
 drivers/usb/gadget/epautoconf.c |   27 ++-
 include/linux/usb/gadget.h  |4 
 2 files changed, 10 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index 51f3d42..d5a905d 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -22,17 +22,6 @@
 
 #include gadget_chips.h
 
-
-/* we must assign addresses for configurable endpoints (like net2280) */
-static unsigned epnum;
-
-// #define MANY_ENDPOINTS
-#ifdef MANY_ENDPOINTS
-/* more than 15 configurable endpoints */
-static unsigned in_epnum;
-#endif
-
-
 /*
  * This should work with endpoints from controller drivers sharing the
  * same endpoint naming convention.  By example:
@@ -176,16 +165,14 @@ ep_matches (
if (isdigit (ep-name [2])) {
u8  num = simple_strtoul (ep-name [2], NULL, 10);
desc-bEndpointAddress |= num;
-#ifdef MANY_ENDPOINTS
} else if (desc-bEndpointAddress  USB_DIR_IN) {
-   if (++in_epnum  15)
+   if (++gadget-in_epnum  15)
return 0;
-   desc-bEndpointAddress = USB_DIR_IN | in_epnum;
-#endif
+   desc-bEndpointAddress = USB_DIR_IN | gadget-in_epnum;
} else {
-   if (++epnum  15)
+   if (++gadget-out_epnum  15)
return 0;
-   desc-bEndpointAddress |= epnum;
+   desc-bEndpointAddress |= gadget-out_epnum;
}
 
/* report (variable) full speed bulk maxpacket */
@@ -385,9 +372,7 @@ void usb_ep_autoconfig_reset (struct usb_gadget *gadget)
list_for_each_entry (ep, gadget-ep_list, ep_list) {
ep-driver_data = NULL;
}
-#ifdef MANY_ENDPOINTS
-   in_epnum = 0;
-#endif
-   epnum = 0;
+   gadget-in_epnum = 0;
+   gadget-out_epnum = 0;
 }
 
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index fdf85a7..40659bc 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -503,6 +503,8 @@ struct usb_gadget_ops {
  * @name: Identifies the controller hardware type.  Used in diagnostics
  * and sometimes configuration.
  * @dev: Driver model state for this abstract device.
+ * @out_epnum: last used out ep number
+ * @in_epnum: last used in ep number
  *
  * Gadgets have a mostly-portable gadget driver implementing device
  * functions, handling all usb configurations and interfaces.  Gadget
@@ -537,6 +539,8 @@ struct usb_gadget {
unsigneda_alt_hnp_support:1;
const char  *name;
struct device   dev;
+   unsignedout_epnum;
+   unsignedin_epnum;
 };
 
 static inline void set_gadget_data(struct usb_gadget *gadget, void *data)
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/20] usb/gadget: remove bufsiz from struct usb_composite_dev

2012-08-24 Thread Sebastian Andrzej Siewior
there is no read user of bufsiz, its content is available via
USB_COMP_EP0_BUFSIZ. Remove it.

Acked-by: Michal Nazarewicz min...@mina86.com
Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de
---
 drivers/usb/gadget/composite.c |1 -
 include/linux/usb/composite.h  |2 --
 2 files changed, 3 deletions(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index e380a05..0f548fe 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1449,7 +1449,6 @@ static int composite_bind(struct usb_gadget *gadget,
cdev-req-complete = composite_setup_complete;
gadget-ep0-driver_data = cdev;
 
-   cdev-bufsiz = USB_COMP_EP0_BUFSIZ;
cdev-driver = cdriver;
 
/*
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index 89d91b6..e970fba 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -318,7 +318,6 @@ extern void usb_composite_setup_continue(struct 
usb_composite_dev *cdev);
  * struct usb_composite_device - represents one composite usb gadget
  * @gadget: read-only, abstracts the gadget's usb peripheral controller
  * @req: used for control responses; buffer is pre-allocated
- * @bufsiz: size of buffer pre-allocated in @req
  * @config: the currently active configuration
  *
  * One of these devices is allocated and initialized before the
@@ -349,7 +348,6 @@ extern void usb_composite_setup_continue(struct 
usb_composite_dev *cdev);
 struct usb_composite_dev {
struct usb_gadget   *gadget;
struct usb_request  *req;
-   unsignedbufsiz;
 
struct usb_configuration*config;
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/20] usb/gadget: make composite module options readonly only

2012-08-24 Thread Sebastian Andrzej Siewior
This is a partly revert of 4fffd6e5 (usb: gadget: composite: make
module parameters accessible at runtime).
It is not possible to change the VID or other property for a gadget
right now. This change has been made for Anrdoid gadget which has this
functionality in its copy of the file. This function is executed currently
only once and most caller in tree are __init.

Acked-by: Michal Nazarewicz min...@mina86.com
Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de
---
 drivers/usb/gadget/composite.c |   20 
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 0f548fe..153efc4 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -34,27 +34,27 @@
  */
 
 static ushort idVendor;
-module_param(idVendor, ushort, 0644);
+module_param(idVendor, ushort, S_IRUGO);
 MODULE_PARM_DESC(idVendor, USB Vendor ID);
 
 static ushort idProduct;
-module_param(idProduct, ushort, 0644);
+module_param(idProduct, ushort, S_IRUGO);
 MODULE_PARM_DESC(idProduct, USB Product ID);
 
 static ushort bcdDevice;
-module_param(bcdDevice, ushort, 0644);
+module_param(bcdDevice, ushort, S_IRUGO);
 MODULE_PARM_DESC(bcdDevice, USB Device version (BCD));
 
 static char *iManufacturer;
-module_param(iManufacturer, charp, 0644);
+module_param(iManufacturer, charp, S_IRUGO);
 MODULE_PARM_DESC(iManufacturer, USB Manufacturer string);
 
 static char *iProduct;
-module_param(iProduct, charp, 0644);
+module_param(iProduct, charp, S_IRUGO);
 MODULE_PARM_DESC(iProduct, USB Product string);
 
 static char *iSerialNumber;
-module_param(iSerialNumber, charp, 0644);
+module_param(iSerialNumber, charp, S_IRUGO);
 MODULE_PARM_DESC(iSerialNumber, SerialNumber string);
 
 static char composite_manufacturer[50];
@@ -1478,16 +1478,12 @@ static int composite_bind(struct usb_gadget *gadget,
/* standardized runtime overrides for device ID data */
if (idVendor)
cdev-desc.idVendor = cpu_to_le16(idVendor);
-   else
-   idVendor = le16_to_cpu(cdev-desc.idVendor);
+
if (idProduct)
cdev-desc.idProduct = cpu_to_le16(idProduct);
-   else
-   idProduct = le16_to_cpu(cdev-desc.idProduct);
+
if (bcdDevice)
cdev-desc.bcdDevice = cpu_to_le16(bcdDevice);
-   else
-   bcdDevice = le16_to_cpu(cdev-desc.bcdDevice);
 
/* string overrides */
if (iManufacturer || !cdev-desc.iManufacturer) {
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/20] staging/ccg: make composite.c function static and remove unsused

2012-08-24 Thread Sebastian Andrzej Siewior
The next step is to move composite.c into the library. Since the Android
gadget has its composite.c copy this make makes sure both symbols do not
clash by making the symbols static. The unused functions are removed.
This patch also provides a local copy of composite.h because the
prototype is now different due to the static attribute.

Cc: de...@driverdev.osuosl.org
Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de
---
 drivers/staging/ccg/ccg.c   |2 +-
 drivers/staging/ccg/composite.c |  117 ++---
 drivers/staging/ccg/composite.h |  368 +++
 3 files changed, 379 insertions(+), 108 deletions(-)
 create mode 100644 drivers/staging/ccg/composite.h

diff --git a/drivers/staging/ccg/ccg.c b/drivers/staging/ccg/ccg.c
index 1f6c249..453c0ea 100644
--- a/drivers/staging/ccg/ccg.c
+++ b/drivers/staging/ccg/ccg.c
@@ -32,9 +32,9 @@
 #include linux/platform_device.h
 
 #include linux/usb/ch9.h
-#include linux/usb/composite.h
 #include linux/usb/gadget.h
 
+#include composite.h
 #include gadget_chips.h
 
 /*
diff --git a/drivers/staging/ccg/composite.c b/drivers/staging/ccg/composite.c
index 9391f3b..f00b0388 100644
--- a/drivers/staging/ccg/composite.c
+++ b/drivers/staging/ccg/composite.c
@@ -112,7 +112,7 @@ next_ep_desc(struct usb_descriptor_header **t)
  * Note: the supplied function should hold all the descriptors
  * for supported speeds
  */
-int config_ep_by_speed(struct usb_gadget *g,
+static int config_ep_by_speed(struct usb_gadget *g,
struct usb_function *f,
struct usb_ep *_ep)
 {
@@ -206,7 +206,7 @@ ep_found:
  * This function returns the value of the function's bind(), which is
  * zero for success else a negative errno value.
  */
-int usb_add_function(struct usb_configuration *config,
+static int usb_add_function(struct usb_configuration *config,
struct usb_function *function)
 {
int value = -EINVAL;
@@ -251,72 +251,6 @@ done:
 }
 
 /**
- * usb_function_deactivate - prevent function and gadget enumeration
- * @function: the function that isn't yet ready to respond
- *
- * Blocks response of the gadget driver to host enumeration by
- * preventing the data line pullup from being activated.  This is
- * normally called during @bind() processing to change from the
- * initial ready to respond state, or when a required resource
- * becomes available.
- *
- * For example, drivers that serve as a passthrough to a userspace
- * daemon can block enumeration unless that daemon (such as an OBEX,
- * MTP, or print server) is ready to handle host requests.
- *
- * Not all systems support software control of their USB peripheral
- * data pullups.
- *
- * Returns zero on success, else negative errno.
- */
-int usb_function_deactivate(struct usb_function *function)
-{
-   struct usb_composite_dev*cdev = function-config-cdev;
-   unsigned long   flags;
-   int status = 0;
-
-   spin_lock_irqsave(cdev-lock, flags);
-
-   if (cdev-deactivations == 0)
-   status = usb_gadget_disconnect(cdev-gadget);
-   if (status == 0)
-   cdev-deactivations++;
-
-   spin_unlock_irqrestore(cdev-lock, flags);
-   return status;
-}
-
-/**
- * usb_function_activate - allow function and gadget enumeration
- * @function: function on which usb_function_activate() was called
- *
- * Reverses effect of usb_function_deactivate().  If no more functions
- * are delaying their activation, the gadget driver will respond to
- * host enumeration procedures.
- *
- * Returns zero on success, else negative errno.
- */
-int usb_function_activate(struct usb_function *function)
-{
-   struct usb_composite_dev*cdev = function-config-cdev;
-   unsigned long   flags;
-   int status = 0;
-
-   spin_lock_irqsave(cdev-lock, flags);
-
-   if (WARN_ON(cdev-deactivations == 0))
-   status = -EINVAL;
-   else {
-   cdev-deactivations--;
-   if (cdev-deactivations == 0)
-   status = usb_gadget_connect(cdev-gadget);
-   }
-
-   spin_unlock_irqrestore(cdev-lock, flags);
-   return status;
-}
-
-/**
  * usb_interface_id() - allocate an unused interface ID
  * @config: configuration associated with the interface
  * @function: function handling the interface
@@ -339,7 +273,7 @@ int usb_function_activate(struct usb_function *function)
  * Returns the interface ID which was allocated; or -ENODEV if no
  * more interface IDs can be allocated.
  */
-int usb_interface_id(struct usb_configuration *config,
+static int usb_interface_id(struct usb_configuration *config,
struct usb_function *function)
 {
unsigned id = config-next_interface_id;
@@ -710,7 +644,7 @@ done:
  * assigns global resources including string IDs, and per-configuration
  * resources such as interface 

[PATCH 11/20] usb/gadget: make g_printer enumerate again

2012-08-24 Thread Sebastian Andrzej Siewior
This was broken in 2e87edf49 (usb: gadget: make g_printer use
composite).
The USB-strings were not setup properly and were not used. No function
was added which results in an empty USB config.
While fixing this, the interface number is now auto generated and not
hard coded to 0.

Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de
---
 drivers/usb/gadget/printer.c |  123 +-
 1 file changed, 61 insertions(+), 62 deletions(-)

diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c
index 39279e2..aeeeae2 100644
--- a/drivers/usb/gadget/printer.c
+++ b/drivers/usb/gadget/printer.c
@@ -139,18 +139,14 @@ module_param(qlen, uint, S_IRUGO|S_IWUSR);
  * descriptors are built on demand.
  */
 
-#define STRING_MANUFACTURER1
-#define STRING_PRODUCT 2
-#define STRING_SERIALNUM   3
+#define STRING_MANUFACTURER0
+#define STRING_PRODUCT 1
+#define STRING_SERIALNUM   2
 
 /* holds our biggest descriptor */
 #define USB_DESC_BUFSIZE   256
 #define USB_BUFSIZE8192
 
-/* This device advertises one configuration. */
-#define DEV_CONFIG_VALUE   1
-#definePRINTER_INTERFACE   0
-
 static struct usb_device_descriptor device_desc = {
.bLength =  sizeof device_desc,
.bDescriptorType =  USB_DT_DEVICE,
@@ -160,16 +156,12 @@ static struct usb_device_descriptor device_desc = {
.bDeviceProtocol =  0,
.idVendor = cpu_to_le16(PRINTER_VENDOR_NUM),
.idProduct =cpu_to_le16(PRINTER_PRODUCT_NUM),
-   .iManufacturer =STRING_MANUFACTURER,
-   .iProduct = STRING_PRODUCT,
-   .iSerialNumber =STRING_SERIALNUM,
.bNumConfigurations =   1
 };
 
 static struct usb_interface_descriptor intf_desc = {
.bLength =  sizeof intf_desc,
.bDescriptorType =  USB_DT_INTERFACE,
-   .bInterfaceNumber = PRINTER_INTERFACE,
.bNumEndpoints =2,
.bInterfaceClass =  USB_CLASS_PRINTER,
.bInterfaceSubClass =   1,  /* Printer Sub-Class */
@@ -258,9 +250,9 @@ static char pnp_string [1024] =
 
 /* static strings, in UTF-8 */
 static struct usb_string   strings [] = {
-   { STRING_MANUFACTURER,  manufacturer, },
-   { STRING_PRODUCT,   product_desc, },
-   { STRING_SERIALNUM, serial_num, },
+   [STRING_MANUFACTURER].s = manufacturer,
+   [STRING_PRODUCT].s = product_desc,
+   [STRING_SERIALNUM].s =  serial_num,
{  }/* end of list */
 };
 
@@ -869,25 +861,13 @@ static int set_interface(struct printer_dev *dev, 
unsigned number)
int result = 0;
 
/* Free the current interface */
-   switch (dev-interface) {
-   case PRINTER_INTERFACE:
-   printer_reset_interface(dev);
-   break;
-   }
+   printer_reset_interface(dev);
 
-   switch (number) {
-   case PRINTER_INTERFACE:
-   result = set_printer_interface(dev);
-   if (result) {
-   printer_reset_interface(dev);
-   } else {
-   dev-interface = PRINTER_INTERFACE;
-   }
-   break;
-   default:
-   result = -EINVAL;
-   /* FALL THROUGH */
-   }
+   result = set_printer_interface(dev);
+   if (result)
+   printer_reset_interface(dev);
+   else
+   dev-interface = number;
 
if (!result)
INFO(dev, Using interface %x\n, number);
@@ -970,7 +950,7 @@ static int printer_func_setup(struct usb_function *f,
switch (ctrl-bRequest) {
case 0: /* Get the IEEE-1284 PNP String */
/* Only one printer interface is supported. */
-   if ((wIndex8) != PRINTER_INTERFACE)
+   if ((wIndex8) != dev-interface)
break;
 
value = (pnp_string[0]8)|pnp_string[1];
@@ -981,7 +961,7 @@ static int printer_func_setup(struct usb_function *f,
 
case 1: /* Get Port Status */
/* Only one printer interface is supported. */
-   if (wIndex != PRINTER_INTERFACE)
+   if (wIndex != dev-interface)
break;
 
*(u8 *)req-buf = dev-printer_status;
@@ -990,7 +970,7 @@ static int printer_func_setup(struct usb_function *f,
 
case 2: /* Soft Reset */
/* Only one printer interface is supported. */
-   if (wIndex != PRINTER_INTERFACE)
+   if (wIndex != dev-interface)
break;
 
printer_soft_reset(dev);

[PATCH 17/20] usb/composite: remove unsused composite_manufacturer variable

2012-08-24 Thread Sebastian Andrzej Siewior
Since the last patch composite_manufacturer is unused because all
gadgets provide a iManufacturer property so remove it.

Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de
---
 drivers/usb/gadget/composite.c |   15 ++-
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 9c09cf6..2ce92c9 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -37,8 +37,6 @@ static char *iProduct;
 module_param(iProduct, charp, S_IRUGO);
 MODULE_PARM_DESC(iProduct, USB Product string);
 
-static char composite_manufacturer[50];
-
 /*-*/
 /**
  * next_ep_desc() - advance to the next EP descriptor
@@ -913,7 +911,7 @@ static int get_string(struct usb_composite_dev *cdev,
 * check if the string has not been overridden.
 */
if (cdev-manufacturer_override == id)
-   str = cdriver-iManufacturer ?: composite_manufacturer;
+   str = cdriver-iManufacturer;
else if (cdev-product_override == id)
str = iProduct ?: cdriver-iProduct;
else if (cdev-serial_override == id)
@@ -1456,18 +1454,9 @@ static int composite_bind(struct usb_gadget *gadget,
cdev-desc = *cdriver-dev;
 
/* string overrides */
-   if (!cdev-desc.iManufacturer) {
-   if (!cdriver-iManufacturer)
-   snprintf(composite_manufacturer,
-sizeof composite_manufacturer,
-%s %s with %s,
-init_utsname()-sysname,
-init_utsname()-release,
-gadget-name);
-
+   if (!cdev-desc.iManufacturer  cdriver-iManufacturer)
cdev-manufacturer_override =
override_id(cdev, cdev-desc.iManufacturer);
-   }
 
if (iProduct || (!cdev-desc.iProduct  cdriver-iProduct))
cdev-product_override =
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 18/20] usb/gadget: push iProduct into gadgets

2012-08-24 Thread Sebastian Andrzej Siewior
This patch pushes the iProduct module argument from composite into
each gadget.

Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de
---
 drivers/usb/gadget/acm_ms.c |3 ++-
 drivers/usb/gadget/audio.c  |2 ++
 drivers/usb/gadget/cdc2.c   |2 ++
 drivers/usb/gadget/composite.c  |   13 ++---
 drivers/usb/gadget/ether.c  |2 ++
 drivers/usb/gadget/g_ffs.c  |4 
 drivers/usb/gadget/gmidi.c  |2 ++
 drivers/usb/gadget/hid.c|2 ++
 drivers/usb/gadget/mass_storage.c   |5 +
 drivers/usb/gadget/multi.c  |7 +--
 drivers/usb/gadget/ncm.c|2 ++
 drivers/usb/gadget/nokia.c  |2 ++
 drivers/usb/gadget/printer.c|3 +++
 drivers/usb/gadget/serial.c |2 ++
 drivers/usb/gadget/tcm_usb_gadget.c |2 ++
 drivers/usb/gadget/webcam.c |2 ++
 drivers/usb/gadget/zero.c   |2 ++
 include/linux/usb/composite.h   |6 +-
 18 files changed, 48 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/gadget/acm_ms.c b/drivers/usb/gadget/acm_ms.c
index 6986d4c..e18e7cf 100644
--- a/drivers/usb/gadget/acm_ms.c
+++ b/drivers/usb/gadget/acm_ms.c
@@ -64,7 +64,6 @@ static struct usb_device_descriptor device_desc = {
.idVendor = cpu_to_le16(ACM_MS_VENDOR_NUM),
.idProduct =cpu_to_le16(ACM_MS_PRODUCT_NUM),
/* .bcdDevice = f(hardware) */
-   /* .iProduct = DYNAMIC */
/* NO SERIAL NUMBER */
/*.bNumConfigurations = DYNAMIC*/
 };
@@ -209,6 +208,8 @@ static int __init acm_ms_bind(struct usb_composite_dev 
*cdev)
else
strings_dev[STRING_MANUFACTURER_IDX].s =
composite_default_mfr(gadget);
+   if (iProduct)
+   strings_dev[STRING_PRODUCT_IDX].s = iProduct;
 
dev_info(gadget-dev, %s, version:  DRIVER_VERSION \n,
DRIVER_DESC);
diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c
index f9b6a82..e1dc15f 100644
--- a/drivers/usb/gadget/audio.c
+++ b/drivers/usb/gadget/audio.c
@@ -181,6 +181,8 @@ static int __init audio_bind(struct usb_composite_dev *cdev)
else
strings_dev[STRING_MANUFACTURER_IDX].s =
composite_default_mfr(cdev-gadget);
+   if (iProduct)
+   strings_dev[STRING_PRODUCT_IDX].s = iProduct;
 
INFO(cdev, %s, version: %s\n, DRIVER_DESC, DRIVER_VERSION);
return 0;
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c
index 708f17c..766ca2d 100644
--- a/drivers/usb/gadget/cdc2.c
+++ b/drivers/usb/gadget/cdc2.c
@@ -207,6 +207,8 @@ static int __init cdc_bind(struct usb_composite_dev *cdev)
else
strings_dev[STRING_MANUFACTURER_IDX].s =
composite_default_mfr(gadget);
+   if (iProduct)
+   strings_dev[STRING_PRODUCT_IDX].s = iProduct;
 
USB_GADGET_COMPOSITE_OVERWRITE_OPTIONS(device_desc);
dev_info(gadget-dev, %s, version:  DRIVER_VERSION \n,
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 2ce92c9..487e912 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -28,15 +28,6 @@
  * with the relevant device-wide data.
  */
 
-/* Some systems will need runtime overrides for the  product identifiers
- * published in the device descriptor, either numbers or strings or both.
- * String parameters are in UTF-8 (superset of ASCII's 7 bit characters).
- */
-
-static char *iProduct;
-module_param(iProduct, charp, S_IRUGO);
-MODULE_PARM_DESC(iProduct, USB Product string);
-
 /*-*/
 /**
  * next_ep_desc() - advance to the next EP descriptor
@@ -913,7 +904,7 @@ static int get_string(struct usb_composite_dev *cdev,
if (cdev-manufacturer_override == id)
str = cdriver-iManufacturer;
else if (cdev-product_override == id)
-   str = iProduct ?: cdriver-iProduct;
+   str = cdriver-iProduct;
else if (cdev-serial_override == id)
str = cdriver-iSerialNumber;
else
@@ -1458,7 +1449,7 @@ static int composite_bind(struct usb_gadget *gadget,
cdev-manufacturer_override =
override_id(cdev, cdev-desc.iManufacturer);
 
-   if (iProduct || (!cdev-desc.iProduct  cdriver-iProduct))
+   if (!cdev-desc.iProduct  cdriver-iProduct)
cdev-product_override =
override_id(cdev, cdev-desc.iProduct);
 
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 513c309..09d4156 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -367,6 +367,8 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
else
strings_dev[STRING_MANUFACTURER_IDX].s =

[PATCH 16/20] usb/gadgets: make sure all gadgets provide an iManufacturer string

2012-08-24 Thread Sebastian Andrzej Siewior
A few gadgets provide a harcoded string in case the module parameter was
not used.
If nothing is provided then composite_bind() creates a string which is
based on the kernel version and UDC's name. Some gadget create the exact
same sting.
This patch moves the creation of the string into
composite_default_mfr().

Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de
---
 drivers/usb/gadget/acm_ms.c |   17 +++--
 drivers/usb/gadget/audio.c  |   14 ++
 drivers/usb/gadget/cdc2.c   |   15 ++-
 drivers/usb/gadget/composite.c  |   22 ++
 drivers/usb/gadget/ether.c  |   16 ++--
 drivers/usb/gadget/f_hid.c  |1 -
 drivers/usb/gadget/f_mass_storage.c |1 -
 drivers/usb/gadget/f_midi.c |1 -
 drivers/usb/gadget/g_ffs.c  |   12 +++-
 drivers/usb/gadget/gmidi.c  |1 -
 drivers/usb/gadget/hid.c|   15 ++-
 drivers/usb/gadget/mass_storage.c   |   17 -
 drivers/usb/gadget/multi.c  |   12 +++-
 drivers/usb/gadget/ncm.c|   16 ++--
 drivers/usb/gadget/nokia.c  |1 -
 drivers/usb/gadget/printer.c|   14 ++
 drivers/usb/gadget/serial.c |   21 -
 drivers/usb/gadget/zero.c   |   15 ++-
 18 files changed, 109 insertions(+), 102 deletions(-)

diff --git a/drivers/usb/gadget/acm_ms.c b/drivers/usb/gadget/acm_ms.c
index 51fc568..6986d4c 100644
--- a/drivers/usb/gadget/acm_ms.c
+++ b/drivers/usb/gadget/acm_ms.c
@@ -15,7 +15,6 @@
  */
 
 #include linux/kernel.h
-#include linux/utsname.h
 
 #include u_serial.h
 
@@ -93,10 +92,8 @@ static const struct usb_descriptor_header *otg_desc[] = {
 #define STRING_PRODUCT_IDX 1
 #define STRING_PRODUCT_SERIAL  2
 
-static char manufacturer[50];
-
 static struct usb_string strings_dev[] = {
-   [STRING_MANUFACTURER_IDX].s = manufacturer,
+   [STRING_MANUFACTURER_IDX].s = ,
[STRING_PRODUCT_IDX].s = DRIVER_DESC,
[STRING_PRODUCT_SERIAL].s = ,
{  } /* end of list */
@@ -190,10 +187,6 @@ static int __init acm_ms_bind(struct usb_composite_dev 
*cdev)
 * contents can be overridden by the composite_dev glue.
 */
 
-   /* device descriptor strings: manufacturer, product */
-   snprintf(manufacturer, sizeof manufacturer, %s %s with %s,
-   init_utsname()-sysname, init_utsname()-release,
-   gadget-name);
status = usb_string_ids_tab(cdev, strings_dev);
if (status  0)
goto fail1;
@@ -212,7 +205,10 @@ static int __init acm_ms_bind(struct usb_composite_dev 
*cdev)
strings_dev[STRING_PRODUCT_SERIAL].id;
}
if (iManufacturer)
-strings_dev[STRING_MANUFACTURER_IDX].s = iManufacturer;
+   strings_dev[STRING_MANUFACTURER_IDX].s = iManufacturer;
+   else
+   strings_dev[STRING_MANUFACTURER_IDX].s =
+   composite_default_mfr(gadget);
 
dev_info(gadget-dev, %s, version:  DRIVER_VERSION \n,
DRIVER_DESC);
@@ -230,7 +226,8 @@ fail0:
 static int __exit acm_ms_unbind(struct usb_composite_dev *cdev)
 {
gserial_cleanup();
-
+   if (!iManufacturer)
+   kfree(strings_dev[STRING_MANUFACTURER_IDX].s);
return 0;
 }
 
diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c
index d598e32..f9b6a82 100644
--- a/drivers/usb/gadget/audio.c
+++ b/drivers/usb/gadget/audio.c
@@ -12,7 +12,6 @@
 /* #define VERBOSE_DEBUG */
 
 #include linux/kernel.h
-#include linux/utsname.h
 #include linux/usb/composite.h
 
 #include gadget_chips.h
@@ -37,10 +36,8 @@ USB_GADGET_COMPOSITE_OPTIONS();
 #define STRING_PRODUCT_IDX 1
 #define STRING_PRODUCT_SERIAL  2
 
-static char manufacturer[50];
-
 static struct usb_string strings_dev[] = {
-   [STRING_MANUFACTURER_IDX].s = manufacturer,
+   [STRING_MANUFACTURER_IDX].s = ,
[STRING_PRODUCT_IDX].s = DRIVER_DESC,
[STRING_PRODUCT_SERIAL].s = ,
{  } /* end of list */
@@ -164,10 +161,6 @@ static int __init audio_bind(struct usb_composite_dev 
*cdev)
__constant_cpu_to_le16(0x0300 | 0x0099);
}
 
-   /* device descriptor strings: manufacturer, product */
-   snprintf(manufacturer, sizeof manufacturer, %s %s with %s,
-   init_utsname()-sysname, init_utsname()-release,
-   cdev-gadget-name);
status = usb_string_ids_tab(cdev, strings_dev);
if (status  0)
goto fail;
@@ -185,6 +178,9 @@ static int __init audio_bind(struct usb_composite_dev *cdev)
}
if (iManufacturer)
strings_dev[STRING_MANUFACTURER_IDX].s = iManufacturer;
+   else
+   strings_dev[STRING_MANUFACTURER_IDX].s =
+   

[PATCH 14/20] usb/gadget: push iSerialNumber into gadgets

2012-08-24 Thread Sebastian Andrzej Siewior
This patch pushes the iSerialNumber module argument from composite into
each gadget. Each gadgets holds a dummy strings in its struct
usb_string to ensure that usb_string_ids_tab() allocates a valid id.
Once the user uses the module paramter, the string is overwritten with
the final value.
This is mostly the same change in each gadget with some minor
exceptions:
- printer accepts two arguments: iSerialNumber like everyone else and
  iSerialNum which was used before it was converted to composite
- g_ffs got a few ifdefs and an enum in order to get the proper index
- mass_storage: gained a struct usb_gadget_strings

Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de
---
 drivers/usb/gadget/acm_ms.c |7 +++
 drivers/usb/gadget/audio.c  |7 +++
 drivers/usb/gadget/cdc2.c   |7 +++
 drivers/usb/gadget/composite.c  |   10 +++---
 drivers/usb/gadget/ether.c  |8 
 drivers/usb/gadget/g_ffs.c  |   27 ---
 drivers/usb/gadget/gmidi.c  |7 +++
 drivers/usb/gadget/hid.c|8 
 drivers/usb/gadget/mass_storage.c   |   26 ++
 drivers/usb/gadget/multi.c  |7 +++
 drivers/usb/gadget/ncm.c|8 
 drivers/usb/gadget/nokia.c  |8 
 drivers/usb/gadget/printer.c|9 -
 drivers/usb/gadget/serial.c |6 ++
 drivers/usb/gadget/tcm_usb_gadget.c |2 ++
 drivers/usb/gadget/webcam.c |7 +++
 drivers/usb/gadget/zero.c   |2 ++
 include/linux/usb/composite.h   |6 +-
 18 files changed, 146 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/gadget/acm_ms.c b/drivers/usb/gadget/acm_ms.c
index f34be59..63ef563 100644
--- a/drivers/usb/gadget/acm_ms.c
+++ b/drivers/usb/gadget/acm_ms.c
@@ -92,12 +92,14 @@ static const struct usb_descriptor_header *otg_desc[] = {
 
 #define STRING_MANUFACTURER_IDX0
 #define STRING_PRODUCT_IDX 1
+#define STRING_PRODUCT_SERIAL  2
 
 static char manufacturer[50];
 
 static struct usb_string strings_dev[] = {
[STRING_MANUFACTURER_IDX].s = manufacturer,
[STRING_PRODUCT_IDX].s = DRIVER_DESC,
+   [STRING_PRODUCT_SERIAL].s = ,
{  } /* end of list */
 };
 
@@ -205,6 +207,11 @@ static int __init acm_ms_bind(struct usb_composite_dev 
*cdev)
goto fail1;
 
USB_GADGET_COMPOSITE_OVERWRITE_OPTIONS(device_desc);
+   if (iSerialNumber) {
+   strings_dev[STRING_PRODUCT_SERIAL].s = iSerialNumber;
+   device_desc.iSerialNumber =
+   strings_dev[STRING_PRODUCT_SERIAL].id;
+   }
dev_info(gadget-dev, %s, version:  DRIVER_VERSION \n,
DRIVER_DESC);
fsg_common_put(fsg_common);
diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c
index 2dc6d63..336206d 100644
--- a/drivers/usb/gadget/audio.c
+++ b/drivers/usb/gadget/audio.c
@@ -35,12 +35,14 @@ USB_GADGET_COMPOSITE_OPTIONS();
 
 #define STRING_MANUFACTURER_IDX0
 #define STRING_PRODUCT_IDX 1
+#define STRING_PRODUCT_SERIAL  2
 
 static char manufacturer[50];
 
 static struct usb_string strings_dev[] = {
[STRING_MANUFACTURER_IDX].s = manufacturer,
[STRING_PRODUCT_IDX].s = DRIVER_DESC,
+   [STRING_PRODUCT_SERIAL].s = ,
{  } /* end of list */
 };
 
@@ -177,6 +179,11 @@ static int __init audio_bind(struct usb_composite_dev 
*cdev)
if (status  0)
goto fail;
USB_GADGET_COMPOSITE_OVERWRITE_OPTIONS(device_desc);
+   if (iSerialNumber) {
+   strings_dev[STRING_PRODUCT_SERIAL].s = iSerialNumber;
+   device_desc.iSerialNumber =
+   strings_dev[STRING_PRODUCT_SERIAL].id;
+   }
 
INFO(cdev, %s, version: %s\n, DRIVER_DESC, DRIVER_VERSION);
return 0;
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c
index 03752db..692f817 100644
--- a/drivers/usb/gadget/cdc2.c
+++ b/drivers/usb/gadget/cdc2.c
@@ -93,12 +93,14 @@ static const struct usb_descriptor_header *otg_desc[] = {
 
 #define STRING_MANUFACTURER_IDX0
 #define STRING_PRODUCT_IDX 1
+#define STRING_PRODUCT_SERIAL  2
 
 static char manufacturer[50];
 
 static struct usb_string strings_dev[] = {
[STRING_MANUFACTURER_IDX].s = manufacturer,
[STRING_PRODUCT_IDX].s = DRIVER_DESC,
+   [STRING_PRODUCT_SERIAL].s = ,
{  } /* end of list */
 };
 
@@ -204,6 +206,11 @@ static int __init cdc_bind(struct usb_composite_dev *cdev)
status = usb_add_config(cdev, cdc_config_driver, cdc_do_config);
if (status  0)
goto fail1;
+   if (iSerialNumber) {
+   strings_dev[STRING_PRODUCT_SERIAL].s = iSerialNumber;
+   device_desc.iSerialNumber =
+   

[PATCH 19/20] usb/libcomposite: move composite.c into libcomposite

2012-08-24 Thread Sebastian Andrzej Siewior
This moves composite.c into libcomposite and updates all gadgets.
Finally!

Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de
---
 drivers/usb/gadget/Makefile |3 ++-
 drivers/usb/gadget/acm_ms.c |2 +-
 drivers/usb/gadget/audio.c  |   11 +--
 drivers/usb/gadget/cdc2.c   |1 -
 drivers/usb/gadget/composite.c  |   15 +--
 drivers/usb/gadget/ether.c  |2 --
 drivers/usb/gadget/f_hid.c  |1 +
 drivers/usb/gadget/g_ffs.c  |3 ---
 drivers/usb/gadget/gmidi.c  |2 +-
 drivers/usb/gadget/hid.c|5 ++---
 drivers/usb/gadget/mass_storage.c   |4 +---
 drivers/usb/gadget/multi.c  |3 ---
 drivers/usb/gadget/ncm.c|4 ++--
 drivers/usb/gadget/nokia.c  |2 --
 drivers/usb/gadget/printer.c|   12 +---
 drivers/usb/gadget/serial.c |2 --
 drivers/usb/gadget/tcm_usb_gadget.c |2 --
 drivers/usb/gadget/webcam.c |2 --
 drivers/usb/gadget/zero.c   |2 --
 include/linux/usb/composite.h   |1 +
 20 files changed, 26 insertions(+), 53 deletions(-)

diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index d3d1950..4e6f876 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -5,7 +5,8 @@ ccflags-$(CONFIG_USB_GADGET_DEBUG) := -DDEBUG
 
 obj-$(CONFIG_USB_GADGET)   += udc-core.o
 obj-$(CONFIG_USB_LIBCOMPOSITE) += libcomposite.o
-libcomposite-y := usbstring.o config.o epautoconf.o 
gadget_chips.o
+libcomposite-y := usbstring.o config.o epautoconf.o
+libcomposite-y += gadget_chips.o composite.o
 obj-$(CONFIG_USB_DUMMY_HCD)+= dummy_hcd.o
 obj-$(CONFIG_USB_NET2272)  += net2272.o
 obj-$(CONFIG_USB_NET2280)  += net2280.o
diff --git a/drivers/usb/gadget/acm_ms.c b/drivers/usb/gadget/acm_ms.c
index e18e7cf..8fb6cb5 100644
--- a/drivers/usb/gadget/acm_ms.c
+++ b/drivers/usb/gadget/acm_ms.c
@@ -15,6 +15,7 @@
  */
 
 #include linux/kernel.h
+#include linux/module.h
 
 #include u_serial.h
 
@@ -40,7 +41,6 @@
  * a gcc --combine ... part1.c part2.c part3.c ...  build would.
  */
 
-#include composite.c
 #include u_serial.c
 #include f_acm.c
 #include f_mass_storage.c
diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c
index e1dc15f..461076c 100644
--- a/drivers/usb/gadget/audio.c
+++ b/drivers/usb/gadget/audio.c
@@ -12,22 +12,13 @@
 /* #define VERBOSE_DEBUG */
 
 #include linux/kernel.h
+#include linux/module.h
 #include linux/usb/composite.h
 
 #include gadget_chips.h
 #define DRIVER_DESCLinux USB Audio Gadget
 #define DRIVER_VERSION Feb 2, 2012
 
-/*-*/
-
-/*
- * Kbuild is not very cooperative with respect to linking separately
- * compiled library objects into one module.  So for now we won't use
- * separate compilation ... ensuring init/exit sections work to shrink
- * the runtime footprint, and giving us at least some parts of what
- * a gcc --combine ... part1.c part2.c part3.c ...  build would.
- */
-#include composite.c
 USB_GADGET_COMPOSITE_OPTIONS();
 
 /* string IDs are assigned dynamically */
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c
index 766ca2d..a92c5a5 100644
--- a/drivers/usb/gadget/cdc2.c
+++ b/drivers/usb/gadget/cdc2.c
@@ -43,7 +43,6 @@ USB_GADGET_COMPOSITE_OPTIONS();
  * a gcc --combine ... part1.c part2.c part3.c ...  build would.
  */
 
-#include composite.c
 #include u_serial.c
 #include f_acm.c
 #include f_ecm.c
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 487e912..5431c29 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -155,6 +155,7 @@ ep_found:
}
return 0;
 }
+EXPORT_PER_CPU_SYMBOL_GPL(config_ep_by_speed);
 
 /**
  * usb_add_function() - add a function to a configuration
@@ -213,6 +214,7 @@ done:
function-name, function, value);
return value;
 }
+EXPORT_SYMBOL_GPL(usb_add_function);
 
 /**
  * usb_function_deactivate - prevent function and gadget enumeration
@@ -249,6 +251,7 @@ int usb_function_deactivate(struct usb_function *function)
spin_unlock_irqrestore(cdev-lock, flags);
return status;
 }
+EXPORT_SYMBOL_GPL(usb_function_deactivate);
 
 /**
  * usb_function_activate - allow function and gadget enumeration
@@ -279,6 +282,7 @@ int usb_function_activate(struct usb_function *function)
spin_unlock_irqrestore(cdev-lock, flags);
return status;
 }
+EXPORT_SYMBOL_GPL(usb_function_activate);
 
 /**
  * usb_interface_id() - allocate an unused interface ID
@@ -315,6 +319,7 @@ int usb_interface_id(struct usb_configuration *config,
}
return -ENODEV;
 }
+EXPORT_SYMBOL_GPL(usb_interface_id);
 
 static int config_buf(struct usb_configuration *config,
enum 

[PATCH 20/20] usb/libcomposite: move MODULE_VERSION to composite.c

2012-08-24 Thread Sebastian Andrzej Siewior
MODULE_VERSION and AUTHOR looks better in composite.c than in
usbstrings.c so I move it there.
I put David Brownell as the module Author as I belive he wrote most of
it.

Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de
---
 drivers/usb/gadget/composite.c |3 +++
 drivers/usb/gadget/usbstring.c |1 -
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 5431c29..17eb5e3 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1674,3 +1674,6 @@ void usb_composite_setup_continue(struct 
usb_composite_dev *cdev)
spin_unlock_irqrestore(cdev-lock, flags);
 }
 EXPORT_SYMBOL_GPL(usb_composite_setup_continue);
+
+MODULE_LICENSE(GPL);
+MODULE_AUTHOR(David Brownell);
diff --git a/drivers/usb/gadget/usbstring.c b/drivers/usb/gadget/usbstring.c
index 24e9bbd..1f49fce 100644
--- a/drivers/usb/gadget/usbstring.c
+++ b/drivers/usb/gadget/usbstring.c
@@ -70,4 +70,3 @@ usb_gadget_get_string (struct usb_gadget_strings *table, int 
id, u8 *buf)
return buf [0];
 }
 EXPORT_SYMBOL_GPL(usb_gadget_get_string);
-MODULE_LICENSE(GPL);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 13/20] usb/gadget: move usb_gadget_controller_number() into a .c file and libcomposite

2012-08-24 Thread Sebastian Andrzej Siewior
After I moved the function from the header file to the c file I see:

| $ size drivers/usb/gadget/gadget_chips.o
| textdata bss dec hex filename
| 1048   0   01048 418 drivers/usb/gadget/gadget_chips.o

That is almost a KiB which is removed from each user.
As Felipe pointed out, the function / usage is very dumb actually. This is
used for the following reasons:
- epautoconf ep hint (could provide a per-gadget callback)
- miss-features. currently the missing altsetting on pxa's and something
  ZLP related on musbhdrc (looks like an optimisation which could be
  implemented in musb itself if it is correct)
- unique BCD accross all UDCs. Not sure how important this is.

Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de
---
 drivers/usb/gadget/Makefile   |2 +-
 drivers/usb/gadget/gadget_chips.c |   92 +
 drivers/usb/gadget/gadget_chips.h |   59 +---
 3 files changed, 94 insertions(+), 59 deletions(-)
 create mode 100644 drivers/usb/gadget/gadget_chips.c

diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index d394162..d3d1950 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -5,7 +5,7 @@ ccflags-$(CONFIG_USB_GADGET_DEBUG) := -DDEBUG
 
 obj-$(CONFIG_USB_GADGET)   += udc-core.o
 obj-$(CONFIG_USB_LIBCOMPOSITE) += libcomposite.o
-libcomposite-y := usbstring.o config.o epautoconf.o
+libcomposite-y := usbstring.o config.o epautoconf.o 
gadget_chips.o
 obj-$(CONFIG_USB_DUMMY_HCD)+= dummy_hcd.o
 obj-$(CONFIG_USB_NET2272)  += net2272.o
 obj-$(CONFIG_USB_NET2280)  += net2280.o
diff --git a/drivers/usb/gadget/gadget_chips.c 
b/drivers/usb/gadget/gadget_chips.c
new file mode 100644
index 000..854c30e
--- /dev/null
+++ b/drivers/usb/gadget/gadget_chips.c
@@ -0,0 +1,92 @@
+/*
+ * USB device controllers have lots of quirks.  Use these macros in
+ * gadget drivers or other code that needs to deal with them, and which
+ * autoconfigures instead of using early binding to the hardware.
+ *
+ * This SHOULD eventually work like the ARM mach_is_*() stuff, driven by
+ * some config file that gets updated as new hardware is supported.
+ * (And avoiding all runtime comparisons in typical one-choice configs!)
+ *
+ * NOTE:  some of these controller drivers may not be available yet.
+ * Some are available on 2.4 kernels; several are available, but not
+ * yet pushed in the 2.6 mainline tree.
+ */
+
+#include linux/usb/gadget.h
+#include linux/module.h
+
+#include gadget_chips.h
+
+/**
+ * usb_gadget_controller_number - support bcdDevice id convention
+ * @gadget: the controller being driven
+ *
+ * Return a 2-digit BCD value associated with the peripheral controller,
+ * suitable for use as part of a bcdDevice value, or a negative error code.
+ *
+ * NOTE:  this convention is purely optional, and has no meaning in terms of
+ * any USB specification.  If you want to use a different convention in your
+ * gadget driver firmware -- maybe a more formal revision ID -- feel free.
+ *
+ * Hosts see these bcdDevice numbers, and are allowed (but not encouraged!)
+ * to change their behavior accordingly.  For example it might help avoiding
+ * some chip bug.
+ */
+int usb_gadget_controller_number(struct usb_gadget *gadget)
+{
+   if (gadget_is_net2280(gadget))
+   return 0x01;
+   else if (gadget_is_dummy(gadget))
+   return 0x02;
+   else if (gadget_is_pxa(gadget))
+   return 0x03;
+   else if (gadget_is_goku(gadget))
+   return 0x06;
+   else if (gadget_is_omap(gadget))
+   return 0x08;
+   else if (gadget_is_pxa27x(gadget))
+   return 0x11;
+   else if (gadget_is_s3c2410(gadget))
+   return 0x12;
+   else if (gadget_is_at91(gadget))
+   return 0x13;
+   else if (gadget_is_imx(gadget))
+   return 0x14;
+   else if (gadget_is_musbhdrc(gadget))
+   return 0x16;
+   else if (gadget_is_atmel_usba(gadget))
+   return 0x18;
+   else if (gadget_is_fsl_usb2(gadget))
+   return 0x19;
+   else if (gadget_is_amd5536udc(gadget))
+   return 0x20;
+   else if (gadget_is_m66592(gadget))
+   return 0x21;
+   else if (gadget_is_fsl_qe(gadget))
+   return 0x22;
+   else if (gadget_is_ci13xxx_pci(gadget))
+   return 0x23;
+   else if (gadget_is_langwell(gadget))
+   return 0x24;
+   else if (gadget_is_r8a66597(gadget))
+   return 0x25;
+   else if (gadget_is_s3c_hsotg(gadget))
+   return 0x26;
+   else if (gadget_is_pch(gadget))
+   return 0x27;
+   else if (gadget_is_ci13xxx_msm(gadget))
+   return 0x28;
+   else if (gadget_is_renesas_usbhs(gadget))
+   return 0x29;
+   else if 

[PATCH 15/20] usb/gadget: push iManufacturer into gadgets

2012-08-24 Thread Sebastian Andrzej Siewior
This patch pushes the iManufacturer module argument from composite into
each gadget. Once the user uses the module paramter, the string is
overwritten with the final value.

Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de
---
 drivers/usb/gadget/acm_ms.c |4 +++-
 drivers/usb/gadget/audio.c  |3 ++-
 drivers/usb/gadget/cdc2.c   |3 ++-
 drivers/usb/gadget/composite.c  |   11 +++
 drivers/usb/gadget/ether.c  |3 ++-
 drivers/usb/gadget/g_ffs.c  |6 ++
 drivers/usb/gadget/gmidi.c  |3 ++-
 drivers/usb/gadget/hid.c|3 ++-
 drivers/usb/gadget/mass_storage.c   |7 +++
 drivers/usb/gadget/multi.c  |7 +++
 drivers/usb/gadget/ncm.c|2 ++
 drivers/usb/gadget/nokia.c  |2 ++
 drivers/usb/gadget/printer.c|2 ++
 drivers/usb/gadget/serial.c |3 +++
 drivers/usb/gadget/tcm_usb_gadget.c |3 +++
 drivers/usb/gadget/webcam.c |3 +++
 drivers/usb/gadget/zero.c   |2 ++
 include/linux/usb/composite.h   |6 +-
 18 files changed, 58 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/gadget/acm_ms.c b/drivers/usb/gadget/acm_ms.c
index 63ef563..51fc568 100644
--- a/drivers/usb/gadget/acm_ms.c
+++ b/drivers/usb/gadget/acm_ms.c
@@ -65,7 +65,6 @@ static struct usb_device_descriptor device_desc = {
.idVendor = cpu_to_le16(ACM_MS_VENDOR_NUM),
.idProduct =cpu_to_le16(ACM_MS_PRODUCT_NUM),
/* .bcdDevice = f(hardware) */
-   /* .iManufacturer = DYNAMIC */
/* .iProduct = DYNAMIC */
/* NO SERIAL NUMBER */
/*.bNumConfigurations = DYNAMIC*/
@@ -212,6 +211,9 @@ static int __init acm_ms_bind(struct usb_composite_dev 
*cdev)
device_desc.iSerialNumber =
strings_dev[STRING_PRODUCT_SERIAL].id;
}
+   if (iManufacturer)
+strings_dev[STRING_MANUFACTURER_IDX].s = iManufacturer;
+
dev_info(gadget-dev, %s, version:  DRIVER_VERSION \n,
DRIVER_DESC);
fsg_common_put(fsg_common);
diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c
index 336206d..d598e32 100644
--- a/drivers/usb/gadget/audio.c
+++ b/drivers/usb/gadget/audio.c
@@ -100,7 +100,6 @@ static struct usb_device_descriptor device_desc = {
.idVendor = __constant_cpu_to_le16(AUDIO_VENDOR_NUM),
.idProduct =__constant_cpu_to_le16(AUDIO_PRODUCT_NUM),
/* .bcdDevice = f(hardware) */
-   /* .iManufacturer = DYNAMIC */
/* .iProduct = DYNAMIC */
/* NO SERIAL NUMBER */
.bNumConfigurations =   1,
@@ -184,6 +183,8 @@ static int __init audio_bind(struct usb_composite_dev *cdev)
device_desc.iSerialNumber =
strings_dev[STRING_PRODUCT_SERIAL].id;
}
+   if (iManufacturer)
+   strings_dev[STRING_MANUFACTURER_IDX].s = iManufacturer;
 
INFO(cdev, %s, version: %s\n, DRIVER_DESC, DRIVER_VERSION);
return 0;
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c
index 692f817..390a7e4 100644
--- a/drivers/usb/gadget/cdc2.c
+++ b/drivers/usb/gadget/cdc2.c
@@ -67,7 +67,6 @@ static struct usb_device_descriptor device_desc = {
.idVendor = cpu_to_le16(CDC_VENDOR_NUM),
.idProduct =cpu_to_le16(CDC_PRODUCT_NUM),
/* .bcdDevice = f(hardware) */
-   /* .iManufacturer = DYNAMIC */
/* .iProduct = DYNAMIC */
/* NO SERIAL NUMBER */
.bNumConfigurations =   1,
@@ -211,6 +210,8 @@ static int __init cdc_bind(struct usb_composite_dev *cdev)
device_desc.iSerialNumber =
strings_dev[STRING_PRODUCT_SERIAL].id;
}
+   if (iManufacturer)
+   strings_dev[STRING_MANUFACTURER_IDX].s = iManufacturer;
 
USB_GADGET_COMPOSITE_OVERWRITE_OPTIONS(device_desc);
dev_info(gadget-dev, %s, version:  DRIVER_VERSION \n,
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 506be03..a89f95d 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -32,9 +32,6 @@
  * published in the device descriptor, either numbers or strings or both.
  * String parameters are in UTF-8 (superset of ASCII's 7 bit characters).
  */
-static char *iManufacturer;
-module_param(iManufacturer, charp, S_IRUGO);
-MODULE_PARM_DESC(iManufacturer, USB Manufacturer string);
 
 static char *iProduct;
 module_param(iProduct, charp, S_IRUGO);
@@ -916,8 +913,7 @@ static int get_string(struct usb_composite_dev *cdev,
 * check if the string has not been overridden.
 */
if (cdev-manufacturer_override == id)
-   str = iManufacturer ?: cdriver-iManufacturer ?:
-   composite_manufacturer;
+   str = cdriver-iManufacturer ?: composite_manufacturer;
   

[PATCH 10/20] usb/gadget: use usb_string_ids_tab instead multiple usb_string_id()

2012-08-24 Thread Sebastian Andrzej Siewior
Using usb_string_ids_tab() instead multiple calls of usb_string_id()
seems to be handy. It also allows to add string without many checks.

Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de
---
 drivers/usb/gadget/acm_ms.c |   12 +++-
 drivers/usb/gadget/audio.c  |   12 +++-
 drivers/usb/gadget/cdc2.c   |   12 +++-
 drivers/usb/gadget/ether.c  |   12 +++-
 drivers/usb/gadget/gmidi.c  |   21 -
 drivers/usb/gadget/hid.c|   11 +++
 drivers/usb/gadget/ncm.c|   12 +++-
 drivers/usb/gadget/nokia.c  |   22 --
 drivers/usb/gadget/serial.c |   22 --
 drivers/usb/gadget/webcam.c |   21 -
 drivers/usb/gadget/zero.c   |   26 --
 11 files changed, 46 insertions(+), 137 deletions(-)

diff --git a/drivers/usb/gadget/acm_ms.c b/drivers/usb/gadget/acm_ms.c
index 94a558a..f34be59 100644
--- a/drivers/usb/gadget/acm_ms.c
+++ b/drivers/usb/gadget/acm_ms.c
@@ -193,17 +193,11 @@ static int __init acm_ms_bind(struct usb_composite_dev 
*cdev)
snprintf(manufacturer, sizeof manufacturer, %s %s with %s,
init_utsname()-sysname, init_utsname()-release,
gadget-name);
-   status = usb_string_id(cdev);
+   status = usb_string_ids_tab(cdev, strings_dev);
if (status  0)
goto fail1;
-   strings_dev[STRING_MANUFACTURER_IDX].id = status;
-   device_desc.iManufacturer = status;
-
-   status = usb_string_id(cdev);
-   if (status  0)
-   goto fail1;
-   strings_dev[STRING_PRODUCT_IDX].id = status;
-   device_desc.iProduct = status;
+   device_desc.iManufacturer = strings_dev[STRING_MANUFACTURER_IDX].id;
+   device_desc.iProduct = strings_dev[STRING_PRODUCT_IDX].id;
 
/* register our configuration */
status = usb_add_config(cdev, acm_ms_config_driver, acm_ms_do_config);
diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c
index a9c687a..2dc6d63 100644
--- a/drivers/usb/gadget/audio.c
+++ b/drivers/usb/gadget/audio.c
@@ -167,17 +167,11 @@ static int __init audio_bind(struct usb_composite_dev 
*cdev)
snprintf(manufacturer, sizeof manufacturer, %s %s with %s,
init_utsname()-sysname, init_utsname()-release,
cdev-gadget-name);
-   status = usb_string_id(cdev);
+   status = usb_string_ids_tab(cdev, strings_dev);
if (status  0)
goto fail;
-   strings_dev[STRING_MANUFACTURER_IDX].id = status;
-   device_desc.iManufacturer = status;
-
-   status = usb_string_id(cdev);
-   if (status  0)
-   goto fail;
-   strings_dev[STRING_PRODUCT_IDX].id = status;
-   device_desc.iProduct = status;
+   device_desc.iManufacturer = strings_dev[STRING_MANUFACTURER_IDX].id;
+   device_desc.iProduct = strings_dev[STRING_PRODUCT_IDX].id = status;
 
status = usb_add_config(cdev, audio_config_driver, audio_do_config);
if (status  0)
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c
index f0f8444..03752db 100644
--- a/drivers/usb/gadget/cdc2.c
+++ b/drivers/usb/gadget/cdc2.c
@@ -194,17 +194,11 @@ static int __init cdc_bind(struct usb_composite_dev *cdev)
snprintf(manufacturer, sizeof manufacturer, %s %s with %s,
init_utsname()-sysname, init_utsname()-release,
gadget-name);
-   status = usb_string_id(cdev);
+   status = usb_string_ids_tab(cdev, strings_dev);
if (status  0)
goto fail1;
-   strings_dev[STRING_MANUFACTURER_IDX].id = status;
-   device_desc.iManufacturer = status;
-
-   status = usb_string_id(cdev);
-   if (status  0)
-   goto fail1;
-   strings_dev[STRING_PRODUCT_IDX].id = status;
-   device_desc.iProduct = status;
+   device_desc.iManufacturer = strings_dev[STRING_MANUFACTURER_IDX].id;
+   device_desc.iProduct = strings_dev[STRING_PRODUCT_IDX].id;
 
/* register our configuration */
status = usb_add_config(cdev, cdc_config_driver, cdc_do_config);
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 3bd9982..3d896ac 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -346,17 +346,11 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
snprintf(manufacturer, sizeof manufacturer, %s %s with %s,
init_utsname()-sysname, init_utsname()-release,
gadget-name);
-   status = usb_string_id(cdev);
+   status = usb_string_ids_tab(cdev, strings_dev);
if (status  0)
goto fail;
-   strings_dev[STRING_MANUFACTURER_IDX].id = status;
-   device_desc.iManufacturer = status;
-
-   status = usb_string_id(cdev);
-   if (status  0)
-   goto fail;
-   strings_dev[STRING_PRODUCT_IDX].id = status;
-   device_desc.iProduct = status;
+   

[PATCH 12/20] usb/gadget: initialize the strings in tcm_usb_gadget properly

2012-08-24 Thread Sebastian Andrzej Siewior
I have no idea what I've been thinking while I was doing this in the first
place. Now the strings are initialized properly and reported by lsusb.

Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de
---
 drivers/usb/gadget/tcm_usb_gadget.c |   33 -
 drivers/usb/gadget/tcm_usb_gadget.h |   14 --
 2 files changed, 28 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/gadget/tcm_usb_gadget.c 
b/drivers/usb/gadget/tcm_usb_gadget.c
index 5641ea1..82608dc 100644
--- a/drivers/usb/gadget/tcm_usb_gadget.c
+++ b/drivers/usb/gadget/tcm_usb_gadget.c
@@ -1976,7 +1976,6 @@ static struct usb_interface_descriptor bot_intf_desc = {
.bInterfaceClass =  USB_CLASS_MASS_STORAGE,
.bInterfaceSubClass =   USB_SC_SCSI,
.bInterfaceProtocol =   USB_PR_BULK,
-   .iInterface =   USB_G_STR_INT_UAS,
 };
 
 static struct usb_interface_descriptor uasp_intf_desc = {
@@ -1987,7 +1986,6 @@ static struct usb_interface_descriptor uasp_intf_desc = {
.bInterfaceClass =  USB_CLASS_MASS_STORAGE,
.bInterfaceSubClass =   USB_SC_SCSI,
.bInterfaceProtocol =   USB_PR_UAS,
-   .iInterface =   USB_G_STR_INT_BBB,
 };
 
 static struct usb_endpoint_descriptor uasp_bi_desc = {
@@ -2208,20 +2206,16 @@ static struct usb_device_descriptor usbg_device_desc = {
.bDeviceClass = USB_CLASS_PER_INTERFACE,
.idVendor = cpu_to_le16(UAS_VENDOR_ID),
.idProduct =cpu_to_le16(UAS_PRODUCT_ID),
-   .iManufacturer =USB_G_STR_MANUFACTOR,
-   .iProduct = USB_G_STR_PRODUCT,
-   .iSerialNumber =USB_G_STR_SERIAL,
-
.bNumConfigurations =   1,
 };
 
 static struct usb_string   usbg_us_strings[] = {
-   { USB_G_STR_MANUFACTOR, Target Manufactor},
-   { USB_G_STR_PRODUCT,Target Product},
-   { USB_G_STR_SERIAL, 0001},
-   { USB_G_STR_CONFIG, default config},
-   { USB_G_STR_INT_UAS,USB Attached SCSI},
-   { USB_G_STR_INT_BBB,Bulk Only Transport},
+   [USB_G_STR_MANUFACTOR].s= Target Manufactor,
+   [USB_G_STR_PRODUCT].s   = Target Product,
+   [USB_G_STR_SERIAL].s= 0001,
+   [USB_G_STR_CONFIG].s= default config,
+   [USB_G_STR_INT_UAS].s   = USB Attached SCSI,
+   [USB_G_STR_INT_BBB].s   = Bulk Only Transport,
{ },
 };
 
@@ -2243,7 +2237,6 @@ static int guas_unbind(struct usb_composite_dev *cdev)
 static struct usb_configuration usbg_config_driver = {
.label  = Linux Target,
.bConfigurationValue= 1,
-   .iConfiguration = USB_G_STR_CONFIG,
.bmAttributes   = USB_CONFIG_ATT_SELFPOWER,
 };
 
@@ -2416,6 +2409,9 @@ static int usbg_cfg_bind(struct usb_configuration *c)
fu-function.disable = usbg_disable;
fu-tpg = the_only_tpg_I_currently_have;
 
+   bot_intf_desc.iInterface = usbg_us_strings[USB_G_STR_INT_BBB].id;
+   uasp_intf_desc.iInterface = usbg_us_strings[USB_G_STR_INT_UAS].id;
+
ret = usb_add_function(c, fu-function);
if (ret)
goto err;
@@ -2430,6 +2426,17 @@ static int usb_target_bind(struct usb_composite_dev 
*cdev)
 {
int ret;
 
+   ret = usb_string_ids_tab(cdev, usbg_us_strings);
+   if (ret)
+   return ret;
+
+   usbg_device_desc.iManufacturer =
+   usbg_us_strings[USB_G_STR_MANUFACTOR].id;
+   usbg_device_desc.iProduct = usbg_us_strings[USB_G_STR_PRODUCT].id;
+   usbg_device_desc.iSerialNumber = usbg_us_strings[USB_G_STR_SERIAL].id;
+   usbg_config_driver.iConfiguration =
+   usbg_us_strings[USB_G_STR_CONFIG].id;
+
ret = usb_add_config(cdev, usbg_config_driver,
usbg_cfg_bind);
if (ret)
diff --git a/drivers/usb/gadget/tcm_usb_gadget.h 
b/drivers/usb/gadget/tcm_usb_gadget.h
index bb18999..9d32ec3 100644
--- a/drivers/usb/gadget/tcm_usb_gadget.h
+++ b/drivers/usb/gadget/tcm_usb_gadget.h
@@ -16,12 +16,14 @@
 #define UASP_SS_EP_COMP_LOG_STREAMS 4
 #define UASP_SS_EP_COMP_NUM_STREAMS (1  UASP_SS_EP_COMP_LOG_STREAMS)
 
-#define USB_G_STR_MANUFACTOR1
-#define USB_G_STR_PRODUCT   2
-#define USB_G_STR_SERIAL3
-#define USB_G_STR_CONFIG4
-#define USB_G_STR_INT_UAS   5
-#define USB_G_STR_INT_BBB   6
+enum {
+   USB_G_STR_MANUFACTOR,
+   USB_G_STR_PRODUCT,
+   USB_G_STR_SERIAL,
+   USB_G_STR_CONFIG,
+   USB_G_STR_INT_UAS,
+   USB_G_STR_INT_BBB,
+};
 
 #define USB_G_ALT_INT_BBB   0
 #define USB_G_ALT_INT_UAS   1
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: USB sound card device complains about error -28: not enough bandwidth only on specific PC hardware, seems not kernel specific

2012-08-24 Thread Alan Stern
On Fri, 24 Aug 2012, David Ranch wrote:

 Hello Alan,
 
 First off, thanks for the response and sorry for the delay here.. very 
 busy here!
 
 
  The problem is caused by the ehci-hcd driver's not-so-great support 
  for scheduling periodic transfers to full-speed devices. That's why 
  the HP and Dell systems have no trouble but your Gateway laptop can't 
  handle it. 
 
 There are various reports that the Windows driver has an option to FORCE 
 this X-Fi device to use USB high speed which solves some specific sound 
 quality issues, etc. but I have not seen anything about needing that 
 switch to support 96khz at.  There was a similar trick done on the 
 Audigy2 NX card and I'd be willing to try some code that could force the 
 device to high speed that but it's unclear what's needed for the X-Fi card.
 
 Audigy 2 NX required a hack to go into highspeed mode
 http://comments.gmane.org/gmane.linux.usb.general/20816

Going to high speed would undoubtedly fix your problem, but we can't do 
it if we don't know how.  Is there any way for you to use your device 
with Windows, force it to high speed, and record the USB commands that 
Windows uses to do this?

 I've also researched around where some people recommended to remove the 
 EHCI module to use the OHCI but that doesn't seem to work on this 
 specific laptop's chipset.

No, your laptop doesn't support either OHCI or UHCI.

 To be clear, I'm ONLY looking to record two channel (stereo) from this 
 sound card's line-in.  I'm more than happy to disable any playback, etc. 
 if that might allow this USB device to stay under the Full speed 
 bandwidth limit

The usbmon trace showed there was audio-out data being sent at the time 
the first error occurred during the initial connection.  But there 
wasn't any audio-out during the second error, so it's not the cause.

  You can provide some more details: The output from lsusb -v for the 
  sound card, and a usbmon trace showing the RECORD failure (see 
  Documentation/usb/usbmon.txt for instructions). 
 
 Absolutely.  Please see here:
 
 http://www.trinityos.com/SCRATCH/

Which kernel version were you using when you recorded these?

Alan Stern

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 7/7 really v3] usb/gadget: remove global variable composite in composite.c

2012-08-24 Thread Michal Nazarewicz
Sebastian Andrzej Siewior bige...@linutronix.de writes:
 This patch removes the global variable composite in composite.c.
 The private data which was saved there is now passed via an additional
 argument to the bind() function in struct usb_gadget_driver.

 Only the old-style UDC drivers have to be touched here, new style are
 doing it right because this change is made in udc-core.

 Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de

Looks good to me.

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +email/xmpp: m...@google.com--ooO--(_)--Ooo--

pgpYQMw2zuh4M.pgp
Description: PGP signature


Re: USB sound card device complains about error -28: not enough bandwidth only on specific PC hardware, seems not kernel specific

2012-08-24 Thread David Ranch


Hello Alan,

Going to high speed would undoubtedly fix your problem, but we can't 
do it if we don't know how. Is there any way for you to use your 
device with Windows, force it to high speed, and record the USB 
commands that Windows uses to do this? 
Sure.. I can put it on the Windows machine and try to record the USB 
commands but I need some guidance (HOWTO, documentation, etc) of what 
software I need to do this.




The usbmon trace showed there was audio-out data being sent at the time
the first error occurred during the initial connection.  But there
wasn't any audio-out during the second error, so it's not the cause.
I have no idea why there would be audio going out that device once 
connected.  The laptop's internal sound card is the default sound 
device.  Maybe a minor initialization bug?  I do know that with the 
3.4.4 kernels, I wouldn't see that initial not enough bandwidth error 
upon connecting it.  Regardless, when I would try the 96Khz recording 
with the 3.4.4 kernel, I'd still get the error.



Which kernel version were you using when you recorded these? 


That was with a Centos6 kernel:  2.6.32-220.7.1.el6.ax25.x86_64 #1 SMP 
Sun Mar 18 15:51:48 PDT 2012 x86_64 x86_64 x86_64 GNU/Linux


As I mentioned above, I also have a Vanilla 3.4.4 kernel that I can use 
though the USB behavior is basically the same.


--David




Alan Stern -- To unsubscribe from this list: send the line 
unsubscribe linux-usb in the body of a message to 
majord...@vger.kernel.org More majordomo info at 
http://vger.kernel.org/majordomo-info.html 

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: USB sound card device complains about error -28: not enough bandwidth only on specific PC hardware, seems not kernel specific

2012-08-24 Thread Alan Stern
On Fri, 24 Aug 2012, David Ranch wrote:

 Hello Alan,
 
  Going to high speed would undoubtedly fix your problem, but we can't 
  do it if we don't know how. Is there any way for you to use your 
  device with Windows, force it to high speed, and record the USB 
  commands that Windows uses to do this? 
 Sure.. I can put it on the Windows machine and try to record the USB 
 commands but I need some guidance (HOWTO, documentation, etc) of what 
 software I need to do this.

It depends on what version of Windows you're running.  There are 
programs freely available, but I don't have a list.  Try doing a web 
search for: USB snoop windows.

  Which kernel version were you using when you recorded these? 
 
 That was with a Centos6 kernel:  2.6.32-220.7.1.el6.ax25.x86_64 #1 SMP 
 Sun Mar 18 15:51:48 PDT 2012 x86_64 x86_64 x86_64 GNU/Linux
 
 As I mentioned above, I also have a Vanilla 3.4.4 kernel that I can use 
 though the USB behavior is basically the same.

Can you run the same test with the 3.4.4 kernel?

In fact, can you build your own kernel with CONFIG_USB_DEBUG enabled?

Alan Stern

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Scanner works on USB-2 port but not on USB-3 because of usbfs claiming the interface

2012-08-24 Thread Harald Judt

Hi,

A few weeks ago I sent you debugging information for the problem 
described below. Now I tried again using linux-3.5.1, and the problem 
still exists. However, I got a new mainboard now that has Intel USB3 
ports and ASM1042 USB3 ports. With both chipsets and the xhci_hcd driver 
I get the same problems as with the one used on the older mainboard, 
Etrontech EJ168A.


Any news?

Am 16.05.2012 23:59, schrieb Sarah Sharp:

On Tue, May 15, 2012 at 09:34:07AM +0200, Harald Judt wrote:

Hi Sarah,

The problem is still present in linux-3.4.0-rc7. You did not respond
to my last mail, so I simply decided to resend it, including the
attachments.

Maybe you can spend some time to look into this?


Hi Harald,

I'm sorry about not responding quickly about this.  Thanks for reminding
me about this.  I'll look into it.

Sarah Sharp


Am 18.04.2012 20:17, schrieb Harald Judt:

Hi Sarah,

Thanks for your response.

Am 11.04.2012 22:43, schrieb Sarah Sharp:

Hi Harald,

Can you point me to the original dmesg from both the successful run
under EHCI and the unsuccessful run under xHCI? I can't seem to find
it.


Attached you will find both original dmesg that I've sent to the mailing
list. IIRC there was not much revelatory information to find there

though.



I also need dmesg with CONFIG_USB_DEBUG and
CONFIG_USB_XHCI_HCD_DEBUGGING enabled for the run under xHCI.


A dmesg with these debugging options enabled is also attached
(xhci-debug-enabled).

I (very carefully) removed private data and some unnecessary
information, but there shouldn't be anything important missing. All
attachments are bzip2 compressed, as some are rather big. I hope they
prove helpful.

Harald



On Tue, Apr 10, 2012 at 12:43:58PM +0200, Harald Judt wrote:

*BUMP*?

Am 16.03.2012 10:12, schrieb Harald Judt:

Hi Sarah,

Am 05.03.2012 18:50, schrieb Sarah Sharp:

Hi Harald,

Sorry about the lack of response. I'm preparing for a conference this
week, so I won't be able to look into this issue until next week.

Sarah Sharp


I hope you enjoyed the conference. Do you think you can spare

some time

now to help me with my problem?

Harald Judt




For reference:



On Mon, Mar 05, 2012 at 05:59:17PM +0100, Harald Judt wrote:


*BUMP*?

Am 27.02.2012 21:41, schrieb Alan Stern:

On Mon, 27 Feb 2012, Harald Judt wrote:


In step 4 scanimage hung until I interrupted it, producing

lots of the

following repeated lines in dmesg:
usb 5-1: usbdev_do_ioctl: REAPURBNDELAY
To save you from excessive scrolling, I've deleted most of these
repeated lines, as you will recognize when looking at the

timestamps.


I don't see any of those usbfs: interface 0 claimed by

usbfs while

'scanimage' sets config #1 messages in either log. Also,

both logs

show that the scanimage program closed the device file and

then opened

it again (although in the USB-2 case a lot of stuff happened first
whereas in the USB-3 log relatively little happened). Any idea
about
that?


Yes, I didn't see these either, neither in dmesg nor in
/var/log/messages. But that's because scanbuttond was not

running, which

would normally start scanimage -L for initialisation purposes.
If I
enable scanbuttond and do another scanimage -L manually while the
one
started by scanbuttond is still running/hanging, I get the

expected message

usb 5-1: usbfs: interface 0 claimed by usbfs while

'scanimage' sets

config #1
But I guess this is ok in this case and just a symptom, and
something
else has to be wrong.


Yes; those messages probably occur because both programs are
trying to
communicate with the scanner at the same time, which is not a good
idea. At the very least, scanimage should have an option to skip its
Set-Configuration step.


To summarize: The problem is not with usbfs, but with something
else.


Both logs show minor errors of various sorts, but nothing really
serious. At the end of the USB-3 log, it looks like the scanner
just
stopped replying. It's not clear whether this is because of a

problem

in the scanner or the computer.

Alan Stern


I successfully tested the scanner in Windows 7 x64, using a trial
version of VueScan, which installs its own scanner driver, as

Canon does

not provide its own for this OS version.

Looking at the observations I presented above, I conclude that the
problem can neither be the scanner nor the computer, but has to be
driver-related. In this case, rather a problem with USB3

because the

scanner works perfectly with USB2. BTW: Reproducible with 3.3-rc5+.

I guess the claimed by usbfs messages occur with scanbuttond
because
it checks regularly for button presses (on the scanner), and that
may
hang too, producing the dmesg messages when scanimage calls for

action.


What is your opinion on this? Any suggestions on how to proceed

from here?


At this point it's up to the maintainer of the xhci-hcd

driver (i.e.,

the USB-3 driver). Sarah will probably have some ideas for further
debugging.

Incidentally, now that we have a good idea of the reason for 

Re: [PATCH 01/20] usb/gadget: start with libcomposite

2012-08-24 Thread Michal Nazarewicz
Sebastian Andrzej Siewior bige...@linutronix.de writes:
 This patch aims to be simple. It removes #include usbstribgs.c line from each
 gadget and creates libcomposite.ko which has only one member, that is
 usbstribgs.c.

 Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de

Acked-by: Michal Nazarewicz min...@mina86.com

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +email/xmpp: m...@google.com--ooO--(_)--Ooo--

pgpSxcozgbhpb.pgp
Description: PGP signature


Re: [PATCH 03/20] usb/gadget: move global vars from epautoconf into struct usb_gadget

2012-08-24 Thread Michal Nazarewicz
Sebastian Andrzej Siewior bige...@linutronix.de writes:
 epautoconf has two global variables which count the endpoint number of
 last assigned endpoint.
 This patch removes the global variable and keeps it as per (UDC) gadget.
 While here, the ifdef is removed and now the in and outpoint are
 enumerated unconditionally. The dwc3 for instance supports 32 endpoints
 in total.

 Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de

The code looks good to me, but I'm not UDC expert and thus I don't know
whether this won't break something, so I'm reluctant to give my
Acked-by.

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +email/xmpp: m...@google.com--ooO--(_)--Ooo--

pgpDqmbnsCHw9.pgp
Description: PGP signature


Re: [PATCH 05/20] staging/ccg: make composite.c function static and remove unsused

2012-08-24 Thread Michal Nazarewicz
Sebastian Andrzej Siewior bige...@linutronix.de writes:
 The next step is to move composite.c into the library. Since the Android
 gadget has its composite.c copy 

Silly question, what branch is the patchset based on?

 this make makes sure both symbols do not
 clash by making the symbols static. The unused functions are removed.
 This patch also provides a local copy of composite.h because the
 prototype is now different due to the static attribute.

 Cc: de...@driverdev.osuosl.org
 Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +email/xmpp: m...@google.com--ooO--(_)--Ooo--

pgpgSAsjEgBEH.pgp
Description: PGP signature


Re: [PATCH 10/20] usb/gadget: use usb_string_ids_tab instead multiple usb_string_id()

2012-08-24 Thread Michal Nazarewicz
Sebastian Andrzej Siewior bige...@linutronix.de writes:
 Using usb_string_ids_tab() instead multiple calls of usb_string_id()
 seems to be handy. It also allows to add string without many checks.

 Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de

Most definitely:

Acked-by: Michal Nazarewicz min...@mina86.com

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +email/xmpp: m...@google.com--ooO--(_)--Ooo--

pgpI2UApTqMVr.pgp
Description: PGP signature


Re: [PATCH 09/20] usb/gadget: push VID/PID/USB BCD module option into gadgets

2012-08-24 Thread Michal Nazarewicz
Sebastian Andrzej Siewior bige...@linutronix.de writes:
 This patch moves the module options idVendor, idProduct and bcdDevice
 from composite.c into each gadgets. This ensures compatibility with
 current gadgets and removes the global variable which brings me step
 closer towards composite.c in libcomposite

 Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de

In general:

Acked-by: Michal Nazarewicz min...@mina86.com

but two comments below:

 diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c
 index 689d142..a9c687a 100644
 --- a/drivers/usb/gadget/audio.c
 +++ b/drivers/usb/gadget/audio.c
 @@ -13,6 +13,7 @@
  
  #include linux/kernel.h
  #include linux/utsname.h
 +#include linux/usb/composite.h

Why is this needed in this patch?  I think it belongs to one of the
later patches.

  
  #include gadget_chips.h
  #define DRIVER_DESC  Linux USB Audio Gadget
 @@ -28,6 +29,7 @@
   * a gcc --combine ... part1.c part2.c part3.c ...  build would.
   */
  #include composite.c
 +USB_GADGET_COMPOSITE_OPTIONS();
  
  /* string IDs are assigned dynamically */
  
 @@ -180,6 +182,7 @@ static int __init audio_bind(struct usb_composite_dev 
 *cdev)
   status = usb_add_config(cdev, audio_config_driver, audio_do_config);
   if (status  0)
   goto fail;
 + USB_GADGET_COMPOSITE_OVERWRITE_OPTIONS(device_desc);
  
   INFO(cdev, %s, version: %s\n, DRIVER_DESC, DRIVER_VERSION);
   return 0;

 diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c
 index 3d3d20d..39279e2 100644
 --- a/drivers/usb/gadget/printer.c
 +++ b/drivers/usb/gadget/printer.c
 @@ -54,6 +54,7 @@
  #include composite.c
  
  /*-*/
 +USB_GADGET_COMPOSITE_OPTIONS();
  
  #define DRIVER_DESC  Printer Gadget
  #define DRIVER_VERSION   2007 OCT 06
 @@ -1263,7 +1264,13 @@ static int printer_unbind(struct usb_composite_dev 
 *cdev)
  
  static int __init printer_bind(struct usb_composite_dev *cdev)
  {
 - return usb_add_config(cdev, printer_cfg_driver, printer_bind_config);
 + int ret;
 +
 + ret = usb_add_config(cdev, printer_cfg_driver, printer_bind_config);
 + if (ret)
 + return ret;
 + USB_GADGET_COMPOSITE_OVERWRITE_OPTIONS(device_desc);
 + return 0;

Alternatively you could just add invocation of the
USB_GADGET_COMPOSITE_OVERWRITE_OPTIONS(device_desc) macro before the
usb_add_config() is added, which would add only one additional line,
like so:

 {
+   USB_GADGET_COMPOSITE_OVERWRITE_OPTIONS(device_desc);
return usb_add_config(cdev, printer_cfg_driver, printer_bind_config);
 }

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +email/xmpp: m...@google.com--ooO--(_)--Ooo--

pgpO6ZXz0Lc3A.pgp
Description: PGP signature


Re: USB sound card device complains about error -28: not enough bandwidth only on specific PC hardware, seems not kernel specific

2012-08-24 Thread David Ranch



It depends on what version of Windows you're running.  There are
programs freely available, but I don't have a list.  Try doing a web
search for: USB snoop windows.


Ok.. will do.  I'm finding tools like the following.  Recognize any of them?

SniffUSB 2.0 - XP only  - Seems free - 
http://www.pcausa.com/Utilities/UsbSnoop/

USBlyzer   - various windows - $200! ouch - http://www.usblyzer.com/

Curious, will doing this snooping on a *different computer* be 
acceptable?  This Gateway laptop only has Linux on it and though I could 
get a new SATA disk for it, doing the requested USB sniff capture to 
enable the High Speed poke on a different box would be far easier.  
I'm thinking of doing this on a Windows XP box.




Can you run the same test with the 3.4.4 kernel?

In fact, can you build your own kernel with CONFIG_USB_DEBUG enabled?


Sure.. if you want, I can do it with a newer kernel if you'd like.. 
3.5.x?  Let me know and I'll start compiling it.


--David
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 14/20] usb/gadget: push iSerialNumber into gadgets

2012-08-24 Thread Michal Nazarewicz
Sebastian Andrzej Siewior bige...@linutronix.de writes:
 This patch pushes the iSerialNumber module argument from composite into
 each gadget. Each gadgets holds a dummy strings in its struct
 usb_string to ensure that usb_string_ids_tab() allocates a valid id.
 Once the user uses the module paramter, the string is overwritten with
 the final value.
 This is mostly the same change in each gadget with some minor
 exceptions:
 - printer accepts two arguments: iSerialNumber like everyone else and
   iSerialNum which was used before it was converted to composite
 - g_ffs got a few ifdefs and an enum in order to get the proper index
 - mass_storage: gained a struct usb_gadget_strings

 Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de

 diff --git a/drivers/usb/gadget/acm_ms.c b/drivers/usb/gadget/acm_ms.c
 index f34be59..63ef563 100644
 --- a/drivers/usb/gadget/acm_ms.c
 +++ b/drivers/usb/gadget/acm_ms.c
 @@ -92,12 +92,14 @@ static const struct usb_descriptor_header *otg_desc[] = {
  
  #define STRING_MANUFACTURER_IDX  0
  #define STRING_PRODUCT_IDX   1
 +#define STRING_PRODUCT_SERIAL2
  
  static char manufacturer[50];
  
  static struct usb_string strings_dev[] = {
   [STRING_MANUFACTURER_IDX].s = manufacturer,
   [STRING_PRODUCT_IDX].s = DRIVER_DESC,
 + [STRING_PRODUCT_SERIAL].s = ,
   {  } /* end of list */
  };
  
 @@ -205,6 +207,11 @@ static int __init acm_ms_bind(struct usb_composite_dev 
 *cdev)
   goto fail1;
  
   USB_GADGET_COMPOSITE_OVERWRITE_OPTIONS(device_desc);
 + if (iSerialNumber) {
 + strings_dev[STRING_PRODUCT_SERIAL].s = iSerialNumber;
 + device_desc.iSerialNumber =
 + strings_dev[STRING_PRODUCT_SERIAL].id;
 + }

Could we instead have USB_GADGET_COMPOSITE_OVERWRITE_OPTIONS handle
this?

This could be achieved by passing strings_dev and STRING_PRODUCT_SERIAL
to the macro.  It could also take care of  initialisation if module
parameter was not given.

Alternatively, composite could require STRING_PRODUCT_SERIAL to always
be zero.  This way only strings_dev would have to be passed as
additional argument to the macro.

   dev_info(gadget-dev, %s, version:  DRIVER_VERSION \n,
   DRIVER_DESC);
   fsg_common_put(fsg_common);

 diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c
 index 563feb5..948414d 100644
 --- a/drivers/usb/gadget/g_ffs.c
 +++ b/drivers/usb/gadget/g_ffs.c
 @@ -114,17 +114,33 @@ static const struct usb_descriptor_header 
 *gfs_otg_desc[] = {
   NULL
  };
  
 +enum {
 +#ifdef CONFIG_USB_FUNCTIONFS_RNDIS
 + GFFS_FFS_RNDIS_IDX,
 +#endif
 +
 +#ifdef CONFIG_USB_FUNCTIONFS_ETH
 + GFFS_FFS_ECM_IDX,
 +#endif
 +
 +#ifdef CONFIG_USB_FUNCTIONFS_GENERIC
 + GFFS_FFS_ECM_GEN_IDX,
 +#endif
 + GFFS_SERIAL_IDX,
 +};
 +
  /* String IDs are assigned dynamically */
  static struct usb_string gfs_strings[] = {
  #ifdef CONFIG_USB_FUNCTIONFS_RNDIS
 - { .s = FunctionFS + RNDIS },
 + [GFFS_FFS_RNDIS_IDX].s = FunctionFS + RNDIS,
  #endif
  #ifdef CONFIG_USB_FUNCTIONFS_ETH
 - { .s = FunctionFS + ECM },
 + [GFFS_FFS_ECM_IDX].s = FunctionFS + ECM,
  #endif
  #ifdef CONFIG_USB_FUNCTIONFS_GENERIC
 - { .s = FunctionFS },
 + [GFFS_FFS_ECM_IDX].s = FunctionFS,
  #endif
 + [GFFS_SERIAL_IDX].s = ,
   {  } /* end of list */
  };
  
 @@ -380,6 +396,11 @@ static int gfs_bind(struct usb_composite_dev *cdev)
   goto error_unbind;
   }
   USB_GADGET_COMPOSITE_OVERWRITE_OPTIONS(gfs_dev_desc);
 + if (iSerialNumber) {
 + gfs_strings[GFFS_SERIAL_IDX].s = iSerialNumber;
 + gfs_dev_desc.iSerialNumber = gfs_strings[GFFS_SERIAL_IDX].id;
 + }
 +

Alternatively, you could just define GFFS_SERIAL_IDX as zero and change:

-   c-c.label  = gfs_strings[i].s;
-   c-c.iConfiguration = gfs_strings[i].id;
+   c-c.label  = gfs_strings[i + 1].s;
+   c-c.iConfiguration = gfs_strings[i + 1].id;

(In fact, moving ++i from the for loop just above c.label assignment
would make it even easier.)

   return 0;
  
  error_unbind:

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +email/xmpp: m...@google.com--ooO--(_)--Ooo--

pgpJYt1k4Jy01.pgp
Description: PGP signature


Re: [PATCH 15/20] usb/gadget: push iManufacturer into gadgets

2012-08-24 Thread Michal Nazarewicz
Sebastian Andrzej Siewior bige...@linutronix.de writes:
 This patch pushes the iManufacturer module argument from composite into
 each gadget. Once the user uses the module paramter, the string is
 overwritten with the final value.

Why to remove the generation of the string from those gadgets and let
composite handle this? 

 Signed-off-by: Sebastian Andrzej Siewior bige...@linutronix.de

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +email/xmpp: m...@google.com--ooO--(_)--Ooo--

pgptMReIjfGYM.pgp
Description: PGP signature


Re: USB sound card device complains about error -28: not enough bandwidth only on specific PC hardware, seems not kernel specific

2012-08-24 Thread Alan Stern
On Fri, 24 Aug 2012, David Ranch wrote:

  It depends on what version of Windows you're running.  There are
  programs freely available, but I don't have a list.  Try doing a web
  search for: USB snoop windows.
 
 Ok.. will do.  I'm finding tools like the following.  Recognize any of them?
 
 SniffUSB 2.0 - XP only  - Seems free - 
 http://www.pcausa.com/Utilities/UsbSnoop/

USB Snoop works well... but only on XP.

 USBlyzer   - various windows - $200! ouch - http://www.usblyzer.com/

There are others.  Some of them give you a free trial period.

 Curious, will doing this snooping on a *different computer* be 
 acceptable?  This Gateway laptop only has Linux on it and though I could 
 get a new SATA disk for it, doing the requested USB sniff capture to 
 enable the High Speed poke on a different box would be far easier.  
 I'm thinking of doing this on a Windows XP box.

Provided the computer has the right driver and knows how to put the 
device into high-speed mode, that would be fine.

  Can you run the same test with the 3.4.4 kernel?
 
  In fact, can you build your own kernel with CONFIG_USB_DEBUG enabled?
 
 Sure.. if you want, I can do it with a newer kernel if you'd like.. 
 3.5.x?  Let me know and I'll start compiling it.

The newer, the better.  :-)

Alan Stern

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 5/5] usb/dwc3: fix no request in request_list when start isoc

2012-08-24 Thread Pratyush Anand

On 8/24/2012 7:01 PM, Pratyush Anand wrote:

On 8/24/2012 5:10 PM, Pratyush ANAND wrote:

If xfernotready is received and there is no request in request_list then
PENDING flag must be set, so that next request in ep queue is executed.



Although, I did not encounter PENDING in isoc testing. But, if somebody
hits it, then only this patch might not be sufficient. One might need
following along with it.

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 8d3b2d5..c08aa39 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1104,6 +1104,16 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep
*dep, struct dwc3_request *req)
 if (dep-flags  DWC3_EP_PENDING_REQUEST) {
 int ret;

+   /*
+* If xfornotready is already elapsed and it is a case
+* of isoc transfer, then issue END TRANSFER, so that
+* you can receive xfernotready again and can have
+* notion of current microframe.
+*/
+   if (usb_endpoint_xfer_isoc(dep-endpoint.desc)) {
+   dwc3_stop_active_transfer(dwc, dep-number);
+   return 0;
+   }
 ret = __dwc3_gadget_kick_transfer(dep, 0, true);
 if (ret  ret != -EBUSY) {
 struct dwc3 *dwc = dep-dwc;


If you agree, then discard this patch only. I will send another one to
handle pending isoc request.



Discard 5/5. I will send another.


Regards
Pratyush

Signed-off-by: Pratyush Anand pratyush.an...@st.com
---
  drivers/usb/dwc3/gadget.c |1 +
  1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 5d41d74..8d3b2d5 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1040,6 +1040,7 @@ static void __dwc3_gadget_start_isoc(struct dwc3
*dwc,
  if (list_empty(dep-request_list)) {
  dev_vdbg(dwc-dev, ISOC ep %s run out for requests.\n,
  dep-name);
+dep-flags |= DWC3_EP_PENDING_REQUEST;
  return;
  }








--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb/dwc3: Fix Pedning isoc

2012-08-24 Thread Pratyush Anand
If xfernotready is received and there is no request in request_list then
PENDING flag must be set, so that next request in ep queue is executed.

In case of isoc transfer, if xfornotready is alreday elapsed and even first
request has not been queued to request_list, then issue END TRANSFER, so that
you can receive xfernotready again and can have notion of current microframe.

Signed-off-by: Pratyush Anand pratyush.an...@st.com
---
 drivers/usb/dwc3/gadget.c |   11 +++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 5d41d74..5ebbd9f 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1040,6 +1040,7 @@ static void __dwc3_gadget_start_isoc(struct dwc3 *dwc,
if (list_empty(dep-request_list)) {
dev_vdbg(dwc-dev, ISOC ep %s run out for requests.\n,
dep-name);
+   dep-flags |= DWC3_EP_PENDING_REQUEST;
return;
}
 
@@ -1103,6 +1104,16 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, 
struct dwc3_request *req)
if (dep-flags  DWC3_EP_PENDING_REQUEST) {
int ret;
 
+   /*
+* If xfornotready is already elapsed and it is a case
+* of isoc transfer, then issue END TRANSFER, so that
+* you can receive xfernotready again and can have
+* notion of current microframe.
+*/
+   if (usb_endpoint_xfer_isoc(dep-endpoint.desc)) {
+   dwc3_stop_active_transfer(dwc, dep-number);
+   return 0;
+   }
ret = __dwc3_gadget_kick_transfer(dep, 0, true);
if (ret  ret != -EBUSY) {
struct dwc3 *dwc = dep-dwc;
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv4 0/9] *** ARM: Update arch-vt8500 to Devicetree ***

2012-08-24 Thread Stephen Warren
On 08/23/2012 01:35 AM, Tony Prisk wrote:
 This patchset updates arch-vt8500 to devicetree and removes all the old-style
 code. Support for WM8650 has also been added.
 
 Example dts/dtsi files are given for the three currently supported models.
 
 Major changes:
 
 GPIO code has been converted to a platform_device and rewritten as WM8505
 support was broken. Add support for WM8650 gpio controller.
 
 UHCI support was missing. Added this as a generic non-pci uhci controller as
 it doesn't require anything special. Should be usable by any system that 
 doesn't
 have special requirements to get the UHCI controller working.
 
 Framebuffer code patched to support WM8650. The bindings for this are of 
 concern
 but there doesn't seem to be a formalized binding yet. This patch is based off
 Sascha Hauer's current patch on the dri-devel mailing list and should be 
 easily
 patched out when its finalized.
 
 Patchset based on Arnd's arm-soc/for-next branch.

I believe all the issues I pointed out are fixed in this series. I'm not
sure I reviewed it in enough detail to ack it, but I'm fine with what I saw.
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Virtualbox/Vmware usb device is working but on installed linux not.

2012-08-24 Thread adam ?
https://bugzilla.kernel.org/show_bug.cgi?id=46411


--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html