[PATCH] USB: ehci-spear: add CONFIG_PM_SLEEP to suspend/resume functions

2013-03-25 Thread Jingoo Han
Add CONFIG_PM_SLEEP to suspend/resume functions to fix the following
build warning when CONFIG_PM_SLEEP is not selected. This is because
sleep PM callbacks defined by SIMPLE_DEV_PM_OPS are only used when
the CONFIG_PM_SLEEP is enabled.

drivers/usb/host/ehci-spear.c:82:12: warning: 'ehci_spear_drv_suspend' defined 
but not used [-Wunused-function]
drivers/usb/host/ehci-spear.c:90:12: warning: 'ehci_spear_drv_resume' defined 
but not used [-Wunused-function]

Signed-off-by: Jingoo Han 
---
 drivers/usb/host/ehci-spear.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/ehci-spear.c b/drivers/usb/host/ehci-spear.c
index 466c1bb..210bb67 100644
--- a/drivers/usb/host/ehci-spear.c
+++ b/drivers/usb/host/ehci-spear.c
@@ -78,7 +78,7 @@ static const struct hc_driver ehci_spear_hc_driver = {
.clear_tt_buffer_complete   = ehci_clear_tt_buffer_complete,
 };
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int ehci_spear_drv_suspend(struct device *dev)
 {
struct usb_hcd *hcd = dev_get_drvdata(dev);
@@ -94,7 +94,7 @@ static int ehci_spear_drv_resume(struct device *dev)
ehci_resume(hcd, false);
return 0;
 }
-#endif /* CONFIG_PM */
+#endif /* CONFIG_PM_SLEEP */
 
 static SIMPLE_DEV_PM_OPS(ehci_spear_pm_ops, ehci_spear_drv_suspend,
ehci_spear_drv_resume);
-- 
1.7.2.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: [PATCH] USB: EHCI: DT support for generic bus glue

2013-03-25 Thread Tony Prisk
On Mon, 2013-03-25 at 19:03 +, Arnd Bergmann wrote:
> On Monday 25 March 2013, Tony Prisk wrote:
> > I'll take a look at this and get back to you before Easter.
> > 
> 
> Great, thanks a lot!
> 
>   Arnd

I couldn't get this patch to apply cleanly on 3.9-rc2, -rc3 or -rc4 for
some reason. Applied it by hand and tested it on WM8850 tablet - all ok.
You can add my tested-by:

Tested-by: Tony Prisk 

Regards
Tony P

--
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 01/12] usb: chipidea: udc: use {read,write}l to handle mapped data

2013-03-25 Thread Paul Zimmerman
> From: Peter Chen 
> Sent: Monday, March 25, 2013 7:58 PM
> 
> On Fri, Mar 22, 2013 at 02:20:23PM +0100, Michael Grzeschik wrote:
> > The udc uses an shared dma memory space between hard and software. This
> > memory layout is described in ci13xxx_qh and ci13xxx_td which are marked
> > with the attribute ((packed)).
> >
> > The packed attribute leads the compiler to generate one byte operations
> > for addressing the mapped memory as it believes this memory has no
> > alignement issues as common streaming data. This appeares on armv5
> > machines where the hardware does not support unaligned 32bit operations.
> > Compilers for newer ARMs will probably still generate 32bit operations,
> > as the hardware supports it.
> >
> > The Datasheet of the synopsys core describes, that some operations on
> > the mapped memory need to be atomic double word operations. I.e. the
> > next pointer addressing in the qhead, as otherwise the hardware could
> > read wrong data and totally stuck.
> >
> > This patch fixes that issue by addressing every mapped area operation
> > with explicit readl and writel operations where needed. It also adds an
> > wmb() for the prepared TD data before it gets enqueued into the qhead.
> 
> The writel includes wmb(), the wmb() isn't needed if the last instruction
> is writel.
> 
> Besides, please make sure all dQH/dTD mapped area access by readl/writel in
> this patch, we don't want to add missing in future.

Is 'sparse' happy with this? AFAIR it will complain if you use readl/writel
on memory that is not marked with __iomem.

Is removing the __attribute__ ((packed)) annotation not enough to fix the
problem?

-- 
Paul

--
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 v3] USB: PHY: Palmas USB Transceiver Driver

2013-03-25 Thread Kishon Vijay Abraham I

Hi,

On Monday 25 March 2013 03:16 PM, Laxman Dewangan wrote:

On Monday 25 March 2013 03:02 PM, Kishon Vijay Abraham I wrote:

From: Graeme Gregory 

This is the driver for the OTG transceiver built into the Palmas chip. It
handles the various USB OTG events that can be generated by cable
insertion/removal.

Signed-off-by: Graeme Gregory 
Signed-off-by: Moiz Sonasath 
Signed-off-by: Ruchika Kharwar 
Signed-off-by: Kishon Vijay Abraham I 
Signed-off-by: Sebastien Guiriec 
---


I think this driver is more over the cable connection like vbus
detetcion or ID pin detection.
Then why not it is implemented based on extcon framework?


extcon framework uses notification mechanism and Felipe dint like using 
notification here. right Felipe?


That way, generic usb driver (like tegra_usb driver) will get
notification through extcon.

We need this cable detection through extcon on our tegra solution
through the Palmas.


+#include 
+#include 
+
+static int palmas_usb_read(struct palmas *palmas, unsigned int reg,
+   unsigned int *dest)
+{
+   unsigned int addr;
+   int slave;
+
+   slave = PALMAS_BASE_TO_SLAVE(PALMAS_USB_OTG_BASE);
+   addr = PALMAS_BASE_TO_REG(PALMAS_USB_OTG_BASE, reg);
+
+   return regmap_read(palmas->regmap[slave], addr, dest);


Please use the generic api for palmas_read()/palmas_write(0 as it will
be ease on debugging on register access.
Direct regmap_read() does not help much on this.


Graeme,
Any reason why you dint use palmas_read()/palmas_write here?
Btw palmas_read()/palmas_write() internally uses regmap APIs.



+}
+
+static int palmas_usb_write(struct palmas *palmas, unsigned int reg,
+   unsigned int data)
+{
+   unsigned int addr;
+   int slave;
+
+   slave = PALMAS_BASE_TO_SLAVE(PALMAS_USB_OTG_BASE);
+   addr = PALMAS_BASE_TO_REG(PALMAS_USB_OTG_BASE, reg);
+
+   return regmap_write(palmas->regmap[slave], addr, data);


Same as above.




+
+   if (status != OMAP_DWC3_UNKNOWN) {
+   palmas_usb->linkstat = status;
+   palmas_usb->mailboxstat = dwc3_omap_mailbox(status);

Omap specific call, why? This is generic palma driver.


hmm.. I think we should either fall-back to the notification mechanism 
or have the client drivers pass function pointer here. Felipe?




+



+   palmas_usb->dev = &pdev->dev;
+
+   palmas_usb->irq1 = regmap_irq_get_virq(palmas->irq_data,
+   PALMAS_ID_OTG_IRQ);
+   palmas_usb->irq2 = regmap_irq_get_virq(palmas->irq_data,
+   PALMAS_ID_IRQ);
+   palmas_usb->irq3 = regmap_irq_get_virq(palmas->irq_data,
+   PALMAS_VBUS_OTG_IRQ);
+   palmas_usb->irq4 = regmap_irq_get_virq(palmas->irq_data,
+   PALMAS_VBUS_IRQ);


Should be come from platform_get_irq() through platform driver.


No. It can be obtained from regmap too.

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


Re: [PATCH 02/12] usb: chipidea: udc: only clear active and halted bits in qhead

2013-03-25 Thread Peter Chen
On Fri, Mar 22, 2013 at 02:20:24PM +0100, Michael Grzeschik wrote:
> The datasheet of the synopsys core describes only to overwrite the
> active and halted bits in the qhead before priming any endpoint.
> 
> Signed-off-by: Michael Grzeschik 
> ---
>  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 fd702e9..e15f5e5 100644
> --- a/drivers/usb/chipidea/udc.c
> +++ b/drivers/usb/chipidea/udc.c
> @@ -472,7 +472,7 @@ static int _hardware_enqueue(struct ci13xxx_ep *mEp, 
> struct ci13xxx_req *mReq)
>   }
>   /*  QH configuration */
>   writel(mReq->dma, &mEp->qh.ptr->td.next); /* TERMINATE = 0 */
> - writel(readl(&mEp->qh.ptr->td.token) & ~TD_STATUS, 
> &mEp->qh.ptr->td.token);
> + writel(readl(&mEp->qh.ptr->td.token) & 
> ~(TD_STATUS_HALTED|TD_STATUS_ACTIVE), &mEp->qh.ptr->td.token);
>   writel(readl(&mEp->qh.ptr->cap) | QH_ZLT, &mEp->qh.ptr->cap);
>  
>   wmb();   /* synchronize before ep prime */
> -- 
> 1.8.2.rc2
> 
> 
Reviewed-by: Peter Chen 

-- 

Best Regards,
Peter Chen

--
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: PROBLEM: USB device registered on OHCI instead of EHCI at boot

2013-03-25 Thread Huang Rui
Hi Alan,

On Mon, Mar 25, 2013 at 10:28:04PM +0800, Alan Stern wrote:
> On Mon, 25 Mar 2013, Huang Rui wrote:
> 
> > Hi Alan,
> > 
> > Thank you to take a look at this issue. Sorry to disturb you again.
> > The PORT ENABLE(PORT_PE) bit in PORTSC register is not set when the
> > port reset, in other words, host controller and device might not do
> > alternating sequence of Chirp Ks and Chirp Js or not be detected. Am I
> > right?
> 
> Yes.

Thanks to your confirm.

> 
> >  I found why the boot issue is not alway reproduced. Because
> > sometimes ehci_hcd is not loaded before ohci_hcd.
> > 
> > [   25.068090] Warning! ehci_hcd should always be loaded before uhci_hcd 
> > and ohci_hcd, not after
> > 
> > If ehci_hcd is loaded firstly, the USB Reader(in my side) is always
> > detected as high speed device. Then I do below change and boot issue
> > isn't encountered again. 
> > 
> > diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
> > index 180a2b0..30fc91c 100644
> > --- a/drivers/usb/host/ohci-hcd.c
> > +++ b/drivers/usb/host/ohci-hcd.c
> > @@ -1325,7 +1325,7 @@ static int __init ohci_hcd_mod_init(void)
> > clear_bit(USB_OHCI_LOADED, &usb_hcds_loaded);
> > return retval;
> >  }
> > -module_init(ohci_hcd_mod_init);
> > +late_initcall(ohci_hcd_mod_init);
> > 
> >  static void __exit ohci_hcd_mod_exit(void)
> >  {
> > 
> > But I think it's not a good solution. Have you any idea to have an
> > appropriate way to make ehci_hcd loaded firstly?
> 
> In general there is no way to do it.  Especially with modern kernels, 
> because what matters is ehci-pci, not ehci-hcd.  And also because the 
> order of probing is not always the same.
> 
> I suppose you could build a kernel with CONFIG_USB_EHCI_HCD=y and 
> CONFIG_USB_EHCI_PCI=y but CONFIG_USB_OHCI_HCD=m.  That might help.

Yes, you're right. Thanks again to your suggestion.

Best Regards,
Rui

--
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: EHCI: DT support for generic bus glue

2013-03-25 Thread Tony Prisk
On Mon, 2013-03-25 at 22:23 +, Arnd Bergmann wrote:
> On Monday 25 March 2013, Alan Stern wrote:
> > >  
> > > + if (!dev->dev.platform_data) {
> > > + dev->dev.platform_data = &ehci_platform_defaults;
> > > + dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
> > > + dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
> > 
> > In view of Felipe's comment, shouldn't these last two lines be 
> > controlled by dev->dev.of_node != NULL instead?
> 
> We could do that, or alternatively like this
> 
>   if (!dev->dev.platform_data) {
>   dev->dev.platform_data = &ehci_platform_defaults;
>   if (!dev->dev.dma_mask)
>   dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
>   if (!dev->dev.coherent_dma_mask)
>   dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
> 
> which would have the additional advantage that platforms can then
> call platform_device_register_resndata() to create the device
> and get a reasonable default dma mask (EHCI should always have
> 32 bit DMA, unless the platform is really screwed), rather than
> statically declaring platform devices.
> 
>   Arnd
> 

Should I be expecting a v2 or should I just test this patch as is?

Regards
Tony P

--
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 01/12] usb: chipidea: udc: use {read,write}l to handle mapped data

2013-03-25 Thread Peter Chen
On Fri, Mar 22, 2013 at 02:20:23PM +0100, Michael Grzeschik wrote:
> The udc uses an shared dma memory space between hard and software. This
> memory layout is described in ci13xxx_qh and ci13xxx_td which are marked
> with the attribute ((packed)).
> 
> The packed attribute leads the compiler to generate one byte operations
> for addressing the mapped memory as it believes this memory has no
> alignement issues as common streaming data. This appeares on armv5
> machines where the hardware does not support unaligned 32bit operations.
> Compilers for newer ARMs will probably still generate 32bit operations,
> as the hardware supports it.
> 
> The Datasheet of the synopsys core describes, that some operations on
> the mapped memory need to be atomic double word operations. I.e. the
> next pointer addressing in the qhead, as otherwise the hardware could
> read wrong data and totally stuck.
> 
> This patch fixes that issue by addressing every mapped area operation
> with explicit readl and writel operations where needed. It also adds an
> wmb() for the prepared TD data before it gets enqueued into the qhead.

The writel includes wmb(), the wmb() isn't needed if the last instruction
is writel.

Besides, please make sure all dQH/dTD mapped area access by readl/writel in
this patch, we don't want to add missing in future.

-- 

Best Regards,
Peter Chen

--
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: serial: fix hang when opening port

2013-03-25 Thread Ming Lei
Johan's 'fix use-after-free in TIOCMIWAIT' patchset[1] introduces
one bug which can cause kernel hang when opening port.

This patch initialized the 'port->delta_msr_wait' waitqueue head
to fix the bug which is introduced in 3.9-rc4.

[1], http://marc.info/?l=linux-usb&m=136368139627876&w=2

Cc: stable 
Signed-off-by: Ming Lei 
---
Cc stable since the previous patchset is marked as stable.

 drivers/usb/serial/usb-serial.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 2e70efa..5d9b178 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -903,6 +903,7 @@ static int usb_serial_probe(struct usb_interface *interface,
port->port.ops = &serial_port_ops;
port->serial = serial;
spin_lock_init(&port->lock);
+   init_waitqueue_head(&port->delta_msr_wait);
/* Keep this for private driver use for the moment but
   should probably go away */
INIT_WORK(&port->work, usb_serial_port_work);
-- 
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


[PATCH v3] usb: dwc3: add CONFIG_PM_SLEEP to suspend/resume functions

2013-03-25 Thread Jingoo Han
Add CONFIG_PM_SLEEP to suspend/resume functions to fix the following
build warning when CONFIG_PM_SLEEP is not selected. This is because
sleep PM callbacks defined by SET_SYSTEM_SLEEP_PM_OPS are only used
when the CONFIG_PM_SLEEP is enabled. Unnecessary CONFIG_PM ifdefs
are removed.

drivers/usb/dwc3/core.c:682:12: warning: 'dwc3_suspend' defined but not used 
[-Wunused-function]
drivers/usb/dwc3/core.c:709:12: warning: 'dwc3_resume' defined but not used 
[-Wunused-function]
drivers/usb/dwc3/dwc3-omap.c:430:12: warning: 'dwc3_omap_suspend' defined but 
not used [-Wunused-function]
drivers/usb/dwc3/dwc3-omap.c:440:12: warning: 'dwc3_omap_resume' defined but 
not used [-Wunused-function]
drivers/usb/dwc3/dwc3-exynos.c:185:12: warning: 'dwc3_exynos_suspend' defined 
but not used [-Wunused-function]
drivers/usb/dwc3/dwc3-exynos.c:194:12: warning: 'dwc3_exynos_resume' defined 
but not used [-Wunused-function]

Signed-off-by: Jingoo Han 
---
 drivers/usb/dwc3/core.c|2 +-
 drivers/usb/dwc3/dwc3-exynos.c |4 ++--
 drivers/usb/dwc3/dwc3-omap.c   |4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index e2325ad..c35d49d 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -634,7 +634,7 @@ static int dwc3_remove(struct platform_device *pdev)
return 0;
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int dwc3_prepare(struct device *dev)
 {
struct dwc3 *dwc = dev_get_drvdata(dev);
diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c
index 1ea7bd8..a8afe6e 100644
--- a/drivers/usb/dwc3/dwc3-exynos.c
+++ b/drivers/usb/dwc3/dwc3-exynos.c
@@ -181,7 +181,7 @@ static const struct of_device_id exynos_dwc3_match[] = {
 MODULE_DEVICE_TABLE(of, exynos_dwc3_match);
 #endif
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int dwc3_exynos_suspend(struct device *dev)
 {
struct dwc3_exynos *exynos = dev_get_drvdata(dev);
@@ -212,7 +212,7 @@ static const struct dev_pm_ops dwc3_exynos_dev_pm_ops = {
 #define DEV_PM_OPS (&dwc3_exynos_dev_pm_ops)
 #else
 #define DEV_PM_OPS NULL
-#endif /* CONFIG_PM */
+#endif /* CONFIG_PM_SLEEP */
 
 static struct platform_driver dwc3_exynos_driver = {
.probe  = dwc3_exynos_probe,
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index 6de734f..34638b9 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -410,7 +410,7 @@ static const struct of_device_id of_dwc3_match[] = {
 };
 MODULE_DEVICE_TABLE(of, of_dwc3_match);
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int dwc3_omap_prepare(struct device *dev)
 {
struct dwc3_omap*omap = dev_get_drvdata(dev);
@@ -461,7 +461,7 @@ static const struct dev_pm_ops dwc3_omap_dev_pm_ops = {
 #define DEV_PM_OPS (&dwc3_omap_dev_pm_ops)
 #else
 #define DEV_PM_OPS NULL
-#endif /* CONFIG_PM */
+#endif /* CONFIG_PM_SLEEP */
 
 static struct platform_driver dwc3_omap_driver = {
.probe  = dwc3_omap_probe,
-- 
1.7.2.5
N떑꿩�r툤y鉉싕b쾊Ф푤v�^�)頻{.n�+돴쪐{군펐왲^n뇊⊆쫧�곷h솳鈺�&��췍쳺�h�(��쉸듶줷"얎�m��곴�z받뻿筬f"톒쉱�~늤

[PATCH v2 1/2] staging: dwc2: remove unneeded arguments from two functions

2013-03-25 Thread Paul Zimmerman
Remove the unneeded struct device *dev argument from dwc2_hcd_init()
and dwc2_hcd_remove(), and pass in the value through the hsotg->dev
member instead

Signed-off-by: Paul Zimmerman 
---
 drivers/staging/dwc2/hcd.c | 19 +--
 drivers/staging/dwc2/hcd.h |  6 +++---
 drivers/staging/dwc2/pci.c |  7 ---
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c
index 01dbdd8..af1a15c 100644
--- a/drivers/staging/dwc2/hcd.c
+++ b/drivers/staging/dwc2/hcd.c
@@ -2682,7 +2682,7 @@ static void dwc2_set_uninitialized(int *p, int size)
  * USB bus with the core and calls the hc_driver->start() function. It returns
  * a negative error on failure.
  */
-int dwc2_hcd_init(struct device *dev, struct dwc2_hsotg *hsotg, int irq,
+int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
  struct dwc2_core_params *params)
 {
struct usb_hcd *hcd;
@@ -2691,7 +2691,7 @@ int dwc2_hcd_init(struct device *dev, struct dwc2_hsotg 
*hsotg, int irq,
int i, num_channels;
int retval = -ENOMEM;
 
-   dev_dbg(dev, "DWC OTG HCD INIT\n");
+   dev_dbg(hsotg->dev, "DWC OTG HCD INIT\n");
 
/*
 * Attempt to ensure this device is really a DWC_otg Controller.
@@ -2702,12 +2702,12 @@ int dwc2_hcd_init(struct device *dev, struct dwc2_hsotg 
*hsotg, int irq,
snpsid = readl(hsotg->regs + GSNPSID);
if ((snpsid & 0xf000) != 0x4f542000 &&
(snpsid & 0xf000) != 0x4f543000) {
-   dev_err(dev, "Bad value for GSNPSID: 0x%08x\n", snpsid);
+   dev_err(hsotg->dev, "Bad value for GSNPSID: 0x%08x\n", snpsid);
retval = -ENODEV;
goto error1;
}
 
-   hcd = usb_create_hcd(&dwc2_hc_driver, dev, dev_name(dev));
+   hcd = usb_create_hcd(&dwc2_hc_driver, hsotg->dev, dev_name(hsotg->dev));
if (!hcd)
goto error1;
 
@@ -2716,7 +2716,6 @@ int dwc2_hcd_init(struct device *dev, struct dwc2_hsotg 
*hsotg, int irq,
spin_lock_init(&hsotg->lock);
((struct wrapper_priv_data *) &hcd->hcd_priv)->hsotg = hsotg;
hsotg->priv = hcd;
-   hsotg->dev = dev;
 
/*
 * Store the contents of the hardware configuration registers here for
@@ -2913,7 +2912,7 @@ error2:
 
usb_put_hcd(hcd);
 error1:
-   dev_err(dev, "%s() FAILED, returning %d\n", __func__, retval);
+   dev_err(hsotg->dev, "%s() FAILED, returning %d\n", __func__, retval);
return retval;
 }
 EXPORT_SYMBOL_GPL(dwc2_hcd_init);
@@ -2922,17 +2921,17 @@ EXPORT_SYMBOL_GPL(dwc2_hcd_init);
  * Removes the HCD.
  * Frees memory and resources associated with the HCD and deregisters the bus.
  */
-void dwc2_hcd_remove(struct device *dev, struct dwc2_hsotg *hsotg)
+void dwc2_hcd_remove(struct dwc2_hsotg *hsotg)
 {
struct usb_hcd *hcd;
 
-   dev_dbg(dev, "DWC OTG HCD REMOVE\n");
+   dev_dbg(hsotg->dev, "DWC OTG HCD REMOVE\n");
 
hcd = dwc2_hsotg_to_hcd(hsotg);
-   dev_dbg(dev, "hsotg->hcd = %p\n", hcd);
+   dev_dbg(hsotg->dev, "hsotg->hcd = %p\n", hcd);
 
if (!hcd) {
-   dev_dbg(dev, "%s: dwc2_hsotg_to_hcd(hsotg) NULL!\n",
+   dev_dbg(hsotg->dev, "%s: dwc2_hsotg_to_hcd(hsotg) NULL!\n",
__func__);
return;
}
diff --git a/drivers/staging/dwc2/hcd.h b/drivers/staging/dwc2/hcd.h
index 775337e..8a60dcf 100644
--- a/drivers/staging/dwc2/hcd.h
+++ b/drivers/staging/dwc2/hcd.h
@@ -447,9 +447,9 @@ static inline u8 dwc2_hcd_is_pipe_out(struct 
dwc2_hcd_pipe_info *pipe)
return !dwc2_hcd_is_pipe_in(pipe);
 }
 
-extern int dwc2_hcd_init(struct device *dev, struct dwc2_hsotg *hsotg,
-int irq, struct dwc2_core_params *params);
-extern void dwc2_hcd_remove(struct device *dev, struct dwc2_hsotg *hsotg);
+extern int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
+struct dwc2_core_params *params);
+extern void dwc2_hcd_remove(struct dwc2_hsotg *hsotg);
 extern int dwc2_set_parameters(struct dwc2_hsotg *hsotg,
   struct dwc2_core_params *params);
 
diff --git a/drivers/staging/dwc2/pci.c b/drivers/staging/dwc2/pci.c
index 117d3ce..539f859 100644
--- a/drivers/staging/dwc2/pci.c
+++ b/drivers/staging/dwc2/pci.c
@@ -103,7 +103,7 @@ static void dwc2_driver_remove(struct pci_dev *dev)
 
dev_dbg(&dev->dev, "%s(%p)\n", __func__, dev);
 
-   dwc2_hcd_remove(&dev->dev, hsotg);
+   dwc2_hcd_remove(hsotg);
pci_disable_device(dev);
 }
 
@@ -133,6 +133,7 @@ static int dwc2_driver_probe(struct pci_dev *dev,
 
pci_set_power_state(dev, PCI_D0);
 
+   hsotg->dev = &dev->dev;
hsotg->regs = devm_request_and_ioremap(&dev->dev, &dev->resource[0]);
if (!hsotg->regs)
return -ENOMEM;
@@ -157,7 +158,7 @@ static int dwc2_driver_probe(struct pci_dev *dev,
pci_set_consistent_dma_m

[PATCH v2 2/2] staging: dwc2: fix wrong setting of DMA masks

2013-03-25 Thread Paul Zimmerman
We were setting the DMA masks in dwc2_driver_probe(), but that is
before the driver parameters have been set to their default values.
That meant the DMA masks could be set wrong. Fix it by moving the
DMA mask setting into dwc2_hcd_init(), after the driver parameters
have been set.

Reported-by: Matthijs Kooijman 
Signed-off-by: Paul Zimmerman 
---
 drivers/staging/dwc2/hcd.c | 46 +-
 drivers/staging/dwc2/pci.c | 12 
 2 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c
index af1a15c..91ff504 100644
--- a/drivers/staging/dwc2/hcd.c
+++ b/drivers/staging/dwc2/hcd.c
@@ -2707,16 +2707,6 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
goto error1;
}
 
-   hcd = usb_create_hcd(&dwc2_hc_driver, hsotg->dev, dev_name(hsotg->dev));
-   if (!hcd)
-   goto error1;
-
-   hcd->has_tt = 1;
-
-   spin_lock_init(&hsotg->lock);
-   ((struct wrapper_priv_data *) &hcd->hcd_priv)->hsotg = hsotg;
-   hsotg->priv = hcd;
-
/*
 * Store the contents of the hardware configuration registers here for
 * easy access later
@@ -2775,18 +2765,18 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
hsotg->frame_num_array = kzalloc(sizeof(*hsotg->frame_num_array) *
 FRAME_NUM_ARRAY_SIZE, GFP_KERNEL);
if (!hsotg->frame_num_array)
-   goto error2;
+   goto error1;
hsotg->last_frame_num_array = kzalloc(
sizeof(*hsotg->last_frame_num_array) *
FRAME_NUM_ARRAY_SIZE, GFP_KERNEL);
if (!hsotg->last_frame_num_array)
-   goto error2;
+   goto error1;
hsotg->last_frame_num = HFNUM_MAX_FRNUM;
 #endif
 
hsotg->core_params = kzalloc(sizeof(*hsotg->core_params), GFP_KERNEL);
if (!hsotg->core_params)
-   goto error2;
+   goto error1;
 
dwc2_set_uninitialized((int *)hsotg->core_params,
   sizeof(*hsotg->core_params) / sizeof(int));
@@ -2794,6 +2784,29 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
/* Validate parameter values */
dwc2_set_parameters(hsotg, params);
 
+   /* Set device flags indicating whether the HCD supports DMA */
+   if (hsotg->core_params->dma_enable > 0) {
+   if (dma_set_mask(hsotg->dev, DMA_BIT_MASK(31)) < 0)
+   dev_warn(hsotg->dev,
+"can't enable workaround for >2GB RAM\n");
+   if (dma_set_coherent_mask(hsotg->dev, DMA_BIT_MASK(31)) < 0)
+   dev_warn(hsotg->dev,
+"can't enable workaround for >2GB RAM\n");
+   } else {
+   dma_set_mask(hsotg->dev, 0);
+   dma_set_coherent_mask(hsotg->dev, 0);
+   }
+
+   hcd = usb_create_hcd(&dwc2_hc_driver, hsotg->dev, dev_name(hsotg->dev));
+   if (!hcd)
+   goto error1;
+
+   hcd->has_tt = 1;
+
+   spin_lock_init(&hsotg->lock);
+   ((struct wrapper_priv_data *) &hcd->hcd_priv)->hsotg = hsotg;
+   hsotg->priv = hcd;
+
/* Initialize the DWC_otg core, and select the Phy type */
retval = dwc2_core_init(hsotg, true);
if (retval)
@@ -2903,6 +2916,8 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
 error3:
dwc2_hcd_release(hsotg);
 error2:
+   usb_put_hcd(hcd);
+error1:
kfree(hsotg->core_params);
 
 #ifdef CONFIG_USB_DWC2_TRACK_MISSED_SOFS
@@ -2910,8 +2925,6 @@ error2:
kfree(hsotg->frame_num_array);
 #endif
 
-   usb_put_hcd(hcd);
-error1:
dev_err(hsotg->dev, "%s() FAILED, returning %d\n", __func__, retval);
return retval;
 }
@@ -2939,12 +2952,11 @@ void dwc2_hcd_remove(struct dwc2_hsotg *hsotg)
usb_remove_hcd(hcd);
hsotg->priv = NULL;
dwc2_hcd_release(hsotg);
+   usb_put_hcd(hcd);
 
 #ifdef CONFIG_USB_DWC2_TRACK_MISSED_SOFS
kfree(hsotg->last_frame_num_array);
kfree(hsotg->frame_num_array);
 #endif
-
-   usb_put_hcd(hcd);
 }
 EXPORT_SYMBOL_GPL(dwc2_hcd_remove);
diff --git a/drivers/staging/dwc2/pci.c b/drivers/staging/dwc2/pci.c
index 539f859..0825eef 100644
--- a/drivers/staging/dwc2/pci.c
+++ b/drivers/staging/dwc2/pci.c
@@ -146,18 +146,6 @@ static int dwc2_driver_probe(struct pci_dev *dev,
 
pci_set_master(dev);
 
-   if (dwc2_module_params.dma_enable > 0) {
-   if (pci_set_dma_mask(dev, DMA_BIT_MASK(31)) < 0)
-   dev_warn(&dev->dev,
-"can't enable workaround for >2GB RAM\n");
-   if (pci_set_consistent_dma_mask(dev, DMA_BIT_MASK(31)) < 0)
-   dev_warn(&dev->dev,
-"can't enable workaround for >2GB RAM\n");
-   } else {
-   pci_set_dma_ma

Re: [PATCH v4] xhci - correct comp_mode_recovery_timer on return from hibernate

2013-03-25 Thread Sarah Sharp
On Mon, Mar 25, 2013 at 11:14:15PM +0100, Rafael J. Wysocki wrote:
> On Monday, March 25, 2013 02:35:37 PM Sarah Sharp wrote:
> > Alan,
> > 
> > Is there a way to disable runtime PM for a PCI host controller, but
> > still allow the system to suspend/hibernate?
> 
> It should be.  Just write "on" to the controller's power/control file in 
> sysfs.

And what's the equivalent function call?  We want to disable it within
the xHCI driver.

Sarah Sharp


> > On Fri, Mar 22, 2013 at 06:33:26PM +, Cortes, Alexis wrote:
> > > Hi Tony,
> > > 
> > > Well, considering the circumstances, the only issue I see here is that 
> > > the system won't be able to wake on a device connect if the port to which 
> > > the device was connected enters in compliance mode (I might add that 
> > > compliance mode is not a 100% of the times failure), however I haven't 
> > > tested this scenario before. 
> > > 
> > > However I think that this problem doesn't worth to disable 
> > > suspend/hibernate, but this is my opinion. I wonder if there's a way to 
> > > re-work this scenario.
> > > 
> > > Best Regards,
> > > Alexis Cortes.
> > > 
> > > -Original Message-
> > > From: Tony Camuso [mailto:tcam...@redhat.com] 
> > > Sent: Friday, March 22, 2013 11:44 AM
> > > To: Cortes, Alexis
> > > Cc: Sarah Sharp; Alan Stern; linux-usb@vger.kernel.org; r...@sisk.pl; 
> > > dzic...@redhat.com
> > > Subject: Re: [PATCH v4] xhci - correct comp_mode_recovery_timer on return 
> > > from hibernate
> > > 
> > > On 03/14/2013 05:42 PM, Alexis R. Cortes wrote:
> > > > Hi Sarah,
> > > >
> > > > On 3/11/2013 5:20 PM, Sarah Sharp wrote:
> > > >> On Mon, Mar 11, 2013 at 05:33:26PM +, Cortes, Alexis wrote:
> > > >>> Hi Sarah,
> > > >>>
> > > >>> Sorry for my delayed response, I was investigating this. By 
> > > >>> 'Inactive' state you mean the Compliance mode? since SS.Inactive and 
> > > >>> Compliance are not the same.
> > > >>
> > > >> Yes, I mean Compliance mode.
> > > >>
> > > >>> When in D3hot or D3cold, the host must be able to transmit a PME 
> > > >>> whenever a device is plugged into the DS port.  If a SS device is 
> > > >>> plugged into DS port and fails to make it to U0, the Port will land 
> > > >>> in Compliance or SS.Disabled.  If Compliance, then there will be no 
> > > >>> PME notification.  If it lands in SS.Disabled, the USB2 will be 
> > > >>> enabled and then a PME notification will be sent for USB2 connection. 
> > > >>> I just realized this.
> > > >>
> > > >> Then we definitely need to poll during runtime suspend, or disable 
> > > >> runtime PM for the PCI device all together.
> > > >> Does this mean wake from S3 (system suspend) on device connect will 
> > > >> be broken as well, if the port fails to make it to U0 and goes into 
> > > >> Compliance mode?
> > > >
> > > > I believe so, since the timing issues caused by the hardware could 
> > > > make the port enter to Compliance, thus it will never reach U0. 
> > > > However I have never tested this scenario.
> > > >
> > > > Best Regards,
> > > > Alexis Cortes.
> > > >
> > > 
> > > Alexis,
> > > 
> > > Does this mean that systems having this chip should not use 
> > > hibernate/suspend?
> > > 
> > > --
> > > 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
> -- 
> I speak only for myself.
> Rafael J. Wysocki, Intel Open Source Technology Center.
--
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: EHCI: DT support for generic bus glue

2013-03-25 Thread Arnd Bergmann
On Monday 25 March 2013, Alan Stern wrote:
> >  
> > + if (!dev->dev.platform_data) {
> > + dev->dev.platform_data = &ehci_platform_defaults;
> > + dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
> > + dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
> 
> In view of Felipe's comment, shouldn't these last two lines be 
> controlled by dev->dev.of_node != NULL instead?

We could do that, or alternatively like this

if (!dev->dev.platform_data) {
dev->dev.platform_data = &ehci_platform_defaults;
if (!dev->dev.dma_mask)
dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
if (!dev->dev.coherent_dma_mask)
dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);

which would have the additional advantage that platforms can then
call platform_device_register_resndata() to create the device
and get a reasonable default dma mask (EHCI should always have
32 bit DMA, unless the platform is really screwed), rather than
statically declaring platform devices.

Arnd
--
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 v4] xhci - correct comp_mode_recovery_timer on return from hibernate

2013-03-25 Thread Rafael J. Wysocki
On Monday, March 25, 2013 02:35:37 PM Sarah Sharp wrote:
> Alan,
> 
> Is there a way to disable runtime PM for a PCI host controller, but
> still allow the system to suspend/hibernate?

It should be.  Just write "on" to the controller's power/control file in sysfs.

Thanks,
Rafael


> On Fri, Mar 22, 2013 at 06:33:26PM +, Cortes, Alexis wrote:
> > Hi Tony,
> > 
> > Well, considering the circumstances, the only issue I see here is that the 
> > system won't be able to wake on a device connect if the port to which the 
> > device was connected enters in compliance mode (I might add that compliance 
> > mode is not a 100% of the times failure), however I haven't tested this 
> > scenario before. 
> > 
> > However I think that this problem doesn't worth to disable 
> > suspend/hibernate, but this is my opinion. I wonder if there's a way to 
> > re-work this scenario.
> > 
> > Best Regards,
> > Alexis Cortes.
> > 
> > -Original Message-
> > From: Tony Camuso [mailto:tcam...@redhat.com] 
> > Sent: Friday, March 22, 2013 11:44 AM
> > To: Cortes, Alexis
> > Cc: Sarah Sharp; Alan Stern; linux-usb@vger.kernel.org; r...@sisk.pl; 
> > dzic...@redhat.com
> > Subject: Re: [PATCH v4] xhci - correct comp_mode_recovery_timer on return 
> > from hibernate
> > 
> > On 03/14/2013 05:42 PM, Alexis R. Cortes wrote:
> > > Hi Sarah,
> > >
> > > On 3/11/2013 5:20 PM, Sarah Sharp wrote:
> > >> On Mon, Mar 11, 2013 at 05:33:26PM +, Cortes, Alexis wrote:
> > >>> Hi Sarah,
> > >>>
> > >>> Sorry for my delayed response, I was investigating this. By 'Inactive' 
> > >>> state you mean the Compliance mode? since SS.Inactive and Compliance 
> > >>> are not the same.
> > >>
> > >> Yes, I mean Compliance mode.
> > >>
> > >>> When in D3hot or D3cold, the host must be able to transmit a PME 
> > >>> whenever a device is plugged into the DS port.  If a SS device is 
> > >>> plugged into DS port and fails to make it to U0, the Port will land in 
> > >>> Compliance or SS.Disabled.  If Compliance, then there will be no PME 
> > >>> notification.  If it lands in SS.Disabled, the USB2 will be enabled and 
> > >>> then a PME notification will be sent for USB2 connection. I just 
> > >>> realized this.
> > >>
> > >> Then we definitely need to poll during runtime suspend, or disable 
> > >> runtime PM for the PCI device all together.
> > >> Does this mean wake from S3 (system suspend) on device connect will 
> > >> be broken as well, if the port fails to make it to U0 and goes into 
> > >> Compliance mode?
> > >
> > > I believe so, since the timing issues caused by the hardware could 
> > > make the port enter to Compliance, thus it will never reach U0. 
> > > However I have never tested this scenario.
> > >
> > > Best Regards,
> > > Alexis Cortes.
> > >
> > 
> > Alexis,
> > 
> > Does this mean that systems having this chip should not use 
> > hibernate/suspend?
> > 
> > --
> > 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
-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
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 v4] xhci - correct comp_mode_recovery_timer on return from hibernate

2013-03-25 Thread Sarah Sharp
Alan,

Is there a way to disable runtime PM for a PCI host controller, but
still allow the system to suspend/hibernate?

Sarah Sharp

On Fri, Mar 22, 2013 at 06:33:26PM +, Cortes, Alexis wrote:
> Hi Tony,
> 
> Well, considering the circumstances, the only issue I see here is that the 
> system won't be able to wake on a device connect if the port to which the 
> device was connected enters in compliance mode (I might add that compliance 
> mode is not a 100% of the times failure), however I haven't tested this 
> scenario before. 
> 
> However I think that this problem doesn't worth to disable suspend/hibernate, 
> but this is my opinion. I wonder if there's a way to re-work this scenario.
> 
> Best Regards,
> Alexis Cortes.
> 
> -Original Message-
> From: Tony Camuso [mailto:tcam...@redhat.com] 
> Sent: Friday, March 22, 2013 11:44 AM
> To: Cortes, Alexis
> Cc: Sarah Sharp; Alan Stern; linux-usb@vger.kernel.org; r...@sisk.pl; 
> dzic...@redhat.com
> Subject: Re: [PATCH v4] xhci - correct comp_mode_recovery_timer on return 
> from hibernate
> 
> On 03/14/2013 05:42 PM, Alexis R. Cortes wrote:
> > Hi Sarah,
> >
> > On 3/11/2013 5:20 PM, Sarah Sharp wrote:
> >> On Mon, Mar 11, 2013 at 05:33:26PM +, Cortes, Alexis wrote:
> >>> Hi Sarah,
> >>>
> >>> Sorry for my delayed response, I was investigating this. By 'Inactive' 
> >>> state you mean the Compliance mode? since SS.Inactive and Compliance are 
> >>> not the same.
> >>
> >> Yes, I mean Compliance mode.
> >>
> >>> When in D3hot or D3cold, the host must be able to transmit a PME whenever 
> >>> a device is plugged into the DS port.  If a SS device is plugged into DS 
> >>> port and fails to make it to U0, the Port will land in Compliance or 
> >>> SS.Disabled.  If Compliance, then there will be no PME notification.  If 
> >>> it lands in SS.Disabled, the USB2 will be enabled and then a PME 
> >>> notification will be sent for USB2 connection. I just realized this.
> >>
> >> Then we definitely need to poll during runtime suspend, or disable 
> >> runtime PM for the PCI device all together.
> >> Does this mean wake from S3 (system suspend) on device connect will 
> >> be broken as well, if the port fails to make it to U0 and goes into 
> >> Compliance mode?
> >
> > I believe so, since the timing issues caused by the hardware could 
> > make the port enter to Compliance, thus it will never reach U0. 
> > However I have never tested this scenario.
> >
> > Best Regards,
> > Alexis Cortes.
> >
> 
> Alexis,
> 
> Does this mean that systems having this chip should not use hibernate/suspend?
> 
> --
> 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: [PATCH] USB: EHCI: DT support for generic bus glue

2013-03-25 Thread Alan Stern
On Mon, 25 Mar 2013, Arnd Bergmann wrote:

> This lets us use the ehci-generic driver on platforms without special
> requirements for their ehci controllers. In particular, this is true
> for the vt8500/wm8x50 platforms, which currently have a separate
> driver that causes problems with multiplatform configurations.

>  static int ehci_platform_probe(struct platform_device *dev)
>  {
>   struct usb_hcd *hcd;
>   struct resource *res_mem;
> - struct usb_ehci_pdata *pdata = dev->dev.platform_data;
> + struct usb_ehci_pdata *pdata;
>   int irq;
>   int err = -ENOMEM;
>  
> - if (!pdata) {
> - WARN_ON(1);
> - return -ENODEV;
> - }
> -
>   if (usb_disabled())
>   return -ENODEV;
>  
> + if (!dev->dev.platform_data) {
> + dev->dev.platform_data = &ehci_platform_defaults;
> + dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
> + dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);

In view of Felipe's comment, shouldn't these last two lines be 
controlled by dev->dev.of_node != NULL instead?

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 v3 00/94] USB: serial: disconnect-related patches for 3.10

2013-03-25 Thread Greg Kroah-Hartman
On Thu, Mar 21, 2013 at 12:36:17PM +0100, Johan Hovold wrote:
> This is v3 of the USB-disconnect series rebased on Linus tree of last
> week (c41b3810c09) and the recently submitted fixes-series:
> 
>   USB: fixes for 3.9-final
> 
> I retained Alan's ACK on the urb-poison patch. 
> 
> This series fixes a bunch of issues related to device disconnect. As
> the diffstat shows:
> 
>   35 files changed, 601 insertions(+), 1576 deletions(-)
> 
> a lot of boilerplate and broken code is removed in the process.

Very nice job, thanks for doing all of this work, it's now all applied.

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: [PATCH] USB: EHCI: DT support for generic bus glue

2013-03-25 Thread Arnd Bergmann
On Monday 25 March 2013, Alan Stern wrote:
> On Mon, 25 Mar 2013, Felipe Balbi wrote:
>
> > this ehci_platform_defaults is quite a hack. Would be much better to see
> > a proper re-factoring of the code so that it actually learns about DT
> > and platform_data.
> > 
> > So, if dev->dev.platform_data is NULL, you shouldn't error, rather you
> > should just assume the default, rather than this quick little hack.
> > 
> > Alan has final saying though.
> 
> IMO, using ehci_platform_defaults is a way of assuming the default.  
> In other words, it's not a bad hack.  I'm okay with this this approach
> (in fact, it was my suggestion originally).

I intentionally did not add any properties for the fields in the current
usb_ehci_pdata. It's not possible to implement the callbacks using just
DT, and the flags are all defined so that 'false' is the default that
happens to be used by the compatible="wm,prizm-ehci" binding.

We can easily extend this driver to also cover the flags or the
caps_offset, or we can add support for regulators and clocks, but
I would prefer to do those only when we actually add support for
a device that needs them.

> On the other hand, it would be nice to have a clearer way of indicating 
> that the driver was invoked because of a DT match, something better 
> than just noticing that dev->dev.platform_data is NULL.  But I guess 
> this is a legitimate option even for regular platform drivers -- if 
> they don't have any specific requirements, they may as well pass a NULL 
> pointer instead of a pointer to an empty structure.

I'm certainly fine doing it either way: leave the defaults for pdata=NULL
or require either a DT match or a pdata pointer (or both, in case of
auxdata, I guess).

Arnd
--
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] staging: dwc2: always release host channel after dequeueing

2013-03-25 Thread Paul Zimmerman
> From: Greg KH [mailto:gre...@linuxfoundation.org]
> Sent: Monday, March 25, 2013 11:14 AM
> 
> On Sat, Mar 23, 2013 at 08:35:40PM +0200, Felipe Balbi wrote:
> > On Fri, Mar 22, 2013 at 05:47:53PM -0700, Paul Zimmerman wrote:
> > > Previously, when an active urb was dequeued, its host channel would
> > > not always be released. There is some special handling for this in
> > > dwc2_hc_chhltd_intr_dma, but when it was the last urb/qtd in its qh, a
> > > safeguard in dwc2_hc_n_intr would short-circuit and prevent the regular
> > > interrupt handlers from running, without releasing the channel.
> > >
> > > This is easily triggered when using a 3G modem using the option driver.
> > > Opening and closing any ttyUSBx device will eat up a host channel that
> > > is forever unusable from that point on.
> > >
> > > Signed-off-by: Matthijs Kooijman 
> > > Signed-off-by: Paul Zimmerman 
> >
> > since this is basically Matthijs' patch with a few extra details from
> > you, it should still be marked as authored by Matthijs. All you did was
> > add a few extra checks for qtd being valid and fixed comment styles.
> >
> > What you can (should?) do is add a note on commit log specifying what
> > you have changed, something like below:
> 
> 
> 
> I agree, Paul, please redo these two patches and resend them, with the
> correct authorship information intact.

OK, I just sent out a corrected version of the second patch, hopefully
I got the format right this time. I will send out a new version of the
first patch in a bit.

-- 
Paul

--
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: EHCI: DT support for generic bus glue

2013-03-25 Thread Felipe Balbi
On Mon, Mar 25, 2013 at 01:47:19PM -0400, Alan Stern wrote:
> On Mon, 25 Mar 2013, Felipe Balbi wrote:
> 
> > > @@ -62,22 +64,26 @@ static const struct ehci_driver_overrides 
> > > platform_overrides __initdata = {
> > >   .reset =ehci_platform_reset,
> > >  };
> > >  
> > > +static struct usb_ehci_pdata ehci_platform_defaults;
> > 
> > this ehci_platform_defaults is quite a hack. Would be much better to see
> > a proper re-factoring of the code so that it actually learns about DT
> > *and* platform_data.
> > 
> > So, if dev->dev.platform_data is NULL, you shouldn't error, rather you
> > should just assume the default, rather than this quick little hack.
> > 
> > Alan has final saying though.
> 
> IMO, using ehci_platform_defaults _is_ a way of assuming the default.  
> In other words, it's not a bad hack.  I'm okay with this this approach
> (in fact, it was my suggestion originally).
> 
> On the other hand, it would be nice to have a clearer way of indicating 
> that the driver was invoked because of a DT match, something better 
> than just noticing that dev->dev.platform_data is NULL.  But I guess 
> this is a legitimate option even for regular platform drivers -- if 

usually we check that dev->of_node is a valid pointer.

> they don't have any specific requirements, they may as well pass a NULL 
> pointer instead of a pointer to an empty structure.

that was my point.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] USB: EHCI: DT support for generic bus glue

2013-03-25 Thread Arnd Bergmann
On Monday 25 March 2013, Tony Prisk wrote:
> I'll take a look at this and get back to you before Easter.
> 

Great, thanks a lot!

Arnd
--
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] staging: dwc2: always release host channel after dequeueing

2013-03-25 Thread Paul Zimmerman
From: Matthijs Kooijman 

Previously, when an active urb was dequeued, its host channel would
not always be released. There is some special handling for this in
dwc2_hc_chhltd_intr_dma, but when it was the last urb/qtd in its qh, a
safeguard in dwc2_hc_n_intr would short-circuit and prevent the regular
interrupt handlers from running, without releasing the channel.

This is easily triggered when using a 3G modem using the option driver.
Opening and closing any ttyUSBx device will eat up a host channel that
is forever unusable from that point on.

Signed-off-by: Matthijs Kooijman 
[pa...@synopsys.com: fixed comment style and added a couple of NULL checks]
Signed-off-by: Paul Zimmerman 
---
 drivers/staging/dwc2/hcd_intr.c | 33 +
 1 file changed, 29 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/dwc2/hcd_intr.c b/drivers/staging/dwc2/hcd_intr.c
index 4b007ab..8b68df8 100644
--- a/drivers/staging/dwc2/hcd_intr.c
+++ b/drivers/staging/dwc2/hcd_intr.c
@@ -708,7 +708,7 @@ static void dwc2_release_channel(struct dwc2_hsotg *hsotg,
free_qtd = 1;
break;
case DWC2_HC_XFER_XACT_ERR:
-   if (qtd->error_count >= 3) {
+   if (qtd && qtd->error_count >= 3) {
dev_vdbg(hsotg->dev,
 "  Complete URB with transaction error\n");
free_qtd = 1;
@@ -729,7 +729,7 @@ static void dwc2_release_channel(struct dwc2_hsotg *hsotg,
case DWC2_HC_XFER_PERIODIC_INCOMPLETE:
dev_vdbg(hsotg->dev, "  Complete URB with I/O error\n");
free_qtd = 1;
-   if (qtd->urb) {
+   if (qtd && qtd->urb) {
qtd->urb->status = -EIO;
dwc2_host_complete(hsotg, qtd->urb->priv, qtd->urb,
   -EIO);
@@ -1708,8 +1708,9 @@ static bool dwc2_halt_status_ok(struct dwc2_hsotg *hsotg,
dev_dbg(hsotg->dev,
"hcint 0x%08x, hcintmsk 0x%08x, hcsplt 0x%08x,\n",
chan->hcint, hcintmsk, hcsplt);
-   dev_dbg(hsotg->dev, "qtd->complete_split %d\n",
-   qtd->complete_split);
+   if (qtd)
+   dev_dbg(hsotg->dev, "qtd->complete_split %d\n",
+   qtd->complete_split);
dev_warn(hsotg->dev,
 "%s: no halt status, channel %d, ignoring interrupt\n",
 __func__, chnum);
@@ -1937,7 +1938,31 @@ static void dwc2_hc_n_intr(struct dwc2_hsotg *hsotg, int 
chnum)
chan->hcint = hcint;
hcint &= hcintmsk;
 
+   /*
+* If the channel was halted due to a dequeue, the qtd list might
+* be empty or at least the first entry will not be the active qtd.
+* In this case, take a shortcut and just release the channel.
+*/
+   if (chan->halt_status == DWC2_HC_XFER_URB_DEQUEUE) {
+   /*
+* If the channel was halted, this should be the only
+* interrupt unmasked
+*/
+   WARN_ON(hcint != HCINTMSK_CHHLTD);
+   if (hsotg->core_params->dma_desc_enable > 0)
+   dwc2_hcd_complete_xfer_ddma(hsotg, chan, chnum,
+   chan->halt_status);
+   else
+   dwc2_release_channel(hsotg, chan, NULL,
+chan->halt_status);
+   return;
+   }
+
if (list_empty(&chan->qh->qtd_list)) {
+   /*
+* TODO: Will this ever happen with the
+* DWC2_HC_XFER_URB_DEQUEUE handling above?
+*/
dev_dbg(hsotg->dev, "## no QTD queued for channel %d ##\n",
chnum);
dev_dbg(hsotg->dev,
-- 
1.8.2.rc0.16.g20a599e

--
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: EHCI: DT support for generic bus glue

2013-03-25 Thread Tony Prisk
On Mon, 2013-03-25 at 16:20 +, Arnd Bergmann wrote:
> This lets us use the ehci-generic driver on platforms without special
> requirements for their ehci controllers. In particular, this is true
> for the vt8500/wm8x50 platforms, which currently have a separate
> driver that causes problems with multiplatform configurations.
> 
> Cc: Tony Prisk 
> Cc: Alexey Charkov 
> Acked-by: Alan Stern 
> Signed-off-by: Arnd Bergmann 
> ---
> Tony, Alexey et al: could one of you test if this works for you?
> 
>  drivers/usb/host/ehci-hcd.c  |   5 --
>  drivers/usb/host/ehci-platform.c |  28 ++--
>  drivers/usb/host/ehci-vt8500.c   | 150 -
>  3 files changed, 22 insertions(+), 161 deletions(-)

I'll take a look at this and get back to you before Easter.

Regards
Tony P

--
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] staging: dwc2: always release host channel after dequeueing

2013-03-25 Thread Greg KH
On Sat, Mar 23, 2013 at 08:35:40PM +0200, Felipe Balbi wrote:
> On Fri, Mar 22, 2013 at 05:47:53PM -0700, Paul Zimmerman wrote:
> > Previously, when an active urb was dequeued, its host channel would
> > not always be released. There is some special handling for this in
> > dwc2_hc_chhltd_intr_dma, but when it was the last urb/qtd in its qh, a
> > safeguard in dwc2_hc_n_intr would short-circuit and prevent the regular
> > interrupt handlers from running, without releasing the channel.
> > 
> > This is easily triggered when using a 3G modem using the option driver.
> > Opening and closing any ttyUSBx device will eat up a host channel that
> > is forever unusable from that point on.
> > 
> > Signed-off-by: Matthijs Kooijman 
> > Signed-off-by: Paul Zimmerman 
> 
> since this is basically Matthijs' patch with a few extra details from
> you, it should still be marked as authored by Matthijs. All you did was
> add a few extra checks for qtd being valid and fixed comment styles.
> 
> What you can (should?) do is add a note on commit log specifying what
> you have changed, something like below:



I agree, Paul, please redo these two patches and resend them, with the
correct authorship information intact.

thanks,

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: xhci page fault panic on Ubuntu kernel with HP desktop hardware

2013-03-25 Thread Sarah Sharp
On Mon, Mar 25, 2013 at 05:43:40PM +0100, Yann Sionneau wrote:
> Hello Sarah,

Hi Yann!

> I am a friend of Florian Fainelli, we met at 2010 RMLL at Bordeaux
> (France) :)
> I hope you are doing well and are still enjoying working on the Linux
> kernel USB 3.0 stack at Intel!

Yep, I'm still plugging away at it.

> My colleague (Olivier in cc) at the office has sometimes (while flashing
> our product with its desktop computer) a page fault (leading to kernel
> panic) due to xhci error.

Ugh, that's bad.  Thanks for reporting this.

> I thought maybe you could have a look at the stack trace in order to see
> if this is a known issue or if it's a new bug that needs a bug tracker
> entry somewhere (or a mailing list email).

I haven't had a report of a page fault in quite some time.  I'll have to
look at your log files in more detail and see if it's a past bug
resurfacing in Ubuntu's 3.2 kernel.

How reproducible is the bug?

> As attached files you can find lsusb -t and lsusb -vvv as well as lspci
> and a picture of the screen with the kernel stack trace.

Ok, I'll take a look at them and get back to you.  In the meantime, can
you compile the latest stable kernel (3.8.4), and see if you can
reproduce your bug on that kernel?  If you need help compiling a custom
kernel, please take a look at these instructions:

http://kernelnewbies.org/KernelBuild

Please compile with CONFIG_USB_DEBUG and CONFIG_USB_XHCI_HCD_DEBUGGING
turned on.  If you can't reproduce your bug on 3.8.4, turn them off,
recompile, and see if you can reproduce it again.

Sarah Sharp

> Ubuntu version:
> 
> lsb_release -a
> No LSB modules are available.
> Distributor ID:   Ubuntu
> Description:  Ubuntu 12.04.2 LTS
> Release:  12.04
> Codename: precise
> 
> uname -a
> Linux FR-B-800-0719 3.2.0-39-generic-pae #62-Ubuntu SMP Wed Feb 27 22:25:11 
> UTC 2013 i686 i686 i386 GNU/Linux
> 
> Hardware:
> HP Compaq Elite 8300 Small Form Factor PC: 
> http://h10010.www1.hp.com/wwpc/us/en/sm/WF05a/12454-12454-64287-5230499-3328898-5232852.html?dnr=1
> 
> Thanks!
> 
> See you.
> 
> Best regards, 
> 
> -- mail_sign.htm
> parrot_logo_int
> *Yann Sionneau*   Parrot S.A. 
> Embedded software engineer174, quai de Jemmapes   t:  +33 (0)1 48 03 60 60
> OEM   75010 Paris, France f:  +33 (0)1 48 03 70 20
> 
> **www.parrot.com* *
> 
> 
> 

> 
> Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
> Device Descriptor:
>   bLength18
>   bDescriptorType 1
>   bcdUSB   2.00
>   bDeviceClass9 Hub
>   bDeviceSubClass 0 Unused
>   bDeviceProtocol 0 Full speed (or root) hub
>   bMaxPacketSize064
>   idVendor   0x1d6b Linux Foundation
>   idProduct  0x0002 2.0 root hub
>   bcdDevice3.02
>   iManufacturer   3 Linux 3.2.0-39-generic-pae ehci_hcd
>   iProduct2 EHCI Host Controller
>   iSerial 1 :00:1a.0
>   bNumConfigurations  1
>   Configuration Descriptor:
> bLength 9
> bDescriptorType 2
> wTotalLength   25
> bNumInterfaces  1
> bConfigurationValue 1
> iConfiguration  0 
> bmAttributes 0xe0
>   Self Powered
>   Remote Wakeup
> MaxPower0mA
> Interface Descriptor:
>   bLength 9
>   bDescriptorType 4
>   bInterfaceNumber0
>   bAlternateSetting   0
>   bNumEndpoints   1
>   bInterfaceClass 9 Hub
>   bInterfaceSubClass  0 Unused
>   bInterfaceProtocol  0 Full speed (or root) hub
>   iInterface  0 
>   Endpoint Descriptor:
> bLength 7
> bDescriptorType 5
> bEndpointAddress 0x81  EP 1 IN
> bmAttributes3
>   Transfer TypeInterrupt
>   Synch Type   None
>   Usage Type   Data
> wMaxPacketSize 0x0004  1x 4 bytes
> bInterval  12
> Hub Descriptor:
>   bLength   9
>   bDescriptorType  41
>   nNbrPorts 3
>   wHubCharacteristic 0x000a
> No power switching (usb 1.0)
> Per-port overcurrent protection
>   bPwrOn2PwrGood   10 * 2 milli seconds
>   bHubContrCurrent  0 milli Ampere
>   DeviceRemovable0x00
>   PortPwrCtrlMask0xff
>  Hub Port Status:
>Port 1: .0507 highspeed power suspend enable connect
>Port 2: .0100 power
>Port 3: .0100 power
> Device Status: 0x0001
>   Self Powered
> 
> Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
> Device Descriptor:
>   bLength18
>   bDescriptorType 1
>   bcdUSB   2.00
>   bDeviceClass9 Hub
>   bDeviceSubClass 0 Unused
>   bDeviceProtocol 0 Full speed (or root) hub
>   bMaxPacketSize064
>   idVendor   

Re: Help with USB issues at boot-up on i.MX25 (linux 3.5.4)

2013-03-25 Thread Alan Stern
On Mon, 25 Mar 2013, David Linares wrote:

> > Start with usbmon (see Documentation/usb/usbmon.txt).
> 
> Thanks Alan. I have just compiled my kernel with debugfs and usbmon.
> I can now easily capture raw text traces after boot-up. But I am interested
> in capturing these traces at boot time because that's when the problems
> occur. Any way to achieve that?

No, there isn't any way.  The best you can do is build the host 
controller driver as a module, and start up usbmon before the module is 
loaded.

> While enabling usbmon, I noticed something that can be related.
> There is a config: "Maximum VBUS Power usage" which is currently set to
> 300mA in my case.

That option (USB_GADGET_VBUS_DRAW) applies only to gadgets.  That is,
it's meant for the part of the USB stack used in peripherals, not in 
hosts.

> But here is the USB dongle I am using:
> 
> lsusb -v
> ...
>   idVendor   0x148f Ralink Technology, Corp.
>   idProduct  0x5370 RT5370 Wireless Adapter
> ..
>   MaxPower  450mA
> 
> I guess setting 450mA will sort out my issue number 4 and avoid the
> "usb 1-1.1: rejected 1 configuration due to insufficient available bus power"
> right?

No, it won't have any effect at all.  What might help would be to plug
the wireless adapter into a powered hub instead of directly into your
computer.

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: Linux USB file storage gadget with new UDC

2013-03-25 Thread Alan Stern
On Tue, 26 Mar 2013, victor yeo wrote:

> I thought Halt feature is optional. I will add code to instruct
> hardware to set the halt feature. I suppose the driver needs to handle
> usb_ep_clear_halt() too. Thanks.
> 
> g_file_storage gadget: SCSI command: READ(10);  Dc=10, Di=4096;  Hc=10, 
> Hi=4096
> g_file_storage gadget-lun0: file read 4096 @ 0 -> 4096
> 
> About the SCSI_READ_10 command, why is it reading 4096 bytes, as the
> MBR(master boot record) is only 512 bytes?

Linux always tries to do I/O in chunks of an entire memory page (4 KB).

> >> In the log file, is there any invalid request received on endpoint 0?
> >
> > In the usbmon file there is.  It is this line:
> >
> >> f4ae6f40 1217192721 S Co:2:018:0 s 21 ff    0
> 
> ok, i will add code to UDC to instruct hardware to send NAK upon
> receiving invalid request on endpoint 0. Does it mean that UDC driver
> has to check for invalid request on endpoint 0?

No.  The UDC driver has no way to know whether a request is valid or 
not.  Read the description of the "setup" member of the 
usb_gadget_driver structure in the header file.

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] usb: Add usb port system pm support

2013-03-25 Thread Sarah Sharp
You forgot to Cc the linux-usb mailing list.

On Mon, Mar 25, 2013 at 04:21:42PM +0800, Lan Tianyu wrote:
> This patch is to add usb port system pm support. Add
> usb port's system suspend/resume callbacks and call
> usb_port_runtime_resume/suspend() to power off these
> ports whose pm qos NO_POWER_OFF flag is not set, system
> wakeup is disabled and persist is enalbed.
> 
> During system pm, usb port should be powered off after
> dev being suspended and powered on before dev being
> resumed. Decause usb ports and devs enable async suspend,
> call device_pm_wait_for_dev() in the usb_port_system_suspend()
> and usb_port_resume() to keeping the order.
> 
> Usb_port_system_suspend() ignores EAGAIN from usb_port_runtime_suspend().
> Because EAGAIN is caused by pm qos NO_POWER_OFF setting. This is
> not an error for usb port system pm.
> 
> If usb port was already powered off by runtime pm with
> port_dev->power_is_on being false, usb_port_system_suspend()
> returns directly.
> 
> If usb port was not powered off during system suspend with
> port_dev->power_is_on being true, usb_port_system_resume()
> returns directly.
> 
> Signed-off-by: Lan Tianyu 
> ---
>  drivers/usb/core/hub.c  |4 
>  drivers/usb/core/port.c |   48 
> +++
>  2 files changed, 52 insertions(+)
> 
> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> index 5480352..09948b6 100644
> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
> @@ -3146,6 +3146,10 @@ int usb_port_resume(struct usb_device *udev, 
> pm_message_t msg)
>   int status;
>   u16 portchange, portstatus;
>  
> + /* Wait for usb port system resume finishing */
> + if (!PMSG_IS_AUTO(msg))
> + device_pm_wait_for_dev(&udev->dev, &port_dev->dev);
> +
>   if (port_dev->did_runtime_put) {
>   status = pm_runtime_get_sync(&port_dev->dev);
>   port_dev->did_runtime_put = false;
> diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
> index 797f9d5..553cab3 100644
> --- a/drivers/usb/core/port.c
> +++ b/drivers/usb/core/port.c
> @@ -136,9 +136,57 @@ static int usb_port_runtime_suspend(struct device *dev)
>   usb_autopm_put_interface(intf);
>   return retval;
>  }
> +#else
> +static int usb_port_runtime_suspend(struct device *dev) { return 0; }
> +static int usb_port_runtime_resume(struct device *dev) { return 0; }
>  #endif
>  
> +static int usb_port_system_suspend(struct device *dev)
> +{
> + struct usb_port *port_dev = to_usb_port(dev);
> + int retval;
> +
> + if (!port_dev->power_is_on)
> + return 0;
> +
> + if (port_dev->child) {
> + struct usb_device *udev = port_dev->child;
> +
> + /*
> +  * usb port can't be powered off when dev's system
> +  * wakeup is enabled or persist is disabled.
> +  */
> + if (device_may_wakeup(&udev->dev)
> + || !udev->persist_enabled)
> + return 0;
> +
> + /*
> +  * usb port should be powered off after usb dev
> +  * being suspended.
> +  */
> + device_pm_wait_for_dev(dev, &port_dev->child->dev);
> + }
> +
> + retval = usb_port_runtime_suspend(dev);
> + if (retval < 0 && retval != -EAGAIN)
> + return retval;
> +
> + return 0;
> +}
> +
> +static int usb_port_system_resume(struct device *dev)
> +{
> + struct usb_port *port_dev = to_usb_port(dev);
> +
> + if (port_dev->power_is_on)
> + return 0;
> +
> + return usb_port_runtime_resume(dev);
> +}
> +
>  static const struct dev_pm_ops usb_port_pm_ops = {
> + .suspend =  usb_port_system_suspend,
> + .resume =   usb_port_system_resume,
>  #ifdef CONFIG_USB_SUSPEND
>   .runtime_suspend =  usb_port_runtime_suspend,
>   .runtime_resume =   usb_port_runtime_resume,
> -- 
> 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: [PATCH] USB: EHCI: DT support for generic bus glue

2013-03-25 Thread Alan Stern
On Mon, 25 Mar 2013, Felipe Balbi wrote:

> > @@ -62,22 +64,26 @@ static const struct ehci_driver_overrides 
> > platform_overrides __initdata = {
> > .reset =ehci_platform_reset,
> >  };
> >  
> > +static struct usb_ehci_pdata ehci_platform_defaults;
> 
> this ehci_platform_defaults is quite a hack. Would be much better to see
> a proper re-factoring of the code so that it actually learns about DT
> *and* platform_data.
> 
> So, if dev->dev.platform_data is NULL, you shouldn't error, rather you
> should just assume the default, rather than this quick little hack.
> 
> Alan has final saying though.

IMO, using ehci_platform_defaults _is_ a way of assuming the default.  
In other words, it's not a bad hack.  I'm okay with this this approach
(in fact, it was my suggestion originally).

On the other hand, it would be nice to have a clearer way of indicating 
that the driver was invoked because of a DT match, something better 
than just noticing that dev->dev.platform_data is NULL.  But I guess 
this is a legitimate option even for regular platform drivers -- if 
they don't have any specific requirements, they may as well pass a NULL 
pointer instead of a pointer to an empty structure.

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] USB: hub: Avoid NULL pointer dereference when hub doesn't have any ports

2013-03-25 Thread David Linares
On 25 March 2013 17:31, Greg Kroah-Hartman  wrote:
> On Mon, Mar 25, 2013 at 10:50:27AM +, David Linares wrote:
>> Return an error if hub->descriptor->bNbrPorts==0. Without this additional
>> check, we can end up doing a "hub->ports = kzalloc(0, GFP_KERNEL)".
>> This hub->ports pointer will therefore be non-NULL and will be used.
>> Example of dmesg:
>>INIT: usb 1-1: New USB device found, idVendor=0424, idProduct=2512
>>usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
>>hub 1-1:1.0: USB hub found
>>version 2.86 bootinghub 1-1:1.0: 0 ports detected
>>Unable to handle kernel NULL pointer dereference at virtual address 
>> 0010
>
> How can a hub not have any ports?  That kind of defeats the goal of
> having a hub at all.
>

Yeah, I know :-) I am still investigating a few USB issues and one of them was
leading to this weird hub init with 0 port.
So far, it seems to be a USB power issue. I started another thread to try to get
some help.

> Not to say your patch isn't good, I'll take it, but this does sound
> quite odd.

Thanks for taking my very first patch.

>
> thanks,
>
> 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: [PATCH] USB: hub: Avoid NULL pointer dereference when hub doesn't have any ports

2013-03-25 Thread Greg Kroah-Hartman
On Mon, Mar 25, 2013 at 10:50:27AM +, David Linares wrote:
> Return an error if hub->descriptor->bNbrPorts==0. Without this additional
> check, we can end up doing a "hub->ports = kzalloc(0, GFP_KERNEL)".
> This hub->ports pointer will therefore be non-NULL and will be used.
> Example of dmesg:
>INIT: usb 1-1: New USB device found, idVendor=0424, idProduct=2512
>usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
>hub 1-1:1.0: USB hub found
>version 2.86 bootinghub 1-1:1.0: 0 ports detected
>Unable to handle kernel NULL pointer dereference at virtual address 
> 0010

How can a hub not have any ports?  That kind of defeats the goal of
having a hub at all.

Not to say your patch isn't good, I'll take it, but this does sound
quite odd.

thanks,

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: [PATCH v4 0/6] support other fsl SoCs with usbmisc + small fixes

2013-03-25 Thread Greg KH
On Mon, Mar 25, 2013 at 05:29:31PM +0100, Michael Grzeschik wrote:
> Hi Alexander, Fabio, Greg,
> 
> On Mon, Mar 25, 2013 at 10:11:15AM -0300, Fabio Estevam wrote:
> > Hi Alexander,
> > 
> > On Thu, Jan 24, 2013 at 7:42 AM, Alexander Shishkin
> >  wrote:
> > > Peter Chen  writes:
> > >
> > >> On Tue, Nov 27, 2012 at 05:16:55PM +0100, Michael Grzeschik wrote:
> > >>> Nearly every SoC from Freescale has this non-core usb registers. This 
> > >>> series
> > >>> adds support for more users of this driver.
> > >>>
> > >>> This series is based on Peter Chen's work. Its needed to merge his 
> > >>> master branch
> > >>> before applying this series:
> > >>>
> > >>> https://github.com/hzpeterchen/linux-usb.git
> > >>
> > >> I have tested it at i.mx6q sabrelite board, it works good.
> > >>
> > >> I have pushed your commit to my git, please cc me
> > >> your coming chipidea patches, thanks.
> > >>
> > >> Alex, please add:
> > >>
> > >> Reviewed-by: Peter Chen 
> > >> Tested-by: Peter Chen 
> > >
> > > Looks good, queueing this one for submission.
> > 
> > Could you please let us know what is preventing this series to be applied?
> 
> That's what our chipidea usb disaster currently looks like in detail:
> 
> http://git.pengutronix.de/git/mgr/linux.git v3.9/topic/usb-phy
> 4414a59 Merge 'v3.9/topic/usb-phy' into usb-3.9
> a806027 usb: otg: mxs-phy: remove clkgate/sftrst clearing
> 026881b usb: otg: mxs-phy: Improve mxs phy initialization
> ed42fa9 usb: mxs-phy: register phy at usb phy library
> d2783aa usb: phy: remove NULL pointer check in usb_add_phy()
> 
> /*
>  * The series usb-ci-udc has already been posted some times
>  * but it currently got no replies by Alexander.
>  */
> http://git.pengutronix.de/git/mgr/linux.git v3.9/topic/usb-ci-udc
> e548c9d Merge 'v3.9/topic/usb-ci-udc' into usb-3.9
> 80538f3 usb: chipidea: udc: add multiple td support to hardware_{en,de}queue
> 02e1c7b usb: chipidea: udc: manage dynamic amount of tds with an linked list
> 0ebb8f4 usb: chipidea: udc: prepare qhead with dma_alloc_coherent
> 39be042 usb: chipidea: udc: add the define TD_PAGE_COUNT and fix all users
> c2f0562 usb: chipidea: udc: use gfp_flags in _hardware_enqueue
> f818222 usb: chipidea: udc: move _ep_queue into an unlocked function
> 8aea3b0 usb: chipidea: udc: configure iso endpoints
> 8e61a12 usb: chipidea: udc: rework ep_enable cap setting
> e5ceed7 usb: chipidea: udc: move ZLT flag change to ep_enable
> 2e33742 usb: chipidea: udc: read status of td only once in hardware_dequeue
> 516803b usb: chipidea: udc: only clear active and halted bits in qhead
> ee95a49 usb: chipidea: udc: use {read,write}l to handle mapped data
> 
> http://git.pengutronix.de/git/mgr/linux.git v3.9/topic/imx-usbmisc
> 1174002 Merge 'v3.9/topic/imx-usbmisc' into usb-3.9
> f406383 usb: chipidea: usbmisc: skip clocks on i.MX6
> d5c8d53 usb: chipidea: usbmisc: use module_platform_driver
> 105d5d0 usb: chipidea: usbmisc: add support for ahb, ipg and per clock
> 
> http://git.pengutronix.de/git/mgr/linux.git v3.9/topic/imx-usb
> df11f8b Merge 'v3.9/topic/imx-usb' into usb-3.9
> 9a967c4 usb: chipidea: udc: add force-full-speed option
> a02af86 USB: chipidea: set STS bit in serial mode
> af34326 usb: chipidea: ci13xxx_imx: add 2nd and 3rd clock to support imx5x 
> and newer
> 5b7f6d8 usb: chipidea: pci: mark platformdata as static
> 
> /*
>  * All above branches depent on the lower branches of Alexander and Peter
>  * which we currently have rebased on v3.9-rc3 and on top of each other.
>  * It is named alex-and-peter-for-3.9.
>  */
> http://git.pengutronix.de/git/mgr/linux.git alex-and-peter-for-3.9
> 
> /*
>  * Peters branch already contain the usbmisc series,
>  * but they never made it to ci-for-greg, although
>  * Alexander already mentioned (24 Jan 2013) to queue them.
>  */
> https://github.com/hzpeterchen/linux-usb.git master^^
> 4d36511 Merge 'v3.9/topic/usb-peterchen'
> 90314f3 usb: chipidea: usbmisc: add post handling and errata fix for mx25
> edde2ad usb: chipidea: usbmisc: add mx53 support
> 6150722 usb: chipidea: usbmisc: prepare driver to handle more than one soc
> 542384e usb: chipidea: usbmisc: fix a potential race condition
> cdffb44 usb: chipidea: usbmisc: unset global varibale usbmisc on driver remove
> b8e47e3 usb: chipidea: usbmisc: rename file, struct and functions to 
> usbmisc_imx
> c5863f9 usb: chipidea: imx: select usb id pin using syscon interface
> 8c8a1f5 usb: chipidea: udc: fix the oops when plugs in usb cable after rmmod 
> gadget
> c703723 usb: chipidea: imx: add getting vbus regulator code
> e897d66 usb: chipidea: delete the delayed work
> 4c0be3e usb: chipidea: add vbus regulator control
> f1e52f8 usb: chipidea: udc: retire the flag CI13_PULLUP_ON_VBUS
> af4e743 usb: chipidea: udc: add pullup/pulldown dp at hw_device_state
> 1be0011 usb: chipidea: add otg id switch and vbus connect/disconnect detect
> 7c3c62d usb: chipidea: add otg file
> 618bfec Revert "USB: chipidea: add vbus detect for udc"
> bfe5248 USB chipidea i.M

Re: Help with USB issues at boot-up on i.MX25 (linux 3.5.4)

2013-03-25 Thread David Linares
On 25 March 2013 14:44, Alan Stern  wrote:
> On Mon, 25 Mar 2013, David Linares wrote:
>
>> Hi all,
>>
>> I am currently working on an open-source project using linux 3.5.4 on
>> an i.MX25 board manufactured by Voipac.
>> I have been experiencing all sorts of USB issues that I have logged here:
>> http://pastebin.com/Ry6fdne5
>> As you will see, it varies from detecting a hub with 0 ports, failing
>> to initialise it or failing to mount a USB dongle attached to it.
>> After trying to get some help on KernelNewbies, I was advised to find
>> the consequence of the NULL pointer dereference (bullet point 1 from
>> pastebin link), which I did. I posted my first patch earlier "[PATCH]
>> USB: hub: Avoid NULL pointer dereference when hub doesn't have any
>> ports".
>>
>> Now, I would like to get to the root cause/causes of these issues but
>> I would need your help. For example, I have no idea if a source not
>> delivering enough power could potentially lead to these kinds of
>> errors.
>
> Certainly it could.
>
>> Any help or advice on ways to carry on my investigation would be
>> gratefully received.
>
> Start with usbmon (see Documentation/usb/usbmon.txt).

Thanks Alan. I have just compiled my kernel with debugfs and usbmon.
I can now easily capture raw text traces after boot-up. But I am interested
in capturing these traces at boot time because that's when the problems
occur. Any way to achieve that?

While enabling usbmon, I noticed something that can be related.
There is a config: "Maximum VBUS Power usage" which is currently set to
300mA in my case. But here is the USB dongle I am using:

lsusb -v
...
  idVendor   0x148f Ralink Technology, Corp.
  idProduct  0x5370 RT5370 Wireless Adapter
..
  MaxPower  450mA

I guess setting 450mA will sort out my issue number 4 and avoid the
"usb 1-1.1: rejected 1 configuration due to insufficient available bus power"
right?

>
> 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] USB: EHCI: DT support for generic bus glue

2013-03-25 Thread Felipe Balbi
Hi,

On Mon, Mar 25, 2013 at 04:20:42PM +, Arnd Bergmann wrote:
> This lets us use the ehci-generic driver on platforms without special
> requirements for their ehci controllers. In particular, this is true
> for the vt8500/wm8x50 platforms, which currently have a separate
> driver that causes problems with multiplatform configurations.
> 
> Cc: Tony Prisk 
> Cc: Alexey Charkov 
> Acked-by: Alan Stern 
> Signed-off-by: Arnd Bergmann 
> ---
> Tony, Alexey et al: could one of you test if this works for you?
> 
>  drivers/usb/host/ehci-hcd.c  |   5 --
>  drivers/usb/host/ehci-platform.c |  28 ++--
>  drivers/usb/host/ehci-vt8500.c   | 150 -
>  3 files changed, 22 insertions(+), 161 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
> index 0c3314c..960e7cf 100644
> --- a/drivers/usb/host/ehci-hcd.c
> +++ b/drivers/usb/host/ehci-hcd.c
> @@ -1286,11 +1286,6 @@ MODULE_LICENSE ("GPL");
>  #define PLATFORM_DRIVER  ehci_octeon_driver
>  #endif
>  
> -#ifdef CONFIG_ARCH_VT8500
> -#include "ehci-vt8500.c"
> -#define  PLATFORM_DRIVER vt8500_ehci_driver
> -#endif
> -
>  #ifdef CONFIG_PLAT_SPEAR
>  #include "ehci-spear.c"
>  #define PLATFORM_DRIVER  spear_ehci_hcd_driver
> diff --git a/drivers/usb/host/ehci-platform.c 
> b/drivers/usb/host/ehci-platform.c
> index ca75063..27e9227 100644
> --- a/drivers/usb/host/ehci-platform.c
> +++ b/drivers/usb/host/ehci-platform.c
> @@ -18,11 +18,13 @@
>   *
>   * Licensed under the GNU/GPL. See COPYING for details.
>   */
> +#include 
>  #include 
>  #include 
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -62,22 +64,26 @@ static const struct ehci_driver_overrides 
> platform_overrides __initdata = {
>   .reset =ehci_platform_reset,
>  };
>  
> +static struct usb_ehci_pdata ehci_platform_defaults;

this ehci_platform_defaults is quite a hack. Would be much better to see
a proper re-factoring of the code so that it actually learns about DT
*and* platform_data.

So, if dev->dev.platform_data is NULL, you shouldn't error, rather you
should just assume the default, rather than this quick little hack.

Alan has final saying though.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v4 0/6] support other fsl SoCs with usbmisc + small fixes

2013-03-25 Thread Michael Grzeschik
Hi Alexander, Fabio, Greg,

On Mon, Mar 25, 2013 at 10:11:15AM -0300, Fabio Estevam wrote:
> Hi Alexander,
> 
> On Thu, Jan 24, 2013 at 7:42 AM, Alexander Shishkin
>  wrote:
> > Peter Chen  writes:
> >
> >> On Tue, Nov 27, 2012 at 05:16:55PM +0100, Michael Grzeschik wrote:
> >>> Nearly every SoC from Freescale has this non-core usb registers. This 
> >>> series
> >>> adds support for more users of this driver.
> >>>
> >>> This series is based on Peter Chen's work. Its needed to merge his master 
> >>> branch
> >>> before applying this series:
> >>>
> >>> https://github.com/hzpeterchen/linux-usb.git
> >>
> >> I have tested it at i.mx6q sabrelite board, it works good.
> >>
> >> I have pushed your commit to my git, please cc me
> >> your coming chipidea patches, thanks.
> >>
> >> Alex, please add:
> >>
> >> Reviewed-by: Peter Chen 
> >> Tested-by: Peter Chen 
> >
> > Looks good, queueing this one for submission.
> 
> Could you please let us know what is preventing this series to be applied?

That's what our chipidea usb disaster currently looks like in detail:

http://git.pengutronix.de/git/mgr/linux.git v3.9/topic/usb-phy
4414a59 Merge 'v3.9/topic/usb-phy' into usb-3.9
a806027 usb: otg: mxs-phy: remove clkgate/sftrst clearing
026881b usb: otg: mxs-phy: Improve mxs phy initialization
ed42fa9 usb: mxs-phy: register phy at usb phy library
d2783aa usb: phy: remove NULL pointer check in usb_add_phy()

/*
 * The series usb-ci-udc has already been posted some times
 * but it currently got no replies by Alexander.
 */
http://git.pengutronix.de/git/mgr/linux.git v3.9/topic/usb-ci-udc
e548c9d Merge 'v3.9/topic/usb-ci-udc' into usb-3.9
80538f3 usb: chipidea: udc: add multiple td support to hardware_{en,de}queue
02e1c7b usb: chipidea: udc: manage dynamic amount of tds with an linked list
0ebb8f4 usb: chipidea: udc: prepare qhead with dma_alloc_coherent
39be042 usb: chipidea: udc: add the define TD_PAGE_COUNT and fix all users
c2f0562 usb: chipidea: udc: use gfp_flags in _hardware_enqueue
f818222 usb: chipidea: udc: move _ep_queue into an unlocked function
8aea3b0 usb: chipidea: udc: configure iso endpoints
8e61a12 usb: chipidea: udc: rework ep_enable cap setting
e5ceed7 usb: chipidea: udc: move ZLT flag change to ep_enable
2e33742 usb: chipidea: udc: read status of td only once in hardware_dequeue
516803b usb: chipidea: udc: only clear active and halted bits in qhead
ee95a49 usb: chipidea: udc: use {read,write}l to handle mapped data

http://git.pengutronix.de/git/mgr/linux.git v3.9/topic/imx-usbmisc
1174002 Merge 'v3.9/topic/imx-usbmisc' into usb-3.9
f406383 usb: chipidea: usbmisc: skip clocks on i.MX6
d5c8d53 usb: chipidea: usbmisc: use module_platform_driver
105d5d0 usb: chipidea: usbmisc: add support for ahb, ipg and per clock

http://git.pengutronix.de/git/mgr/linux.git v3.9/topic/imx-usb
df11f8b Merge 'v3.9/topic/imx-usb' into usb-3.9
9a967c4 usb: chipidea: udc: add force-full-speed option
a02af86 USB: chipidea: set STS bit in serial mode
af34326 usb: chipidea: ci13xxx_imx: add 2nd and 3rd clock to support imx5x and 
newer
5b7f6d8 usb: chipidea: pci: mark platformdata as static

/*
 * All above branches depent on the lower branches of Alexander and Peter
 * which we currently have rebased on v3.9-rc3 and on top of each other.
 * It is named alex-and-peter-for-3.9.
 */
http://git.pengutronix.de/git/mgr/linux.git alex-and-peter-for-3.9

/*
 * Peters branch already contain the usbmisc series,
 * but they never made it to ci-for-greg, although
 * Alexander already mentioned (24 Jan 2013) to queue them.
 */
https://github.com/hzpeterchen/linux-usb.git master^^
4d36511 Merge 'v3.9/topic/usb-peterchen'
90314f3 usb: chipidea: usbmisc: add post handling and errata fix for mx25
edde2ad usb: chipidea: usbmisc: add mx53 support
6150722 usb: chipidea: usbmisc: prepare driver to handle more than one soc
542384e usb: chipidea: usbmisc: fix a potential race condition
cdffb44 usb: chipidea: usbmisc: unset global varibale usbmisc on driver remove
b8e47e3 usb: chipidea: usbmisc: rename file, struct and functions to usbmisc_imx
c5863f9 usb: chipidea: imx: select usb id pin using syscon interface
8c8a1f5 usb: chipidea: udc: fix the oops when plugs in usb cable after rmmod 
gadget
c703723 usb: chipidea: imx: add getting vbus regulator code
e897d66 usb: chipidea: delete the delayed work
4c0be3e usb: chipidea: add vbus regulator control
f1e52f8 usb: chipidea: udc: retire the flag CI13_PULLUP_ON_VBUS
af4e743 usb: chipidea: udc: add pullup/pulldown dp at hw_device_state
1be0011 usb: chipidea: add otg id switch and vbus connect/disconnect detect
7c3c62d usb: chipidea: add otg file
618bfec Revert "USB: chipidea: add vbus detect for udc"
bfe5248 USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy
705620f USB mxs-phy: Register phy with framework
f5e9796 USB chipidea i.MX: introduce dr_mode property
dc622c4 USB chipidea: introduce dual role mode pdata flags
b1d4a9e USB: chipidea: add PTW and PTS handling
747eee3 USB: chipidea: ci13xxx

[PATCH] USB: EHCI: DT support for generic bus glue

2013-03-25 Thread Arnd Bergmann
This lets us use the ehci-generic driver on platforms without special
requirements for their ehci controllers. In particular, this is true
for the vt8500/wm8x50 platforms, which currently have a separate
driver that causes problems with multiplatform configurations.

Cc: Tony Prisk 
Cc: Alexey Charkov 
Acked-by: Alan Stern 
Signed-off-by: Arnd Bergmann 
---
Tony, Alexey et al: could one of you test if this works for you?

 drivers/usb/host/ehci-hcd.c  |   5 --
 drivers/usb/host/ehci-platform.c |  28 ++--
 drivers/usb/host/ehci-vt8500.c   | 150 -
 3 files changed, 22 insertions(+), 161 deletions(-)

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 0c3314c..960e7cf 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1286,11 +1286,6 @@ MODULE_LICENSE ("GPL");
 #define PLATFORM_DRIVERehci_octeon_driver
 #endif
 
-#ifdef CONFIG_ARCH_VT8500
-#include "ehci-vt8500.c"
-#definePLATFORM_DRIVER vt8500_ehci_driver
-#endif
-
 #ifdef CONFIG_PLAT_SPEAR
 #include "ehci-spear.c"
 #define PLATFORM_DRIVERspear_ehci_hcd_driver
diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
index ca75063..27e9227 100644
--- a/drivers/usb/host/ehci-platform.c
+++ b/drivers/usb/host/ehci-platform.c
@@ -18,11 +18,13 @@
  *
  * Licensed under the GNU/GPL. See COPYING for details.
  */
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -62,22 +64,26 @@ static const struct ehci_driver_overrides 
platform_overrides __initdata = {
.reset =ehci_platform_reset,
 };
 
+static struct usb_ehci_pdata ehci_platform_defaults;
+
 static int ehci_platform_probe(struct platform_device *dev)
 {
struct usb_hcd *hcd;
struct resource *res_mem;
-   struct usb_ehci_pdata *pdata = dev->dev.platform_data;
+   struct usb_ehci_pdata *pdata;
int irq;
int err = -ENOMEM;
 
-   if (!pdata) {
-   WARN_ON(1);
-   return -ENODEV;
-   }
-
if (usb_disabled())
return -ENODEV;
 
+   if (!dev->dev.platform_data) {
+   dev->dev.platform_data = &ehci_platform_defaults;
+   dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
+   dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
+   }
+   pdata = dev->dev.platform_data;
+
irq = platform_get_irq(dev, 0);
if (irq < 0) {
dev_err(&dev->dev, "no irq provided");
@@ -139,6 +145,9 @@ static int ehci_platform_remove(struct platform_device *dev)
if (pdata->power_off)
pdata->power_off(dev);
 
+   if (pdata == &ehci_platform_defaults)
+   dev->dev.platform_data = NULL;
+
return 0;
 }
 
@@ -183,6 +192,12 @@ static int ehci_platform_resume(struct device *dev)
 #define ehci_platform_resume   NULL
 #endif /* CONFIG_PM */
 
+static const struct of_device_id vt8500_ehci_ids[] = {
+   { .compatible = "via,vt8500-ehci", },
+   { .compatible = "wm,prizm-ehci", },
+   {}
+};
+
 static const struct platform_device_id ehci_platform_table[] = {
{ "ehci-platform", 0 },
{ }
@@ -203,6 +218,7 @@ static struct platform_driver ehci_platform_driver = {
.owner  = THIS_MODULE,
.name   = "ehci-platform",
.pm = &ehci_platform_pm_ops,
+   .of_match_table = of_match_ptr(vt8500_ehci_ids),
}
 };
 
diff --git a/drivers/usb/host/ehci-vt8500.c b/drivers/usb/host/ehci-vt8500.c
deleted file mode 100644
index 7ecf709..000
--
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 USB file storage gadget with new UDC

2013-03-25 Thread victor yeo
Hi,

>> I do not know when to set the Halt feature for the bulk-in endpoint. I
>> see gadget code have this line printed out:
>> g_file_storage gadget: bulk-in set halt
>
> The UDC driver is supposed to set the Halt feature when the set_halt()
> routine in the usb_ep_ops table is called with a nonzero second
> argument.  Also when the set_wedge() routine is called -- the
> difference is that with set_wedge(), the driver should ignore
> Clear-Halt requests from the host.
>
> All of this material is documented in include/linus/usb/gadget.h.  Why
> don't you read that file?
>

I thought Halt feature is optional. I will add code to instruct
hardware to set the halt feature. I suppose the driver needs to handle
usb_ep_clear_halt() too. Thanks.

g_file_storage gadget: SCSI command: READ(10);  Dc=10, Di=4096;  Hc=10, Hi=4096
g_file_storage gadget-lun0: file read 4096 @ 0 -> 4096

About the SCSI_READ_10 command, why is it reading 4096 bytes, as the
MBR(master boot record) is only 512 bytes?

>> In the log file, is there any invalid request received on endpoint 0?
>
> In the usbmon file there is.  It is this line:
>
>> f4ae6f40 1217192721 S Co:2:018:0 s 21 ff    0

ok, i will add code to UDC to instruct hardware to send NAK upon
receiving invalid request on endpoint 0. Does it mean that UDC driver
has to check for invalid request on endpoint 0?

Thanks,
victor
--
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: Help with USB issues at boot-up on i.MX25 (linux 3.5.4)

2013-03-25 Thread Alan Stern
On Mon, 25 Mar 2013, David Linares wrote:

> Hi all,
> 
> I am currently working on an open-source project using linux 3.5.4 on
> an i.MX25 board manufactured by Voipac.
> I have been experiencing all sorts of USB issues that I have logged here:
> http://pastebin.com/Ry6fdne5
> As you will see, it varies from detecting a hub with 0 ports, failing
> to initialise it or failing to mount a USB dongle attached to it.
> After trying to get some help on KernelNewbies, I was advised to find
> the consequence of the NULL pointer dereference (bullet point 1 from
> pastebin link), which I did. I posted my first patch earlier "[PATCH]
> USB: hub: Avoid NULL pointer dereference when hub doesn't have any
> ports".
> 
> Now, I would like to get to the root cause/causes of these issues but
> I would need your help. For example, I have no idea if a source not
> delivering enough power could potentially lead to these kinds of
> errors.

Certainly it could.

> Any help or advice on ways to carry on my investigation would be
> gratefully received.

Start with usbmon (see Documentation/usb/usbmon.txt).

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: USB port power-off and system suspend

2013-03-25 Thread Alan Stern
On Sat, 23 Mar 2013, Lan, Tianyu wrote:

> On 2013/3/23 1:35, Alan Stern wrote:> Tianyu:
> > 
> > Did you ever test the port power-off mechanism with system suspend?
> > Right now it doesn't seem like it would work, because it relies on
> > runtime PM to turn off the port power, and runtime PM doesn't operate
> > normally during a system suspend.
> > 
> > Alan Stern
> > 
> 
> Hi Alan:
>   You are right. Current the port power-off can't work during
> system suspend. I have already worked on a patch of adding usb
> port system pm support. But there is a still problem that how to
> control power off mechanism from kernel side. Before, we have a solution
> for runtime pm that increase/decrease port dev's usage count.
>   http://marc.info/?l=linux-usb&m=135772122031446&w=2
> But now, we have another user, System pm. So I think we should find
> a solution to cover these two cases. Maybe add a new pm qos request
> for NO_POWER_OFF flag? I'd like to see your opinion. 

Yes, I think you need to copy the test that's in usb_port_suspend.  
Better yet, move that test to a separate function in port.c and call it 
from both places.

> I have a patch that can work and it still needs to add some condition
> checks in the usb_port_system_suspend(). Dev's system wakeup disable
> and persist enable.

...

> +static int usb_port_system_suspend(struct device *dev)
> +{
> + struct usb_port *port_dev = to_usb_port(dev);
> + int retval;
> +
> + if (port_dev->child)
> + device_pm_wait_for_dev(dev, &port_dev->child->dev);
> +
> + retval = usb_port_runtime_suspend(dev);
> + if (retval < 0 && retval != -EAGAIN)
> + return retval;
> +
> + return 0;

This should always return 0.  Ignore any errors from 
usb_port_runtime_suspend.

> +}
> +
> +static int usb_port_system_resume(struct device *dev)
> +{
> + return usb_port_runtime_resume(dev);
> +}
> +

These new functions should be protected by #ifdef CONFIG_PM_SLEEP.

>  static const struct dev_pm_ops usb_port_pm_ops = {
> + .suspend =  usb_port_system_suspend,
> + .resume =   usb_port_system_resume,

And the same goes for these entries.  The runtime routines now need to 
be protected by CONFIG_PM, since they can be used if either PM_RUNTIME 
or PM_SLEEP is 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: PROBLEM: USB device registered on OHCI instead of EHCI at boot

2013-03-25 Thread Alan Stern
On Mon, 25 Mar 2013, Huang Rui wrote:

> Hi Alan,
> 
> Thank you to take a look at this issue. Sorry to disturb you again.
> The PORT ENABLE(PORT_PE) bit in PORTSC register is not set when the
> port reset, in other words, host controller and device might not do
> alternating sequence of Chirp Ks and Chirp Js or not be detected. Am I
> right?

Yes.

>  I found why the boot issue is not alway reproduced. Because
> sometimes ehci_hcd is not loaded before ohci_hcd.
> 
> [   25.068090] Warning! ehci_hcd should always be loaded before uhci_hcd and 
> ohci_hcd, not after
> 
> If ehci_hcd is loaded firstly, the USB Reader(in my side) is always
> detected as high speed device. Then I do below change and boot issue
> isn't encountered again. 
> 
> diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
> index 180a2b0..30fc91c 100644
> --- a/drivers/usb/host/ohci-hcd.c
> +++ b/drivers/usb/host/ohci-hcd.c
> @@ -1325,7 +1325,7 @@ static int __init ohci_hcd_mod_init(void)
> clear_bit(USB_OHCI_LOADED, &usb_hcds_loaded);
> return retval;
>  }
> -module_init(ohci_hcd_mod_init);
> +late_initcall(ohci_hcd_mod_init);
> 
>  static void __exit ohci_hcd_mod_exit(void)
>  {
> 
> But I think it's not a good solution. Have you any idea to have an
> appropriate way to make ehci_hcd loaded firstly?

In general there is no way to do it.  Especially with modern kernels, 
because what matters is ehci-pci, not ehci-hcd.  And also because the 
order of probing is not always the same.

I suppose you could build a kernel with CONFIG_USB_EHCI_HCD=y and 
CONFIG_USB_EHCI_PCI=y but CONFIG_USB_OHCI_HCD=m.  That might help.

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


Help with USB issues at boot-up on i.MX25 (linux 3.5.4)

2013-03-25 Thread David Linares
Hi all,

I am currently working on an open-source project using linux 3.5.4 on
an i.MX25 board manufactured by Voipac.
I have been experiencing all sorts of USB issues that I have logged here:
http://pastebin.com/Ry6fdne5
As you will see, it varies from detecting a hub with 0 ports, failing
to initialise it or failing to mount a USB dongle attached to it.
After trying to get some help on KernelNewbies, I was advised to find
the consequence of the NULL pointer dereference (bullet point 1 from
pastebin link), which I did. I posted my first patch earlier "[PATCH]
USB: hub: Avoid NULL pointer dereference when hub doesn't have any
ports".

Now, I would like to get to the root cause/causes of these issues but
I would need your help. For example, I have no idea if a source not
delivering enough power could potentially lead to these kinds of
errors.
Any help or advice on ways to carry on my investigation would be
gratefully received.

Cheers,
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: Linux USB file storage gadget with new UDC

2013-03-25 Thread Alan Stern
On Mon, 25 Mar 2013, victor yeo wrote:

> I do not know when to set the Halt feature for the bulk-in endpoint. I
> see gadget code have this line printed out:
> g_file_storage gadget: bulk-in set halt

The UDC driver is supposed to set the Halt feature when the set_halt()  
routine in the usb_ep_ops table is called with a nonzero second
argument.  Also when the set_wedge() routine is called -- the
difference is that with set_wedge(), the driver should ignore
Clear-Halt requests from the host.

All of this material is documented in include/linus/usb/gadget.h.  Why 
don't you read that file?

> In the log file, is there any invalid request received on endpoint 0?

In the usbmon file there is.  It is this line:

> f4ae6f40 1217192721 S Co:2:018:0 s 21 ff    0

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: PROBLEM: since linux kernel 3.8 Apple Cinema Display's usb hub spits errors randomly at boot.

2013-03-25 Thread Alan Stern
On Sun, 24 Mar 2013, Jenya Y wrote:

> Alan, thank you very much for your effort! The updated second patch did 
> resolve all the remaining errors.
>   In case you have any questions or need assistance or anything of this 
> sort, feel free to contact me, I'll be happy to help.
> 
> Remember I mentioned a friend of mine, that I sent your first patch to? 
> Well, she tried it on an amd system with 3.8 and nvidia nforce chipset 
> and though her usb hub error messages disappeared, her system was unable 
> to auto-detect new devices after the patch.
> 
> Meanwhile, I convinced her to go with 3.9 + the special build config we 
> successfully tested and so far all seems to be almost perfect.
> I'm not sure if sending her the second patch will help.
> 
> So this is where we stand... If you wish I can suggest her to contact you.

It's up to her.  If she's happy with the way things are now then she 
doesn't need to do anything more.

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 v4 0/6] support other fsl SoCs with usbmisc + small fixes

2013-03-25 Thread Fabio Estevam
Hi Alexander,

On Thu, Jan 24, 2013 at 7:42 AM, Alexander Shishkin
 wrote:
> Peter Chen  writes:
>
>> On Tue, Nov 27, 2012 at 05:16:55PM +0100, Michael Grzeschik wrote:
>>> Nearly every SoC from Freescale has this non-core usb registers. This series
>>> adds support for more users of this driver.
>>>
>>> This series is based on Peter Chen's work. Its needed to merge his master 
>>> branch
>>> before applying this series:
>>>
>>> https://github.com/hzpeterchen/linux-usb.git
>>
>> I have tested it at i.mx6q sabrelite board, it works good.
>>
>> I have pushed your commit to my git, please cc me
>> your coming chipidea patches, thanks.
>>
>> Alex, please add:
>>
>> Reviewed-by: Peter Chen 
>> Tested-by: Peter Chen 
>
> Looks good, queueing this one for submission.

Could you please let us know what is preventing this series to be applied?

Thanks,

Fabio Estevam
--
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: hub: Avoid NULL pointer dereference when hub doesn't have any ports

2013-03-25 Thread David Linares
Return an error if hub->descriptor->bNbrPorts==0. Without this additional
check, we can end up doing a "hub->ports = kzalloc(0, GFP_KERNEL)".
This hub->ports pointer will therefore be non-NULL and will be used.
Example of dmesg:
   INIT: usb 1-1: New USB device found, idVendor=0424, idProduct=2512
   usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
   hub 1-1:1.0: USB hub found
   version 2.86 bootinghub 1-1:1.0: 0 ports detected
   Unable to handle kernel NULL pointer dereference at virtual address 0010

Signed-off-by: David Linares 
---
 drivers/usb/core/hub.c |4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 5480352..7815462 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1317,6 +1317,10 @@ static int hub_configure(struct usb_hub *hub,
message = "hub has too many ports!";
ret = -ENODEV;
goto fail;
+   } else if (hub->descriptor->bNbrPorts == 0) {
+   message = "hub doesn't have any ports!";
+   ret = -ENODEV;
+   goto fail;
}
 
hdev->maxchild = hub->descriptor->bNbrPorts;
-- 
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: [PATCH 0/6] mfd: omap-usb-host: Device tree support for 3.10

2013-03-25 Thread Roger Quadros
Hi Samuel,

I've rebased this now on top of 3.9-rc4. Please pull this into your
next branch when appropriate. Thanks.

The following changes since commit 8bb9660418e05bb1845ac1a2428444d78e322cc7:

  Linux 3.9-rc4 (2013-03-23 16:52:44 -0700)

are available in the git repository at:
  git://github.com/rogerq/linux.git usbhost-mfd-next

Roger Quadros (5):
  mfd: omap-usb-host: update nports in platform_data
  mfd: omap-usb-host: Remove PHY reset handling code
  mfd: omap-usb-tll: move configuration code to omap_tll_init()
  mfd: omap-usb-tll: Add device tree support and binding information
  mfd: omap-usb-host: Add device tree support and binding information

 .../devicetree/bindings/mfd/omap-usb-host.txt  |   80 
 .../devicetree/bindings/mfd/omap-usb-tll.txt   |   17 ++
 drivers/mfd/omap-usb-host.c|  200 ++-
 drivers/mfd/omap-usb-tll.c |  214 ++--
 drivers/mfd/omap-usb.h |5 +-
 5 files changed, 362 insertions(+), 154 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/omap-usb-host.txt
 create mode 100644 Documentation/devicetree/bindings/mfd/omap-usb-tll.txt

cheers,
-roger

On 03/12/2013 12:25 PM, Roger Quadros wrote:
> Hi Samuel,
> 
> These patches implement device tree support for the OMAP High Speed
> USB Host subsystem. The corresponding EHCI & SoC patches will be sent
> separately and this set has no build dependencies with them.
> 
> Patch 3 is acutally a bug fix which should go into 3.9-rc. I've sent
> it separately to you before.
> 
> The following changes since commit f6161aa153581da4a3867a2d1a7caf4be19b6ec9:
> 
>   Linux 3.9-rc2 (2013-03-10 16:54:19 -0700)
> 
> are available in the git repository at:
>   git://github.com/rogerq/linux.git usbhost-mfd-next
> 
> Roger Quadros (6):
>   mfd: omap-usb-host: update nports in platform_data
>   mfd: omap-usb-host: Remove PHY reset handling code
>   mfd: omap-usb-host: Actually update hostconfig
>   mfd: omap-usb-tll: move configuration code to omap_tll_init()
>   mfd: omap-usb-tll: Add device tree support and binding information
>   mfd: omap-usb-host: Add device tree support and binding information
> 
>  .../devicetree/bindings/mfd/omap-usb-host.txt  |   80 
>  .../devicetree/bindings/mfd/omap-usb-tll.txt   |   17 ++
>  drivers/mfd/omap-usb-host.c|  206 ++-
>  drivers/mfd/omap-usb-tll.c |  214 
> ++--
>  drivers/mfd/omap-usb.h |5 +-
>  5 files changed, 365 insertions(+), 157 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/mfd/omap-usb-host.txt
>  create mode 100644 Documentation/devicetree/bindings/mfd/omap-usb-tll.txt
> 
> --
> cheers,
> -roger
> 

--
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: phy: samsung: fix sparse warning

2013-03-25 Thread Felipe Balbi
Hi,

On Mon, Mar 25, 2013 at 06:41:25PM +0900, Kukjin Kim wrote:
> Felipe Balbi wrote:
> > 
> > Fix the following sparse warning:
> > 
> > drivers/usb/phy/phy-samsung-usb2.c:50:26: sparse: incorrect type in
> > argument 1 (different address spaces)
> > drivers/usb/phy/phy-samsung-usb2.c:50:26:expected void const volatile
> > [noderef] *addr
> > drivers/usb/phy/phy-samsung-usb2.c:50:26:got void *
> > 
> > Cc: Vivek Gautam 
> > Cc: Kukjin Kim 
> 
> Looks good to me, if you want:
> 
> Acked-by: Kukjin Kim 

hmm, a little too late, it already hit my next branch :-(

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v2] usb: dwc3: add CONFIG_PM_SLEEP to suspend/resume functions

2013-03-25 Thread Felipe Balbi
On Mon, Mar 25, 2013 at 08:53:39AM +, Jingoo Han wrote:
> Add CONFIG_PM_SLEEP to suspend/resume functions to fix the following
> build warning when CONFIG_PM_SLEEP is not selected. This is because
> sleep PM callbacks defined by SET_SYSTEM_SLEEP_PM_OPS are only used
> when the CONFIG_PM_SLEEP is enabled. Unnecessary CONFIG_PM ifdefs
> are removed.
> 
> Switch to using SIMPLE_DEV_PM_OPS  macro to declare the driver's
> pm_ops. It reduces code size.
> 
> drivers/usb/dwc3/core.c:682:12: warning: 'dwc3_suspend' defined but not used 
> [-Wunused-function]
> drivers/usb/dwc3/core.c:709:12: warning: 'dwc3_resume' defined but not used 
> [-Wunused-function]
> drivers/usb/dwc3/dwc3-omap.c:430:12: warning: 'dwc3_omap_suspend' defined but 
> not used [-Wunused-function]
> drivers/usb/dwc3/dwc3-omap.c:440:12: warning: 'dwc3_omap_resume' defined but 
> not used [-Wunused-function]
> drivers/usb/dwc3/dwc3-exynos.c:185:12: warning: 'dwc3_exynos_suspend' defined 
> but not used [-Wunused-function]
> drivers/usb/dwc3/dwc3-exynos.c:194:12: warning: 'dwc3_exynos_resume' defined 
> but not used [-Wunused-function]
> 
> Signed-off-by: Jingoo Han 
> ---
> Changes since v1:
> - Removed unnecessary CONFIG_PM ifdefs
> - Used SIMPLE_DEV_PM_OPS macro

please don't. I explicitly used  SET_SYSTEM_SLEEP_PM_OPS() because we
will add runtime PM support later.

> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index e2325ad..e0847a7 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -634,7 +634,6 @@ static int dwc3_remove(struct platform_device *pdev)
>   return 0;
>  }
>  
> -#ifdef CONFIG_PM
>  static int dwc3_prepare(struct device *dev)

I'm not sure. Should we really provide prepare/complete even when
CONFIG_PM_SLEEP isn't enabled ?

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v3] USB: PHY: Palmas USB Transceiver Driver

2013-03-25 Thread Laxman Dewangan

On Monday 25 March 2013 03:02 PM, Kishon Vijay Abraham I wrote:

From: Graeme Gregory 

This is the driver for the OTG transceiver built into the Palmas chip. It
handles the various USB OTG events that can be generated by cable
insertion/removal.

Signed-off-by: Graeme Gregory 
Signed-off-by: Moiz Sonasath 
Signed-off-by: Ruchika Kharwar 
Signed-off-by: Kishon Vijay Abraham I 
Signed-off-by: Sebastien Guiriec 
---


I think this driver is more over the cable connection like vbus 
detetcion or ID pin detection.

Then why not it is implemented based on extcon framework?

That way, generic usb driver (like tegra_usb driver) will get 
notification through extcon.


We need this cable detection through extcon on our tegra solution 
through the Palmas.



+#include 
+#include 
+
+static int palmas_usb_read(struct palmas *palmas, unsigned int reg,
+   unsigned int *dest)
+{
+   unsigned int addr;
+   int slave;
+
+   slave = PALMAS_BASE_TO_SLAVE(PALMAS_USB_OTG_BASE);
+   addr = PALMAS_BASE_TO_REG(PALMAS_USB_OTG_BASE, reg);
+
+   return regmap_read(palmas->regmap[slave], addr, dest);


Please use the generic api for palmas_read()/palmas_write(0 as it will 
be ease on debugging on register access.

Direct regmap_read() does not help much on this.


+}
+
+static int palmas_usb_write(struct palmas *palmas, unsigned int reg,
+   unsigned int data)
+{
+   unsigned int addr;
+   int slave;
+
+   slave = PALMAS_BASE_TO_SLAVE(PALMAS_USB_OTG_BASE);
+   addr = PALMAS_BASE_TO_REG(PALMAS_USB_OTG_BASE, reg);
+
+   return regmap_write(palmas->regmap[slave], addr, data);


Same as above.




+
+   if (status != OMAP_DWC3_UNKNOWN) {
+   palmas_usb->linkstat = status;
+   palmas_usb->mailboxstat = dwc3_omap_mailbox(status);

Omap specific call, why? This is generic palma driver.



+



+   palmas_usb->dev = &pdev->dev;
+
+   palmas_usb->irq1 = regmap_irq_get_virq(palmas->irq_data,
+   PALMAS_ID_OTG_IRQ);
+   palmas_usb->irq2 = regmap_irq_get_virq(palmas->irq_data,
+   PALMAS_ID_IRQ);
+   palmas_usb->irq3 = regmap_irq_get_virq(palmas->irq_data,
+   PALMAS_VBUS_OTG_IRQ);
+   palmas_usb->irq4 = regmap_irq_get_virq(palmas->irq_data,
+   PALMAS_VBUS_IRQ);


Should be come from platform_get_irq() through platform driver.



--
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: phy: samsung: fix sparse warning

2013-03-25 Thread Kukjin Kim
Felipe Balbi wrote:
> 
> Fix the following sparse warning:
> 
> drivers/usb/phy/phy-samsung-usb2.c:50:26: sparse: incorrect type in
> argument 1 (different address spaces)
> drivers/usb/phy/phy-samsung-usb2.c:50:26:expected void const volatile
> [noderef] *addr
> drivers/usb/phy/phy-samsung-usb2.c:50:26:got void *
> 
> Cc: Vivek Gautam 
> Cc: Kukjin Kim 

Looks good to me, if you want:

Acked-by: Kukjin Kim 

Thanks.

- Kukjin

> Signed-off-by: Felipe Balbi 
> ---
>  drivers/usb/phy/phy-samsung-usb2.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/phy/phy-samsung-usb2.c b/drivers/usb/phy/phy-
> samsung-usb2.c
> index dce9681..45ffe03 100644
> --- a/drivers/usb/phy/phy-samsung-usb2.c
> +++ b/drivers/usb/phy/phy-samsung-usb2.c
> @@ -43,7 +43,7 @@ static int samsung_usbphy_set_host(struct usb_otg *otg,
> struct usb_bus *host)
>   return 0;
>  }
> 
> -static bool exynos5_phyhost_is_on(void *regs)
> +static bool exynos5_phyhost_is_on(void __iomem *regs)
>  {
>   u32 reg;
> 
> --
> 1.8.2

--
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 v3] USB: PHY: Palmas USB Transceiver Driver

2013-03-25 Thread Kishon Vijay Abraham I
From: Graeme Gregory 

This is the driver for the OTG transceiver built into the Palmas chip. It
handles the various USB OTG events that can be generated by cable
insertion/removal.

Signed-off-by: Graeme Gregory 
Signed-off-by: Moiz Sonasath 
Signed-off-by: Ruchika Kharwar 
Signed-off-by: Kishon Vijay Abraham I 
Signed-off-by: Sebastien Guiriec 
---
Changes from v2:
* Moved the driver to drivers/usb/phy/
* Added a bit more explanation in Kconfig

 .../devicetree/bindings/usb/twl-usb.txt|   15 +
 drivers/usb/phy/Kconfig|9 +
 drivers/usb/phy/Makefile   |1 +
 drivers/usb/phy/phy-palmas-usb.c   |  396 
 include/linux/mfd/palmas.h |7 +-
 5 files changed, 427 insertions(+), 1 deletion(-)
 create mode 100644 drivers/usb/phy/phy-palmas-usb.c

diff --git a/Documentation/devicetree/bindings/usb/twl-usb.txt 
b/Documentation/devicetree/bindings/usb/twl-usb.txt
index 36b9aed..17a9194 100644
--- a/Documentation/devicetree/bindings/usb/twl-usb.txt
+++ b/Documentation/devicetree/bindings/usb/twl-usb.txt
@@ -38,3 +38,18 @@ twl4030-usb {
usb3v1-supply = <&vusb3v1>;
usb_mode = <1>;
 };
+
+PALMAS USB COMPARATOR
+Required Properties:
+ - compatible : Should be "ti,palmas-usb" or "ti,twl6035-usb"
+ - vbus-supply : phandle to the regulator device tree node.
+
+Optional Properties:
+ - ti,wakeup : To enable the wakeup comparator in probe
+ - ti,no_control_vbus: if the platform wishes its own vbus control
+
+palmas-usb {
+   compatible = "ti,twl6035-usb", "ti,palmas-usb";
+   vbus-supply = <&smps10_reg>;
+   ti,wakeup;
+};
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 7e8fe0f..4107136 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -85,6 +85,15 @@ config OMAP_USB3
  This driver interacts with the "OMAP Control USB Driver" to power
  on/off the PHY.
 
+config PALMAS_USB
+   tristate "Palmas USB Transceiver Driver"
+   depends on MFD_PALMAS
+   help
+ Enable this to support the Palmas USB transceiver driver. This
+ palmas transceiver has the VBUS and ID GND and OTG SRP events
+ capabilities. For all other transceiver functionality
+ UTMI PHY is embedded in OMAP.
+
 config SAMSUNG_USBPHY
tristate "Samsung USB PHY Driver"
help
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index 33863c0..0e01790 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -17,6 +17,7 @@ obj-$(CONFIG_NOP_USB_XCEIV)   += phy-nop.o
 obj-$(CONFIG_OMAP_CONTROL_USB) += phy-omap-control.o
 obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o
 obj-$(CONFIG_OMAP_USB3)+= phy-omap-usb3.o
+obj-$(CONFIG_PALMAS_USB)   += phy-palmas-usb.o
 obj-$(CONFIG_SAMSUNG_USBPHY)   += phy-samsung-usb.o
 obj-$(CONFIG_SAMSUNG_USB2PHY)  += phy-samsung-usb2.o
 obj-$(CONFIG_SAMSUNG_USB3PHY)  += phy-samsung-usb3.o
diff --git a/drivers/usb/phy/phy-palmas-usb.c b/drivers/usb/phy/phy-palmas-usb.c
new file mode 100644
index 000..8bdffe3
--- /dev/null
+++ b/drivers/usb/phy/phy-palmas-usb.c
@@ -0,0 +1,396 @@
+/*
+ * Palmas USB transceiver driver
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Author: Graeme Gregory 
+ * Author: Kishon Vijay Abraham I 
+ *
+ * Based on twl6030_usb.c
+ *
+ * Author: Hema HK 
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int palmas_usb_read(struct palmas *palmas, unsigned int reg,
+   unsigned int *dest)
+{
+   unsigned int addr;
+   int slave;
+
+   slave = PALMAS_BASE_TO_SLAVE(PALMAS_USB_OTG_BASE);
+   addr = PALMAS_BASE_TO_REG(PALMAS_USB_OTG_BASE, reg);
+
+   return regmap_read(palmas->regmap[slave], addr, dest);
+}
+
+static int palmas_usb_write(struct palmas *palmas, unsigned int reg,
+   unsigned int data)
+{
+   unsigned int addr;
+   int slave;
+
+   slave = PALMAS_BASE_TO_SLAVE(PALMAS_USB_OTG_BASE);
+   addr = PALMAS_BASE_TO_REG(PALMAS_USB_OTG_BASE, reg);
+
+   return regmap_write(palmas->regmap[slave], addr, data);
+}
+
+static void palmas_usb_wakeup(struct palmas *palmas, int e

RE: [PATCH v2] usb: ehci-s5p: Use devm for requesting ehci_vbus_gpio

2013-03-25 Thread Kukjin Kim
Doug Anderson wrote:
> 
> The ehci_vbus_gpio is requested but never freed.  This can cause
> problems with deferred probes and would cause problems if
> s5p_ehci_remove was ever called.  Use devm to fix this.
> 
> Signed-off-by: Doug Anderson 

Acked-by: Kukjin Kim 

Thanks.

- Kukjin

> ---
> Changes in v2:
> - &pdev->dev => dev elsewhere in s5p_setup_vbus_gpio()
> 
>  drivers/usb/host/ehci-s5p.c | 11 ++-
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-s5p.c
> index 20ebf6a..738490e 100644
> --- a/drivers/usb/host/ehci-s5p.c
> +++ b/drivers/usb/host/ehci-s5p.c
> @@ -92,20 +92,21 @@ static void s5p_ehci_phy_disable(struct s5p_ehci_hcd
> *s5p_ehci)
> 
>  static void s5p_setup_vbus_gpio(struct platform_device *pdev)
>  {
> + struct device *dev = &pdev->dev;
>   int err;
>   int gpio;
> 
> - if (!pdev->dev.of_node)
> + if (!dev->of_node)
>   return;
> 
> - gpio = of_get_named_gpio(pdev->dev.of_node,
> - "samsung,vbus-gpio", 0);
> + gpio = of_get_named_gpio(dev->of_node, "samsung,vbus-gpio", 0);
>   if (!gpio_is_valid(gpio))
>   return;
> 
> - err = gpio_request_one(gpio, GPIOF_OUT_INIT_HIGH, "ehci_vbus_gpio");
> + err = devm_gpio_request_one(dev, gpio, GPIOF_OUT_INIT_HIGH,
> + "ehci_vbus_gpio");
>   if (err)
> - dev_err(&pdev->dev, "can't request ehci vbus gpio %d",
gpio);
> + dev_err(dev, "can't request ehci vbus gpio %d", gpio);
>  }
> 
>  static u64 ehci_s5p_dma_mask = DMA_BIT_MASK(32);
> --
> 1.8.1.3

--
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 v2] usb: dwc3: add CONFIG_PM_SLEEP to suspend/resume functions

2013-03-25 Thread Jingoo Han
Add CONFIG_PM_SLEEP to suspend/resume functions to fix the following
build warning when CONFIG_PM_SLEEP is not selected. This is because
sleep PM callbacks defined by SET_SYSTEM_SLEEP_PM_OPS are only used
when the CONFIG_PM_SLEEP is enabled. Unnecessary CONFIG_PM ifdefs
are removed.

Switch to using SIMPLE_DEV_PM_OPS  macro to declare the driver's
pm_ops. It reduces code size.

drivers/usb/dwc3/core.c:682:12: warning: 'dwc3_suspend' defined but not used 
[-Wunused-function]
drivers/usb/dwc3/core.c:709:12: warning: 'dwc3_resume' defined but not used 
[-Wunused-function]
drivers/usb/dwc3/dwc3-omap.c:430:12: warning: 'dwc3_omap_suspend' defined but 
not used [-Wunused-function]
drivers/usb/dwc3/dwc3-omap.c:440:12: warning: 'dwc3_omap_resume' defined but 
not used [-Wunused-function]
drivers/usb/dwc3/dwc3-exynos.c:185:12: warning: 'dwc3_exynos_suspend' defined 
but not used [-Wunused-function]
drivers/usb/dwc3/dwc3-exynos.c:194:12: warning: 'dwc3_exynos_resume' defined 
but not used [-Wunused-function]

Signed-off-by: Jingoo Han 
---
Changes since v1:
- Removed unnecessary CONFIG_PM ifdefs
- Used SIMPLE_DEV_PM_OPS macro

 drivers/usb/dwc3/core.c|   10 +++---
 drivers/usb/dwc3/dwc3-exynos.c |   15 +--
 drivers/usb/dwc3/dwc3-omap.c   |   10 +++---
 3 files changed, 11 insertions(+), 24 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index e2325ad..e0847a7 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -634,7 +634,6 @@ static int dwc3_remove(struct platform_device *pdev)
return 0;
 }
 
-#ifdef CONFIG_PM
 static int dwc3_prepare(struct device *dev)
 {
struct dwc3 *dwc = dev_get_drvdata(dev);
@@ -679,6 +678,7 @@ static void dwc3_complete(struct device *dev)
spin_unlock_irqrestore(&dwc->lock, flags);
 }
 
+#ifdef CONFIG_PM_SLEEP
 static int dwc3_suspend(struct device *dev)
 {
struct dwc3 *dwc = dev_get_drvdata(dev);
@@ -738,6 +738,7 @@ static int dwc3_resume(struct device *dev)
 
return 0;
 }
+#endif
 
 static const struct dev_pm_ops dwc3_dev_pm_ops = {
.prepare= dwc3_prepare,
@@ -746,11 +747,6 @@ static const struct dev_pm_ops dwc3_dev_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(dwc3_suspend, dwc3_resume)
 };
 
-#define DWC3_PM_OPS&(dwc3_dev_pm_ops)
-#else
-#define DWC3_PM_OPSNULL
-#endif
-
 #ifdef CONFIG_OF
 static const struct of_device_id of_dwc3_match[] = {
{
@@ -767,7 +763,7 @@ static struct platform_driver dwc3_driver = {
.driver = {
.name   = "dwc3",
.of_match_table = of_match_ptr(of_dwc3_match),
-   .pm = DWC3_PM_OPS,
+   .pm = &dwc3_dev_pm_ops,
},
 };
 
diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c
index 1ea7bd8..2b91627 100644
--- a/drivers/usb/dwc3/dwc3-exynos.c
+++ b/drivers/usb/dwc3/dwc3-exynos.c
@@ -181,7 +181,7 @@ static const struct of_device_id exynos_dwc3_match[] = {
 MODULE_DEVICE_TABLE(of, exynos_dwc3_match);
 #endif
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int dwc3_exynos_suspend(struct device *dev)
 {
struct dwc3_exynos *exynos = dev_get_drvdata(dev);
@@ -204,15 +204,10 @@ static int dwc3_exynos_resume(struct device *dev)
 
return 0;
 }
+#endif
 
-static const struct dev_pm_ops dwc3_exynos_dev_pm_ops = {
-   SET_SYSTEM_SLEEP_PM_OPS(dwc3_exynos_suspend, dwc3_exynos_resume)
-};
-
-#define DEV_PM_OPS (&dwc3_exynos_dev_pm_ops)
-#else
-#define DEV_PM_OPS NULL
-#endif /* CONFIG_PM */
+static SIMPLE_DEV_PM_OPS(dwc3_exynos_dev_pm_ops, dwc3_exynos_suspend,
+   dwc3_exynos_resume);
 
 static struct platform_driver dwc3_exynos_driver = {
.probe  = dwc3_exynos_probe,
@@ -220,7 +215,7 @@ static struct platform_driver dwc3_exynos_driver = {
.driver = {
.name   = "exynos-dwc3",
.of_match_table = of_match_ptr(exynos_dwc3_match),
-   .pm = DEV_PM_OPS,
+   .pm = &dwc3_exynos_dev_pm_ops,
},
 };
 
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index 6de734f..8726be5 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -410,7 +410,6 @@ static const struct of_device_id of_dwc3_match[] = {
 };
 MODULE_DEVICE_TABLE(of, of_dwc3_match);
 
-#ifdef CONFIG_PM
 static int dwc3_omap_prepare(struct device *dev)
 {
struct dwc3_omap*omap = dev_get_drvdata(dev);
@@ -427,6 +426,7 @@ static void dwc3_omap_complete(struct device *dev)
dwc3_omap_enable_irqs(omap);
 }
 
+#ifdef CONFIG_PM_SLEEP
 static int dwc3_omap_suspend(struct device *dev)
 {
struct dwc3_omap*omap = dev_get_drvdata(dev);
@@ -450,6 +450,7 @@ static int dwc3_omap_resume(struct device *dev)
 
return 0;
 }
+#endif
 
 static const struct dev_pm_ops dwc3_omap_dev_pm_ops = {
.prepare= dwc3_omap_prepare,
@@ -458,18 +459,13 

[PATCH v2 7/8] usb/gadget: nokia: convert to new interface of f_phonet

2013-03-25 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/Kconfig |1 +
 drivers/usb/gadget/nokia.c |   51 +--
 2 files changed, 35 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index a4cb286..2fdc78b 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -939,6 +939,7 @@ config USB_G_NOKIA
select USB_F_ACM
select USB_F_ECM
select USB_F_OBEX
+   select USB_F_PHONET
help
  The Nokia composite gadget provides support for acm, obex
  and phonet in only one composite gadget driver.
diff --git a/drivers/usb/gadget/nokia.c b/drivers/usb/gadget/nokia.c
index be8d747..f20e55f 100644
--- a/drivers/usb/gadget/nokia.c
+++ b/drivers/usb/gadget/nokia.c
@@ -30,19 +30,6 @@
 #define NOKIA_VERSION_NUM  0x0211
 #define NOKIA_LONG_NAME"N900 (PC-Suite Mode)"
 
-/*-*/
-
-/*
- * 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.
- */
-#define USBF_PHONET_INCLUDED
-#include "f_phonet.c"
-
-/*-*/
 USB_GADGET_COMPOSITE_OPTIONS();
 
 #define NOKIA_VENDOR_ID0x0421  /* Nokia */
@@ -103,6 +90,8 @@ static struct usb_function *f_obex1_cfg1;
 static struct usb_function *f_obex2_cfg1;
 static struct usb_function *f_obex1_cfg2;
 static struct usb_function *f_obex2_cfg2;
+static struct usb_function *f_phonet_cfg1;
+static struct usb_function *f_phonet_cfg2;
 static u8 hostaddr[ETH_ALEN];
 static struct eth_dev *the_dev;
 static struct net_device *phonet_dev;
@@ -128,21 +117,30 @@ static struct usb_function_instance *fi_acm;
 static struct usb_function_instance *fi_ecm;
 static struct usb_function_instance *fi_obex1;
 static struct usb_function_instance *fi_obex2;
+static struct usb_function_instance *fi_phonet;
 
 static int __init nokia_bind_config(struct usb_configuration *c)
 {
struct usb_function *f_acm;
struct usb_function *f_ecm;
+   struct usb_function *f_phonet = NULL;
struct usb_function *f_obex1 = NULL;
struct usb_function *f_obex2 = NULL;
+   struct f_phonet_opts *phonet_opts;
struct f_ecm_opts *ecm_opts;
int status = 0;
int obex1_stat = 0;
int obex2_stat = 0;
-
-   status = phonet_bind_config(c, phonet_dev);
-   if (status)
-   printk(KERN_DEBUG "could not bind phonet config\n");
+   int phonet_stat = 0;
+
+   if (!IS_ERR(fi_phonet)) {
+   phonet_opts = container_of(fi_phonet, struct f_phonet_opts,
+  func_inst);
+   phonet_opts->dev = phonet_dev;
+   f_phonet = usb_get_function(fi_phonet);
+   if (IS_ERR(f_phonet))
+   printk(KERN_DEBUG "could not get phonet function\n");
+   }
 
if (!IS_ERR(fi_obex1)) {
f_obex1 = usb_get_function(fi_obex1);
@@ -172,6 +170,12 @@ static int __init nokia_bind_config(struct 
usb_configuration *c)
goto err_get_ecm;
}
 
+   if (!IS_ERR_OR_NULL(f_phonet)) {
+   phonet_stat = usb_add_function(c, f_phonet);
+   if (phonet_stat)
+   printk(KERN_DEBUG "could not add phonet function\n");
+   }
+
if (!IS_ERR_OR_NULL(f_obex1)) {
obex1_stat = usb_add_function(c, f_obex1);
if (obex1_stat)
@@ -197,11 +201,13 @@ static int __init nokia_bind_config(struct 
usb_configuration *c)
if (c == &nokia_config_500ma_driver) {
f_acm_cfg1 = f_acm;
f_ecm_cfg1 = f_ecm;
+   f_phonet_cfg1 = f_phonet;
f_obex1_cfg1 = f_obex1;
f_obex2_cfg1 = f_obex2;
} else {
f_acm_cfg2 = f_acm;
f_ecm_cfg2 = f_ecm;
+   f_phonet_cfg2 = f_phonet;
f_obex1_cfg2 = f_obex1;
f_obex2_cfg2 = f_obex2;
}
@@ -214,6 +220,8 @@ err_conf:
usb_remove_function(c, f_obex2);
if (!obex1_stat)
usb_remove_function(c, f_obex1);
+   if (!phonet_stat)
+   usb_remove_function(c, f_phonet);
usb_put_function(f_ecm);
 err_get_ecm:
usb_put_function(f_acm);
@@ -222,6 +230,8 @@ err_get_acm:
usb_put_function(f_obex2);
if (!IS_ERR_OR_NULL(f_obex1))
usb_put_function(f_obex1);
+   if (!IS_ERR_OR_NULL(f_phonet))
+   usb_put_function(f_phonet);
   

[PATCH v2 3/8] usb/gadget: nokia: convert to new interface of f_obex

2013-03-25 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/Kconfig |1 +
 drivers/usb/gadget/nokia.c |  114 ++--
 2 files changed, 79 insertions(+), 36 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index aaf1e62..266d529 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -935,6 +935,7 @@ config USB_G_NOKIA
select USB_U_ETHER
select USB_F_ACM
select USB_F_ECM
+   select USB_F_OBEX
help
  The Nokia composite gadget provides support for acm, obex
  and phonet in only one composite gadget driver.
diff --git a/drivers/usb/gadget/nokia.c b/drivers/usb/gadget/nokia.c
index 27da576..bb10019 100644
--- a/drivers/usb/gadget/nokia.c
+++ b/drivers/usb/gadget/nokia.c
@@ -16,6 +16,7 @@
  */
 
 #include 
+#include 
 #include 
 
 #include "u_serial.h"
@@ -38,8 +39,6 @@
  * the runtime footprint, and giving us at least some parts of what
  * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
  */
-#define USBF_OBEX_INCLUDED
-#include "f_obex.c"
 #include "f_phonet.c"
 
 /*-*/
@@ -99,17 +98,13 @@ static struct usb_function *f_acm_cfg1;
 static struct usb_function *f_acm_cfg2;
 static struct usb_function *f_ecm_cfg1;
 static struct usb_function *f_ecm_cfg2;
+static struct usb_function *f_obex1_cfg1;
+static struct usb_function *f_obex2_cfg1;
+static struct usb_function *f_obex1_cfg2;
+static struct usb_function *f_obex2_cfg2;
 static u8 hostaddr[ETH_ALEN];
 static struct eth_dev *the_dev;
 
-enum {
-   TTY_PORT_OBEX0,
-   TTY_PORT_OBEX1,
-   TTY_PORTS_MAX,
-};
-
-static unsigned char tty_lines[TTY_PORTS_MAX];
-
 static struct usb_configuration nokia_config_500ma_driver = {
.label  = "Bus Powered",
.bConfigurationValue = 1,
@@ -128,29 +123,41 @@ static struct usb_configuration nokia_config_100ma_driver 
= {
 
 static struct usb_function_instance *fi_acm;
 static struct usb_function_instance *fi_ecm;
+static struct usb_function_instance *fi_obex1;
+static struct usb_function_instance *fi_obex2;
 
 static int __init nokia_bind_config(struct usb_configuration *c)
 {
struct usb_function *f_acm;
struct usb_function *f_ecm;
+   struct usb_function *f_obex1 = NULL;
+   struct usb_function *f_obex2 = NULL;
struct f_ecm_opts *ecm_opts;
int status = 0;
+   int obex1_stat = 0;
+   int obex2_stat = 0;
 
status = phonet_bind_config(c);
if (status)
printk(KERN_DEBUG "could not bind phonet config\n");
 
-   status = obex_bind_config(c, tty_lines[TTY_PORT_OBEX0]);
-   if (status)
-   printk(KERN_DEBUG "could not bind obex config %d\n", 0);
+   if (!IS_ERR(fi_obex1)) {
+   f_obex1 = usb_get_function(fi_obex1);
+   if (IS_ERR(f_obex1))
+   printk(KERN_DEBUG "could not get obex function 0\n");
+   }
 
-   status = obex_bind_config(c, tty_lines[TTY_PORT_OBEX1]);
-   if (status)
-   printk(KERN_DEBUG "could not bind obex config %d\n", 0);
+   if (!IS_ERR(fi_obex2)) {
+   f_obex2 = usb_get_function(fi_obex2);
+   if (IS_ERR(f_obex2))
+   printk(KERN_DEBUG "could not get obex function 1\n");
+   }
 
f_acm = usb_get_function(fi_acm);
-   if (IS_ERR(f_acm))
-   return PTR_ERR(f_acm);
+   if (IS_ERR(f_acm)) {
+   status = PTR_ERR(fi_acm);
+   goto err_get_acm;
+   }
 
ecm_opts = container_of(fi_ecm, struct f_ecm_opts, func_inst);
ecm_opts->ethaddr = hostaddr;
@@ -162,30 +169,56 @@ static int __init nokia_bind_config(struct 
usb_configuration *c)
goto err_get_ecm;
}
 
+   if (!IS_ERR_OR_NULL(f_obex1)) {
+   obex1_stat = usb_add_function(c, f_obex1);
+   if (obex1_stat)
+   printk(KERN_DEBUG "could not add obex function 0\n");
+   }
+
+   if (!IS_ERR_OR_NULL(f_obex2)) {
+   obex2_stat = usb_add_function(c, f_obex2);
+   if (obex2_stat)
+   printk(KERN_DEBUG "could not add obex function 1\n");
+   }
+
status = usb_add_function(c, f_acm);
if (status)
goto err_conf;
 
status = usb_add_function(c, f_ecm);
if (status) {
-   pr_debug("could not bind ecm config %d\n", status);
+   pr_debug("could not add ecm function %d\n", status);
goto err_ecm;
}
+
if (c == &nokia_config_500ma_driver) {
f_acm_cfg1 = f_acm;
f_ecm_cfg1 = f_ecm;
+   f_obex1_cfg1 = f_obex1;
+   f_obex2_cfg1 = f_obex2;
} else {
f_acm_cfg2 = f_acm;
f_ecm_cfg2 = f_ecm;
+   

[PATCH v2 8/8] usb/gadget: f_phonet: remove compatibility layer

2013-03-25 Thread Andrzej Pietrasiewicz
There are no old function interface users left, so the old interface
can be removed.

Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/f_phonet.c |   63 ++--
 1 files changed, 4 insertions(+), 59 deletions(-)

diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c
index 02b2270..b921d65 100644
--- a/drivers/usb/gadget/f_phonet.c
+++ b/drivers/usb/gadget/f_phonet.c
@@ -560,55 +560,6 @@ err:
return status;
 }
 
-#ifdef USBF_PHONET_INCLUDED
-
-static void
-pn_old_unbind(struct usb_configuration *c, struct usb_function *f)
-{
-   struct f_phonet *fp = func_to_pn(f);
-   int i;
-
-   /* We are already disconnected */
-   if (fp->in_req)
-   usb_ep_free_request(fp->in_ep, fp->in_req);
-   for (i = 0; i < phonet_rxq_size; i++)
-   if (fp->out_reqv[i])
-   usb_ep_free_request(fp->out_ep, fp->out_reqv[i]);
-
-   usb_free_all_descriptors(f);
-   kfree(fp);
-}
-
-/*-*/
-
-int __init phonet_bind_config(struct usb_configuration *c,
- struct net_device *dev)
-{
-   struct f_phonet *fp;
-   int err, size;
-
-   size = sizeof(*fp) + (phonet_rxq_size * sizeof(struct usb_request *));
-   fp = kzalloc(size, GFP_KERNEL);
-   if (!fp)
-   return -ENOMEM;
-
-   fp->dev = dev;
-   fp->function.name = "phonet";
-   fp->function.bind = pn_bind;
-   fp->function.unbind = pn_old_unbind;
-   fp->function.set_alt = pn_set_alt;
-   fp->function.get_alt = pn_get_alt;
-   fp->function.disable = pn_disconnect;
-   spin_lock_init(&fp->rx.lock);
-
-   err = usb_add_function(c, &fp->function);
-   if (err)
-   kfree(fp);
-   return err;
-}
-
-#else
-
 static void phonet_free_inst(struct usb_function_instance *f)
 {
struct f_phonet_opts *opts;
@@ -679,12 +630,6 @@ struct usb_function *phonet_alloc(struct 
usb_function_instance *fi)
return &fp->function;
 }
 
-DECLARE_USB_FUNCTION_INIT(phonet, phonet_alloc_inst, phonet_alloc);
-MODULE_AUTHOR("Rémi Denis-Courmont");
-MODULE_LICENSE("GPL");
-
-#endif
-
 struct net_device *gphonet_setup(struct usb_gadget *gadget)
 {
struct net_device *dev;
@@ -709,14 +654,14 @@ struct net_device *gphonet_setup(struct usb_gadget 
*gadget)
}
return dev;
 }
-#ifndef USBF_PHONET_INCLUDED
 EXPORT_SYMBOL(gphonet_setup);
-#endif
 
 void gphonet_cleanup(struct net_device *dev)
 {
unregister_netdev(dev);
 }
-#ifndef USBF_PHONET_INCLUDED
 EXPORT_SYMBOL(gphonet_cleanup);
-#endif
+
+DECLARE_USB_FUNCTION_INIT(phonet, phonet_alloc_inst, phonet_alloc);
+MODULE_AUTHOR("Rémi Denis-Courmont");
+MODULE_LICENSE("GPL");
-- 
1.7.0.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 v2 6/8] usb/gadget: f_phonet: convert to new function interface with backward compatibility

2013-03-25 Thread Andrzej Pietrasiewicz
Converting f_phonet to the new function interface requires converting
the f_phonet's function code and its users.
This patch converts the f_phonet.c to the new function interface.
The file is now compiled into a separate usb_f_phonet.ko module.
The old function interface is provided by means of preprocessor
conditional directives. After all users are converted, the old interface
can be removed.

Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/Kconfig|3 +
 drivers/usb/gadget/Makefile   |2 +
 drivers/usb/gadget/f_phonet.c |   96 ++--
 drivers/usb/gadget/nokia.c|1 +
 drivers/usb/gadget/u_phonet.h |5 ++
 5 files changed, 102 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 266d529..a4cb286 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -587,6 +587,9 @@ config USB_F_SERIAL
 config USB_F_OBEX
tristate
 
+config USB_F_PHONET
+   tristate
+
 choice
tristate "USB Gadget Drivers"
default USB_ETH
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 3b65f1b..dc80129 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -101,3 +101,5 @@ usb_f_serial-y  := f_serial.o
 obj-$(CONFIG_USB_F_SERIAL) += usb_f_serial.o
 usb_f_obex-y   := f_obex.o
 obj-$(CONFIG_USB_F_OBEX)   += usb_f_obex.o
+usb_f_phonet-y := f_phonet.o
+obj-$(CONFIG_USB_F_PHONET) += usb_f_phonet.o
diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c
index f8df525..02b2270 100644
--- a/drivers/usb/gadget/f_phonet.c
+++ b/drivers/usb/gadget/f_phonet.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -478,8 +479,7 @@ static void pn_disconnect(struct usb_function *f)
 
 /*-*/
 
-static __init
-int pn_bind(struct usb_configuration *c, struct usb_function *f)
+static int pn_bind(struct usb_configuration *c, struct usb_function *f)
 {
struct usb_composite_dev *cdev = c->cdev;
struct usb_gadget *gadget = cdev->gadget;
@@ -560,8 +560,10 @@ err:
return status;
 }
 
+#ifdef USBF_PHONET_INCLUDED
+
 static void
-pn_unbind(struct usb_configuration *c, struct usb_function *f)
+pn_old_unbind(struct usb_configuration *c, struct usb_function *f)
 {
struct f_phonet *fp = func_to_pn(f);
int i;
@@ -593,7 +595,7 @@ int __init phonet_bind_config(struct usb_configuration *c,
fp->dev = dev;
fp->function.name = "phonet";
fp->function.bind = pn_bind;
-   fp->function.unbind = pn_unbind;
+   fp->function.unbind = pn_old_unbind;
fp->function.set_alt = pn_set_alt;
fp->function.get_alt = pn_get_alt;
fp->function.disable = pn_disconnect;
@@ -605,7 +607,85 @@ int __init phonet_bind_config(struct usb_configuration *c,
return err;
 }
 
-struct net_device __init *gphonet_setup(struct usb_gadget *gadget)
+#else
+
+static void phonet_free_inst(struct usb_function_instance *f)
+{
+   struct f_phonet_opts *opts;
+
+   opts = container_of(f, struct f_phonet_opts, func_inst);
+   kfree(opts);
+}
+
+static struct usb_function_instance *phonet_alloc_inst(void)
+{
+   struct f_phonet_opts *opts;
+
+   opts = kzalloc(sizeof(*opts), GFP_KERNEL);
+   if (!opts)
+   return ERR_PTR(-ENOMEM);
+
+   opts->func_inst.free_func_inst = phonet_free_inst;
+
+   return &opts->func_inst;
+}
+
+static void phonet_free(struct usb_function *f)
+{
+   struct f_phonet *phonet;
+
+   phonet = func_to_pn(f);
+   kfree(phonet);
+}
+
+static void pn_unbind(struct usb_configuration *c, struct usb_function *f)
+{
+   struct f_phonet *fp = func_to_pn(f);
+   int i;
+
+   /* We are already disconnected */
+   if (fp->in_req)
+   usb_ep_free_request(fp->in_ep, fp->in_req);
+   for (i = 0; i < phonet_rxq_size; i++)
+   if (fp->out_reqv[i])
+   usb_ep_free_request(fp->out_ep, fp->out_reqv[i]);
+
+   usb_free_all_descriptors(f);
+}
+
+struct usb_function *phonet_alloc(struct usb_function_instance *fi)
+{
+   struct f_phonet *fp;
+   struct f_phonet_opts *opts;
+   int size;
+
+   size = sizeof(*fp) + (phonet_rxq_size * sizeof(struct usb_request *));
+   fp = kzalloc(size, GFP_KERNEL);
+   if (!fp)
+   return ERR_PTR(-ENOMEM);
+
+   opts = container_of(fi, struct f_phonet_opts, func_inst);
+
+   fp->dev = opts->dev;
+   fp->function.name = "phonet";
+   fp->function.bind = pn_bind;
+   fp->function.unbind = pn_unbind;
+   fp->function.set_alt = pn_set_alt;
+   fp->function.get_alt = pn_get_alt;
+   fp->function.disable = pn_disconnect;
+   fp->function.free_func = phonet_free;
+   sp

[PATCH v2 4/8] usb/gadget: f_obex: remove compatibility layer

2013-03-25 Thread Andrzej Pietrasiewicz
There are no old function interface users left, so the old interface
can be removed.

Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/f_obex.c |   54 ---
 1 files changed, 0 insertions(+), 54 deletions(-)

diff --git a/drivers/usb/gadget/f_obex.c b/drivers/usb/gadget/f_obex.c
index 439b666..5571e36 100644
--- a/drivers/usb/gadget/f_obex.c
+++ b/drivers/usb/gadget/f_obex.c
@@ -405,57 +405,6 @@ fail:
return status;
 }
 
-#ifdef USBF_OBEX_INCLUDED
-
-static void
-obex_old_unbind(struct usb_configuration *c, struct usb_function *f)
-{
-   obex_string_defs[OBEX_CTRL_IDX].id = 0;
-   usb_free_all_descriptors(f);
-   kfree(func_to_obex(f));
-}
-
-/**
- * obex_bind_config - add a CDC OBEX function to a configuration
- * @c: the configuration to support the CDC OBEX instance
- * @port_num: /dev/ttyGS* port this interface will use
- * Context: single threaded during gadget setup
- *
- * Returns zero on success, else negative errno.
- */
-int __init obex_bind_config(struct usb_configuration *c, u8 port_num)
-{
-   struct f_obex   *obex;
-   int status;
-
-   /* allocate and initialize one new instance */
-   obex = kzalloc(sizeof *obex, GFP_KERNEL);
-   if (!obex)
-   return -ENOMEM;
-
-   obex->port_num = port_num;
-
-   obex->port.connect = obex_connect;
-   obex->port.disconnect = obex_disconnect;
-
-   obex->port.func.name = "obex";
-   obex->port.func.strings = obex_strings;
-   /* descriptors are per-instance copies */
-   obex->port.func.bind = obex_bind;
-   obex->port.func.unbind = obex_old_unbind;
-   obex->port.func.set_alt = obex_set_alt;
-   obex->port.func.get_alt = obex_get_alt;
-   obex->port.func.disable = obex_disable;
-
-   status = usb_add_function(c, &obex->port.func);
-   if (status)
-   kfree(obex);
-
-   return status;
-}
-
-#else
-
 static void obex_free_inst(struct usb_function_instance *f)
 {
struct f_serial_opts *opts;
@@ -529,8 +478,5 @@ struct usb_function *obex_alloc(struct 
usb_function_instance *fi)
 }
 
 DECLARE_USB_FUNCTION_INIT(obex, obex_alloc_inst, obex_alloc);
-
-#endif
-
 MODULE_AUTHOR("Felipe Balbi");
 MODULE_LICENSE("GPL");
-- 
1.7.0.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 v2 5/8] usb/gadget: phonet: move global dev variable to its user

2013-03-25 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/f_phonet.c |   20 +++-
 drivers/usb/gadget/nokia.c|   14 +-
 drivers/usb/gadget/u_phonet.h |6 +++---
 3 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c
index b21ab55..f8df525 100644
--- a/drivers/usb/gadget/f_phonet.c
+++ b/drivers/usb/gadget/f_phonet.c
@@ -579,9 +579,8 @@ pn_unbind(struct usb_configuration *c, struct usb_function 
*f)
 
 /*-*/
 
-static struct net_device *dev;
-
-int __init phonet_bind_config(struct usb_configuration *c)
+int __init phonet_bind_config(struct usb_configuration *c,
+ struct net_device *dev)
 {
struct f_phonet *fp;
int err, size;
@@ -606,16 +605,16 @@ int __init phonet_bind_config(struct usb_configuration *c)
return err;
 }
 
-int __init gphonet_setup(struct usb_gadget *gadget)
+struct net_device __init *gphonet_setup(struct usb_gadget *gadget)
 {
+   struct net_device *dev;
struct phonet_port *port;
int err;
 
/* Create net device */
-   BUG_ON(dev);
dev = alloc_netdev(sizeof(*port), "upnlink%d", pn_net_setup);
if (!dev)
-   return -ENOMEM;
+   return ERR_PTR(-ENOMEM);
 
port = netdev_priv(dev);
spin_lock_init(&port->lock);
@@ -623,12 +622,15 @@ int __init gphonet_setup(struct usb_gadget *gadget)
SET_NETDEV_DEV(dev, &gadget->dev);
 
err = register_netdev(dev);
-   if (err)
+   if (err) {
free_netdev(dev);
-   return err;
+
+   return ERR_PTR(err);
+   }
+   return dev;
 }
 
-void gphonet_cleanup(void)
+void gphonet_cleanup(struct net_device *dev)
 {
unregister_netdev(dev);
 }
diff --git a/drivers/usb/gadget/nokia.c b/drivers/usb/gadget/nokia.c
index bb10019..047b2fe 100644
--- a/drivers/usb/gadget/nokia.c
+++ b/drivers/usb/gadget/nokia.c
@@ -104,6 +104,8 @@ static struct usb_function *f_obex1_cfg2;
 static struct usb_function *f_obex2_cfg2;
 static u8 hostaddr[ETH_ALEN];
 static struct eth_dev *the_dev;
+static struct net_device *phonet_dev;
+
 
 static struct usb_configuration nokia_config_500ma_driver = {
.label  = "Bus Powered",
@@ -137,7 +139,7 @@ static int __init nokia_bind_config(struct 
usb_configuration *c)
int obex1_stat = 0;
int obex2_stat = 0;
 
-   status = phonet_bind_config(c);
+   status = phonet_bind_config(c, phonet_dev);
if (status)
printk(KERN_DEBUG "could not bind phonet config\n");
 
@@ -227,9 +229,11 @@ static int __init nokia_bind(struct usb_composite_dev 
*cdev)
struct usb_gadget   *gadget = cdev->gadget;
int status;
 
-   status = gphonet_setup(cdev->gadget);
-   if (status < 0)
+   phonet_dev = gphonet_setup(cdev->gadget);
+   if (IS_ERR(phonet_dev)) {
+   status = PTR_ERR(phonet_dev);
goto err_phonet;
+   }
 
the_dev = gether_setup(cdev->gadget, hostaddr);
if (IS_ERR(the_dev)) {
@@ -302,7 +306,7 @@ err_obex2_inst:
 err_usb:
gether_cleanup(the_dev);
 err_ether:
-   gphonet_cleanup();
+   gphonet_cleanup(phonet_dev);
 err_phonet:
return status;
 }
@@ -327,7 +331,7 @@ static int __exit nokia_unbind(struct usb_composite_dev 
*cdev)
usb_put_function_instance(fi_obex2);
usb_put_function_instance(fi_acm);
usb_put_function_instance(fi_ecm);
-   gphonet_cleanup();
+   gphonet_cleanup(phonet_dev);
 
gether_cleanup(the_dev);
 
diff --git a/drivers/usb/gadget/u_phonet.h b/drivers/usb/gadget/u_phonet.h
index 09a7525..459ee32 100644
--- a/drivers/usb/gadget/u_phonet.h
+++ b/drivers/usb/gadget/u_phonet.h
@@ -14,8 +14,8 @@
 #include 
 #include 
 
-int gphonet_setup(struct usb_gadget *gadget);
-int phonet_bind_config(struct usb_configuration *c);
-void gphonet_cleanup(void);
+struct net_device *gphonet_setup(struct usb_gadget *gadget);
+int phonet_bind_config(struct usb_configuration *c, struct net_device *dev);
+void gphonet_cleanup(struct net_device *dev);
 
 #endif /* __U_PHONET_H */
-- 
1.7.0.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 v2 1/8] usb/gadget: f_obex: convert to new function interface with backward compatibility

2013-03-25 Thread Andrzej Pietrasiewicz
Converting f_obex to the new function interface requires converting
the f_obex's function code and its users.
This patch converts the f_obex.c to the new function interface.
The file is now compiled into a separate usb_f_obex.ko module.
The old function interface is provided by means of preprocessor
conditional directives. After all users are converted, the old interface
can be removed.

Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/Kconfig  |3 +
 drivers/usb/gadget/Makefile |2 +
 drivers/usb/gadget/f_obex.c |  171 +++
 drivers/usb/gadget/nokia.c  |1 +
 drivers/usb/gadget/serial.c |1 +
 5 files changed, 132 insertions(+), 46 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index d3b5128..ac89706 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -584,6 +584,9 @@ config USB_F_FS
 config USB_F_SERIAL
tristate
 
+config USB_F_OBEX
+   tristate
+
 choice
tristate "USB Gadget Drivers"
default USB_ETH
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index f00e276..3b65f1b 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -99,3 +99,5 @@ usb_f_fs-y:= f_fs.o
 obj-$(CONFIG_USB_F_FS) += usb_f_fs.o
 usb_f_serial-y := f_serial.o
 obj-$(CONFIG_USB_F_SERIAL) += usb_f_serial.o
+usb_f_obex-y   := f_obex.o
+obj-$(CONFIG_USB_F_OBEX)   += usb_f_obex.o
diff --git a/drivers/usb/gadget/f_obex.c b/drivers/usb/gadget/f_obex.c
index 36a0045..439b666 100644
--- a/drivers/usb/gadget/f_obex.c
+++ b/drivers/usb/gadget/f_obex.c
@@ -72,7 +72,7 @@ static struct usb_gadget_strings *obex_strings[] = {
 
 /*-*/
 
-static struct usb_interface_descriptor obex_control_intf __initdata = {
+static struct usb_interface_descriptor obex_control_intf = {
.bLength= sizeof(obex_control_intf),
.bDescriptorType= USB_DT_INTERFACE,
.bInterfaceNumber   = 0,
@@ -83,7 +83,7 @@ static struct usb_interface_descriptor obex_control_intf 
__initdata = {
.bInterfaceSubClass = USB_CDC_SUBCLASS_OBEX,
 };
 
-static struct usb_interface_descriptor obex_data_nop_intf __initdata = {
+static struct usb_interface_descriptor obex_data_nop_intf = {
.bLength= sizeof(obex_data_nop_intf),
.bDescriptorType= USB_DT_INTERFACE,
.bInterfaceNumber   = 1,
@@ -93,7 +93,7 @@ static struct usb_interface_descriptor obex_data_nop_intf 
__initdata = {
.bInterfaceClass= USB_CLASS_CDC_DATA,
 };
 
-static struct usb_interface_descriptor obex_data_intf __initdata = {
+static struct usb_interface_descriptor obex_data_intf = {
.bLength= sizeof(obex_data_intf),
.bDescriptorType= USB_DT_INTERFACE,
.bInterfaceNumber   = 2,
@@ -103,14 +103,14 @@ static struct usb_interface_descriptor obex_data_intf 
__initdata = {
.bInterfaceClass= USB_CLASS_CDC_DATA,
 };
 
-static struct usb_cdc_header_desc obex_cdc_header_desc __initdata = {
+static struct usb_cdc_header_desc obex_cdc_header_desc = {
.bLength= sizeof(obex_cdc_header_desc),
.bDescriptorType= USB_DT_CS_INTERFACE,
.bDescriptorSubType = USB_CDC_HEADER_TYPE,
.bcdCDC = cpu_to_le16(0x0120),
 };
 
-static struct usb_cdc_union_desc obex_cdc_union_desc __initdata = {
+static struct usb_cdc_union_desc obex_cdc_union_desc = {
.bLength= sizeof(obex_cdc_union_desc),
.bDescriptorType= USB_DT_CS_INTERFACE,
.bDescriptorSubType = USB_CDC_UNION_TYPE,
@@ -118,7 +118,7 @@ static struct usb_cdc_union_desc obex_cdc_union_desc 
__initdata = {
.bSlaveInterface0   = 2,
 };
 
-static struct usb_cdc_obex_desc obex_desc __initdata = {
+static struct usb_cdc_obex_desc obex_desc = {
.bLength= sizeof(obex_desc),
.bDescriptorType= USB_DT_CS_INTERFACE,
.bDescriptorSubType = USB_CDC_OBEX_TYPE,
@@ -127,7 +127,7 @@ static struct usb_cdc_obex_desc obex_desc __initdata = {
 
 /* High-Speed Support */
 
-static struct usb_endpoint_descriptor obex_hs_ep_out_desc __initdata = {
+static struct usb_endpoint_descriptor obex_hs_ep_out_desc = {
.bLength= USB_DT_ENDPOINT_SIZE,
.bDescriptorType= USB_DT_ENDPOINT,
 
@@ -136,7 +136,7 @@ static struct usb_endpoint_descriptor obex_hs_ep_out_desc 
__initdata = {
.wMaxPacketSize = cpu_to_le16(512),
 };
 
-static struct usb_endpoint_descriptor obex_hs_ep_in_desc __initdata = {
+static struct usb_endpoint_descriptor obex_hs_ep_in_desc = {
.bLength= USB_DT_ENDPOINT_SIZE,
.bDescriptorType= USB_DT_ENDPOINT,

[PATCH v2 2/8] usb/gadget: serial: convert to new interface of f_obex

2013-03-25 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/Kconfig  |1 +
 drivers/usb/gadget/serial.c |   42 +++---
 2 files changed, 4 insertions(+), 39 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index ac89706..aaf1e62 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -856,6 +856,7 @@ config USB_G_SERIAL
select USB_U_SERIAL
select USB_F_ACM
select USB_F_SERIAL
+   select USB_F_OBEX
select USB_LIBCOMPOSITE
help
  The Serial Gadget talks to the Linux-USB generic serial driver.
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index 664da64..1f5f978 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -12,6 +12,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -28,18 +29,6 @@
 #define GS_VERSION_NAMEGS_LONG_NAME " " GS_VERSION_STR
 
 /*-*/
-
-/*
- * 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.
- */
-#define USBF_OBEX_INCLUDED
-#include "f_obex.c"
-
-/*-*/
 USB_GADGET_COMPOSITE_OPTIONS();
 
 /* Thanks to NetChip Technologies for donating this product ID.
@@ -126,17 +115,6 @@ module_param(n_ports, uint, 0);
 MODULE_PARM_DESC(n_ports, "number of ports to create, default=1");
 
 /*-*/
-static unsigned char tty_lines[MAX_U_SERIAL_PORTS];
-
-static int __init serial_bind_obex_config(struct usb_configuration *c)
-{
-   unsigned i;
-   int status = 0;
-
-   for (i = 0; i < n_ports && status == 0; i++)
-   status = obex_bind_config(c, tty_lines[i]);
-   return status;
-}
 
 static struct usb_configuration serial_config_driver = {
/* .label = f(use_acm) */
@@ -199,15 +177,6 @@ out:
 static int __init gs_bind(struct usb_composite_dev *cdev)
 {
int status;
-   int cur_line = 0;
-
-   if (use_obex) {
-   for (cur_line = 0; cur_line < n_ports; cur_line++) {
-   status = gserial_alloc_line(&tty_lines[cur_line]);
-   if (status)
-   goto fail;
-   }
-   }
 
/* Allocate string descriptor numbers ... note that string
 * contents can be overridden by the composite_dev glue.
@@ -232,8 +201,8 @@ static int __init gs_bind(struct usb_composite_dev *cdev)
"acm");
usb_ep_autoconfig_reset(cdev->gadget);
} else if (use_obex)
-   status = usb_add_config(cdev, &serial_config_driver,
-   serial_bind_obex_config);
+   status = serial_register_ports(cdev, &serial_config_driver,
+   "obex");
else {
status = serial_register_ports(cdev, &serial_config_driver,
"gser");
@@ -247,9 +216,6 @@ static int __init gs_bind(struct usb_composite_dev *cdev)
return 0;
 
 fail:
-   cur_line--;
-   while (cur_line >= 0 && use_obex)
-   gserial_free_line(tty_lines[cur_line--]);
return status;
 }
 
@@ -260,8 +226,6 @@ static int gs_unbind(struct usb_composite_dev *cdev)
for (i = 0; i < n_ports; i++) {
usb_put_function(f_serial[i]);
usb_put_function_instance(fi_serial[i]);
-   if (use_obex)
-   gserial_free_line(tty_lines[i]);
}
return 0;
 }
-- 
1.7.0.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 v2 0/8] Towards configfs - usb OBEX and phonet functions conversion to the new interface

2013-03-25 Thread Andrzej Pietrasiewicz
This is a follow-up to this thread:

http://www.spinics.net/lists/linux-usb/msg82418.html

which is a prerequisite for applying the patches being sent here.

I am creating a separate series because the above mentioned thread
becomes very long.

The prerequisite for providing the configfs interface for USB gadgets and
all their users is converting them to the new function interface from Sebastian.
Just changing the function interface is not enough for gadgets to be converted
to configfs, though. After the functions are converted, some more work is
required to arrive at a gadget configurable through configfs.

This patch series serves the purpose stated above for OBEX and phonet
and it supersedes this series:

http://www.spinics.net/lists/linux-usb/msg82990.html

change history:

v1..v2:

- fixes in OBEX conversion
- convert phonet

v1:

- convert OBEX


So far I have converted the following functions and gadgets:

USB function | users (gadgets)
=
f_mass_storage   | g_mass_storage, acm_ms, g_multi
f_ncm| g_ncm
f_eem| g_ether
f_ecm| g_cdc, g_ether, g_ffs, g_multi, g_nokia
f_subset | g_ether, g_ffs, g_multi
f_rndis  | g_ether, g_ffs, g_multi
f_fs | g_ffs
f_serial | g_serial
f_obex   | g_serial, g_nokia
f_phonet | g_nokia

Still to be converted:

USB function | users (gadgets)
=
f_uac1   | g_audio
f_uac2   | g_audio
f_midi   | g_midi
f_hid| g_hid
f_uvc| g_webcam


Andrzej Pietrasiewicz (8):
  usb/gadget: f_obex: convert to new function interface with backward
compatibility
  usb/gadget: serial: convert to new interface of f_obex
  usb/gadget: nokia: convert to new interface of f_obex
  usb/gadget: f_obex: remove compatibility layer
  usb/gadget: phonet: move global dev variable to its user
  usb/gadget: f_phonet: convert to new function interface with backward
compatibility
  usb/gadget: nokia: convert to new interface of f_phonet
  usb/gadget: f_phonet: remove compatibility layer

 drivers/usb/gadget/Kconfig|9 ++
 drivers/usb/gadget/Makefile   |4 +
 drivers/usb/gadget/f_obex.c   |  147 +---
 drivers/usb/gadget/f_phonet.c |   79 +--
 drivers/usb/gadget/nokia.c|  171 -
 drivers/usb/gadget/serial.c   |   41 +-
 drivers/usb/gadget/u_phonet.h |   11 ++-
 7 files changed, 284 insertions(+), 178 deletions(-)

--
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: dwc3: add CONFIG_PM_SLEEP to suspend/resume functions

2013-03-25 Thread Felipe Balbi
Hi,

On Mon, Mar 25, 2013 at 07:48:25AM +, Jingoo Han wrote:
> Add CONFIG_PM_SLEEP to suspend/resume functions to fix the following
> build warning when CONFIG_PM_SLEEP is not selected. This is because
> sleep PM callbacks defined by SET_SYSTEM_SLEEP_PM_OPS are only used
> when the CONFIG_PM_SLEEP is enabled.
> 
> drivers/usb/dwc3/core.c:682:12: warning: 'dwc3_suspend' defined but not used 
> [-Wunused-function]
> drivers/usb/dwc3/core.c:709:12: warning: 'dwc3_resume' defined but not used 
> [-Wunused-function]
> drivers/usb/dwc3/dwc3-omap.c:430:12: warning: 'dwc3_omap_suspend' defined but 
> not used [-Wunused-function]
> drivers/usb/dwc3/dwc3-omap.c:440:12: warning: 'dwc3_omap_resume' defined but 
> not used [-Wunused-function]
> drivers/usb/dwc3/dwc3-exynos.c:185:12: warning: 'dwc3_exynos_suspend' defined 
> but not used [-Wunused-function]
> drivers/usb/dwc3/dwc3-exynos.c:194:12: warning: 'dwc3_exynos_resume' defined 
> but not used [-Wunused-function]
> 
> Signed-off-by: Jingoo Han 
> ---
>  drivers/usb/dwc3/core.c|2 ++
>  drivers/usb/dwc3/dwc3-exynos.c |2 ++
>  drivers/usb/dwc3/dwc3-omap.c   |2 ++
>  3 files changed, 6 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index e2325ad..10729ff 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -679,6 +679,7 @@ static void dwc3_complete(struct device *dev)
>   spin_unlock_irqrestore(&dwc->lock, flags);
>  }
>  
> +#ifdef CONFIG_PM_SLEEP
>  static int dwc3_suspend(struct device *dev)
>  {
>   struct dwc3 *dwc = dev_get_drvdata(dev);
> @@ -738,6 +739,7 @@ static int dwc3_resume(struct device *dev)
>  
>   return 0;
>  }
> +#endif

good point, but looks a bit incomplete. Looking at the definition of
SET_SYSTEM_SLEEP_PM_OPS, it seems like you could remove #ifdef CONFIG_PM
from that file.

Can you cook a patch along those lines ?

-- 
balbi


signature.asc
Description: Digital signature


[PATCH] usb: dwc3: add CONFIG_PM_SLEEP to suspend/resume functions

2013-03-25 Thread Jingoo Han
Add CONFIG_PM_SLEEP to suspend/resume functions to fix the following
build warning when CONFIG_PM_SLEEP is not selected. This is because
sleep PM callbacks defined by SET_SYSTEM_SLEEP_PM_OPS are only used
when the CONFIG_PM_SLEEP is enabled.

drivers/usb/dwc3/core.c:682:12: warning: 'dwc3_suspend' defined but not used 
[-Wunused-function]
drivers/usb/dwc3/core.c:709:12: warning: 'dwc3_resume' defined but not used 
[-Wunused-function]
drivers/usb/dwc3/dwc3-omap.c:430:12: warning: 'dwc3_omap_suspend' defined but 
not used [-Wunused-function]
drivers/usb/dwc3/dwc3-omap.c:440:12: warning: 'dwc3_omap_resume' defined but 
not used [-Wunused-function]
drivers/usb/dwc3/dwc3-exynos.c:185:12: warning: 'dwc3_exynos_suspend' defined 
but not used [-Wunused-function]
drivers/usb/dwc3/dwc3-exynos.c:194:12: warning: 'dwc3_exynos_resume' defined 
but not used [-Wunused-function]

Signed-off-by: Jingoo Han 
---
 drivers/usb/dwc3/core.c|2 ++
 drivers/usb/dwc3/dwc3-exynos.c |2 ++
 drivers/usb/dwc3/dwc3-omap.c   |2 ++
 3 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index e2325ad..10729ff 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -679,6 +679,7 @@ static void dwc3_complete(struct device *dev)
spin_unlock_irqrestore(&dwc->lock, flags);
 }
 
+#ifdef CONFIG_PM_SLEEP
 static int dwc3_suspend(struct device *dev)
 {
struct dwc3 *dwc = dev_get_drvdata(dev);
@@ -738,6 +739,7 @@ static int dwc3_resume(struct device *dev)
 
return 0;
 }
+#endif
 
 static const struct dev_pm_ops dwc3_dev_pm_ops = {
.prepare= dwc3_prepare,
diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c
index 1ea7bd8..f7806f0 100644
--- a/drivers/usb/dwc3/dwc3-exynos.c
+++ b/drivers/usb/dwc3/dwc3-exynos.c
@@ -182,6 +182,7 @@ MODULE_DEVICE_TABLE(of, exynos_dwc3_match);
 #endif
 
 #ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int dwc3_exynos_suspend(struct device *dev)
 {
struct dwc3_exynos *exynos = dev_get_drvdata(dev);
@@ -204,6 +205,7 @@ static int dwc3_exynos_resume(struct device *dev)
 
return 0;
 }
+#endif
 
 static const struct dev_pm_ops dwc3_exynos_dev_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(dwc3_exynos_suspend, dwc3_exynos_resume)
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index 6de734f..9620d7d 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -427,6 +427,7 @@ static void dwc3_omap_complete(struct device *dev)
dwc3_omap_enable_irqs(omap);
 }
 
+#ifdef CONFIG_PM_SLEEP
 static int dwc3_omap_suspend(struct device *dev)
 {
struct dwc3_omap*omap = dev_get_drvdata(dev);
@@ -450,6 +451,7 @@ static int dwc3_omap_resume(struct device *dev)
 
return 0;
 }
+#endif
 
 static const struct dev_pm_ops dwc3_omap_dev_pm_ops = {
.prepare= dwc3_omap_prepare,
-- 
1.7.2.5
N떑꿩�r툤y鉉싕b쾊Ф푤v�^�)頻{.n�+돴쪐{군펐왲^n뇊⊆쫧�곷h솳鈺�&��췍쳺�h�(��쉸듶줷"얎�m��곴�z받뻿筬f"톒쉱�~늤

[PATCH V2 5/6] arm: mmp: remove clock name from usb pdata for ttc

2013-03-25 Thread Chao Xie
The clock name will directly get by driver. Removing
the name from pdata.

Signed-off-by: Chao Xie 
---
 arch/arm/mach-mmp/ttc_dkb.c |6 --
 1 files changed, 0 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-mmp/ttc_dkb.c b/arch/arm/mach-mmp/ttc_dkb.c
index 22a9058..6528a5f 100644
--- a/arch/arm/mach-mmp/ttc_dkb.c
+++ b/arch/arm/mach-mmp/ttc_dkb.c
@@ -162,13 +162,7 @@ static struct i2c_board_info ttc_dkb_i2c_info[] = {
 #ifdef CONFIG_USB_SUPPORT
 #if defined(CONFIG_USB_MV_UDC) || defined(CONFIG_USB_EHCI_MV_U2O)
 
-static char *pxa910_usb_clock_name[] = {
-   [0] = "U2OCLK",
-};
-
 static struct mv_usb_platform_data ttc_usb_pdata = {
-   .clknum = 1,
-   .clkname= pxa910_usb_clock_name,
.vbus   = NULL,
.mode   = MV_USB_MODE_OTG,
.otg_force_a_bus_req = 1,
-- 
1.7.4.1

--
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 V2 0/6] remove the clock name from pdata

2013-03-25 Thread Chao Xie
The clock is defined by device, so the driver knows how many
clocks needed by the device.
The orignal way that passing the clock name by pdata is not correct.
The following patches fix it.

V2->V1:
   typo fix
   rebased on latest usb-next

Chao Xie (6):
  usb: gadget: mv_udc_core: remove unused clock
  usb: otg: mv_otg: remove unused clock
  usb: ehci: mv_ehci: remove unused clock
  arm: mmp: remove clock from usb pdata for aspenite
  arm: mmp: remove clock name from usb pdata for ttc
  usb: mv_usb: remove clock name from pdata

 arch/arm/mach-mmp/aspenite.c |6 -
 arch/arm/mach-mmp/ttc_dkb.c  |6 -
 drivers/usb/gadget/mv_udc.h  |3 +-
 drivers/usb/gadget/mv_udc_core.c |   27 ++---
 drivers/usb/host/ehci-mv.c   |   35 +
 drivers/usb/phy/phy-mv-usb.c |   28 ++
 drivers/usb/phy/phy-mv-usb.h |3 +-
 include/linux/platform_data/mv_usb.h |2 -
 8 files changed, 26 insertions(+), 84 deletions(-)

-- 
1.7.4.1

--
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 V2 4/6] arm: mmp: remove clock from usb pdata for aspenite

2013-03-25 Thread Chao Xie
The clock name will directly get by driver. Removing
the name from pdata.

Signed-off-by: Chao Xie 
---
 arch/arm/mach-mmp/aspenite.c |6 --
 1 files changed, 0 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-mmp/aspenite.c b/arch/arm/mach-mmp/aspenite.c
index 9f64d56..76901f4 100644
--- a/arch/arm/mach-mmp/aspenite.c
+++ b/arch/arm/mach-mmp/aspenite.c
@@ -223,13 +223,7 @@ static struct pxa27x_keypad_platform_data 
aspenite_keypad_info __initdata = {
 };
 
 #if defined(CONFIG_USB_EHCI_MV)
-static char *pxa168_sph_clock_name[] = {
-   [0] = "PXA168-USBCLK",
-};
-
 static struct mv_usb_platform_data pxa168_sph_pdata = {
-   .clknum = 1,
-   .clkname= pxa168_sph_clock_name,
.mode   = MV_USB_MODE_HOST,
.phy_init   = pxa_usb_phy_init,
.phy_deinit = pxa_usb_phy_deinit,
-- 
1.7.4.1

--
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 V2 3/6] usb: ehci: mv_ehci: remove unused clock

2013-03-25 Thread Chao Xie
The origianl understanding of clock is wrong. The EHCI controller
only have one clock input.
Passing clock name by pdata is wrong. The clock is defined by device
iteself.

Signed-off-by: Chao Xie 
---
 drivers/usb/host/ehci-mv.c |   35 ++-
 1 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c
index 3804820..6bad41a 100644
--- a/drivers/usb/host/ehci-mv.c
+++ b/drivers/usb/host/ehci-mv.c
@@ -33,25 +33,17 @@ struct ehci_hcd_mv {
 
struct mv_usb_platform_data *pdata;
 
-   /* clock source and total clock number */
-   unsigned int clknum;
-   struct clk *clk[0];
+   struct clk *clk;
 };
 
 static void ehci_clock_enable(struct ehci_hcd_mv *ehci_mv)
 {
-   unsigned int i;
-
-   for (i = 0; i < ehci_mv->clknum; i++)
-   clk_prepare_enable(ehci_mv->clk[i]);
+   clk_prepare_enable(ehci_mv->clk);
 }
 
 static void ehci_clock_disable(struct ehci_hcd_mv *ehci_mv)
 {
-   unsigned int i;
-
-   for (i = 0; i < ehci_mv->clknum; i++)
-   clk_disable_unprepare(ehci_mv->clk[i]);
+   clk_disable_unprepare(ehci_mv->clk);
 }
 
 static int mv_ehci_enable(struct ehci_hcd_mv *ehci_mv)
@@ -144,9 +136,8 @@ static int mv_ehci_probe(struct platform_device *pdev)
struct ehci_hcd *ehci;
struct ehci_hcd_mv *ehci_mv;
struct resource *r;
-   int clk_i, retval = -ENODEV;
+   int retval = -ENODEV;
u32 offset;
-   size_t size;
 
if (!pdata) {
dev_err(&pdev->dev, "missing platform_data\n");
@@ -160,8 +151,7 @@ static int mv_ehci_probe(struct platform_device *pdev)
if (!hcd)
return -ENOMEM;
 
-   size = sizeof(*ehci_mv) + sizeof(struct clk *) * pdata->clknum;
-   ehci_mv = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
+   ehci_mv = devm_kzalloc(&pdev->dev, sizeof(*ehci_mv), GFP_KERNEL);
if (ehci_mv == NULL) {
dev_err(&pdev->dev, "cannot allocate ehci_hcd_mv\n");
retval = -ENOMEM;
@@ -172,16 +162,11 @@ static int mv_ehci_probe(struct platform_device *pdev)
ehci_mv->pdata = pdata;
ehci_mv->hcd = hcd;
 
-   ehci_mv->clknum = pdata->clknum;
-   for (clk_i = 0; clk_i < ehci_mv->clknum; clk_i++) {
-   ehci_mv->clk[clk_i] =
-   devm_clk_get(&pdev->dev, pdata->clkname[clk_i]);
-   if (IS_ERR(ehci_mv->clk[clk_i])) {
-   dev_err(&pdev->dev, "error get clck \"%s\"\n",
-   pdata->clkname[clk_i]);
-   retval = PTR_ERR(ehci_mv->clk[clk_i]);
-   goto err_clear_drvdata;
-   }
+   ehci_mv->clk = devm_clk_get(&pdev->dev, NULL);
+   if (IS_ERR(ehci_mv->clk)) {
+   dev_err(&pdev->dev, "error getting clock\n");
+   retval = PTR_ERR(ehci_mv->clk);
+   goto err_clear_drvdata;
}
 
r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phyregs");
-- 
1.7.4.1

--
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 V2 1/6] usb: gadget: mv_udc_core: remove unused clock

2013-03-25 Thread Chao Xie
The origianl understanding of clock is wrong. The UDC controller
only have one clock input.
Passing clock name by pdata is wrong. The clock is defined by device
iteself.

Signed-off-by: Chao Xie 
---
 drivers/usb/gadget/mv_udc.h  |3 +--
 drivers/usb/gadget/mv_udc_core.c |   27 +++
 2 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/gadget/mv_udc.h b/drivers/usb/gadget/mv_udc.h
index 9073436..be77f20 100644
--- a/drivers/usb/gadget/mv_udc.h
+++ b/drivers/usb/gadget/mv_udc.h
@@ -222,8 +222,7 @@ struct mv_udc {
struct mv_usb_platform_data *pdata;
 
/* some SOC has mutiple clock sources for USB*/
-   unsigned intclknum;
-   struct clk  *clk[0];
+   struct clk  *clk;
 };
 
 /* endpoint data structure */
diff --git a/drivers/usb/gadget/mv_udc_core.c b/drivers/usb/gadget/mv_udc_core.c
index 9a68c05..593147b 100644
--- a/drivers/usb/gadget/mv_udc_core.c
+++ b/drivers/usb/gadget/mv_udc_core.c
@@ -972,18 +972,12 @@ static struct usb_ep_ops mv_ep_ops = {
 
 static void udc_clock_enable(struct mv_udc *udc)
 {
-   unsigned int i;
-
-   for (i = 0; i < udc->clknum; i++)
-   clk_prepare_enable(udc->clk[i]);
+   clk_prepare_enable(udc->clk);
 }
 
 static void udc_clock_disable(struct mv_udc *udc)
 {
-   unsigned int i;
-
-   for (i = 0; i < udc->clknum; i++)
-   clk_disable_unprepare(udc->clk[i]);
+   clk_disable_unprepare(udc->clk);
 }
 
 static void udc_stop(struct mv_udc *udc)
@@ -2105,7 +2099,6 @@ static int mv_udc_probe(struct platform_device *pdev)
struct mv_usb_platform_data *pdata = pdev->dev.platform_data;
struct mv_udc *udc;
int retval = 0;
-   int clk_i = 0;
struct resource *r;
size_t size;
 
@@ -2114,8 +2107,7 @@ static int mv_udc_probe(struct platform_device *pdev)
return -ENODEV;
}
 
-   size = sizeof(*udc) + sizeof(struct clk *) * pdata->clknum;
-   udc = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
+   udc = devm_kzalloc(&pdev->dev, sizeof(*udc), GFP_KERNEL);
if (udc == NULL) {
dev_err(&pdev->dev, "failed to allocate memory for udc\n");
return -ENOMEM;
@@ -2141,15 +2133,10 @@ static int mv_udc_probe(struct platform_device *pdev)
}
}
 
-   udc->clknum = pdata->clknum;
-   for (clk_i = 0; clk_i < udc->clknum; clk_i++) {
-   udc->clk[clk_i] = devm_clk_get(&pdev->dev,
-   pdata->clkname[clk_i]);
-   if (IS_ERR(udc->clk[clk_i])) {
-   retval = PTR_ERR(udc->clk[clk_i]);
-   return retval;
-   }
-   }
+   /* udc only have one sysclk. */
+   udc->clk = devm_clk_get(&pdev->dev, NULL);
+   if (IS_ERR(udc->clk))
+   return PTR_ERR(udc->clk);
 
r = platform_get_resource_byname(udc->dev, IORESOURCE_MEM, "capregs");
if (r == NULL) {
-- 
1.7.4.1

--
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 V2 6/6] usb: mv_usb: remove clock name from pdata

2013-03-25 Thread Chao Xie
Using pdata to pass clock name is not correct.
Directly get clock from usb drivers.

Signed-off-by: Chao Xie 
---
 include/linux/platform_data/mv_usb.h |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/include/linux/platform_data/mv_usb.h 
b/include/linux/platform_data/mv_usb.h
index 944b01d..98b7925 100644
--- a/include/linux/platform_data/mv_usb.h
+++ b/include/linux/platform_data/mv_usb.h
@@ -34,8 +34,6 @@ struct mv_usb_addon_irq {
 };
 
 struct mv_usb_platform_data {
-   unsigned intclknum;
-   char**clkname;
struct mv_usb_addon_irq *id;/* Only valid for OTG. ID pin change*/
struct mv_usb_addon_irq *vbus;  /* valid for OTG/UDC. VBUS change*/
 
-- 
1.7.4.1

--
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 V2 2/6] usb: otg: mv_otg: remove unused clock

2013-03-25 Thread Chao Xie
The origianl understanding of clock is wrong. The OTG controller
only have one clock input.
Passing clock name by pdata is wrong. The clock is defined by device
iteself.

Signed-off-by: Chao Xie 
---
 drivers/usb/phy/phy-mv-usb.c |   28 +++-
 drivers/usb/phy/phy-mv-usb.h |3 +--
 2 files changed, 8 insertions(+), 23 deletions(-)

diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c
index 6872bf0..c987bbe 100644
--- a/drivers/usb/phy/phy-mv-usb.c
+++ b/drivers/usb/phy/phy-mv-usb.c
@@ -237,18 +237,12 @@ static void mv_otg_start_periphrals(struct mv_otg *mvotg, 
int on)
 
 static void otg_clock_enable(struct mv_otg *mvotg)
 {
-   unsigned int i;
-
-   for (i = 0; i < mvotg->clknum; i++)
-   clk_prepare_enable(mvotg->clk[i]);
+   clk_prepare_enable(mvotg->clk);
 }
 
 static void otg_clock_disable(struct mv_otg *mvotg)
 {
-   unsigned int i;
-
-   for (i = 0; i < mvotg->clknum; i++)
-   clk_disable_unprepare(mvotg->clk[i]);
+   clk_disable_unprepare(mvotg->clk);
 }
 
 static int mv_otg_enable_internal(struct mv_otg *mvotg)
@@ -684,16 +678,14 @@ static int mv_otg_probe(struct platform_device *pdev)
struct mv_otg *mvotg;
struct usb_otg *otg;
struct resource *r;
-   int retval = 0, clk_i, i;
-   size_t size;
+   int retval = 0, i;
 
if (pdata == NULL) {
dev_err(&pdev->dev, "failed to get platform data\n");
return -ENODEV;
}
 
-   size = sizeof(*mvotg) + sizeof(struct clk *) * pdata->clknum;
-   mvotg = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
+   mvotg = devm_kzalloc(&pdev->dev, sizeof(*mvotg), GFP_KERNEL);
if (!mvotg) {
dev_err(&pdev->dev, "failed to allocate memory!\n");
return -ENOMEM;
@@ -708,15 +700,9 @@ static int mv_otg_probe(struct platform_device *pdev)
mvotg->pdev = pdev;
mvotg->pdata = pdata;
 
-   mvotg->clknum = pdata->clknum;
-   for (clk_i = 0; clk_i < mvotg->clknum; clk_i++) {
-   mvotg->clk[clk_i] = devm_clk_get(&pdev->dev,
-   pdata->clkname[clk_i]);
-   if (IS_ERR(mvotg->clk[clk_i])) {
-   retval = PTR_ERR(mvotg->clk[clk_i]);
-   return retval;
-   }
-   }
+   mvotg->clk = devm_clk_get(&pdev->dev, NULL);
+   if (IS_ERR(mvotg->clk))
+   return PTR_ERR(mvotg->clk);
 
mvotg->qwork = create_singlethread_workqueue("mv_otg_queue");
if (!mvotg->qwork) {
diff --git a/drivers/usb/phy/phy-mv-usb.h b/drivers/usb/phy/phy-mv-usb.h
index 8a9e351..551da6e 100644
--- a/drivers/usb/phy/phy-mv-usb.h
+++ b/drivers/usb/phy/phy-mv-usb.h
@@ -158,8 +158,7 @@ struct mv_otg {
 
unsigned int active;
unsigned int clock_gating;
-   unsigned int clknum;
-   struct clk *clk[0];
+   struct clk *clk;
 };
 
 #endif
-- 
1.7.4.1

--
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