[PATCH] xhci: fix memleak in xhci_run()

2017-07-19 Thread shuwang
From: Shu Wang 

Found this issue by kmemleak.
xhci_run() did not check return val and free command for
xhci_queue_vendor_command()

unreferenced object 0x88011c0be500 (size 64):
  comm "kworker/0:1", pid 58, jiffies 4294670908 (age 50.420s)
  hex dump (first 32 bytes):
  backtrace:
[] kmemleak_alloc+0x4a/0xa0
[] kmem_cache_alloc_trace+0xca/0x1d0
[] xhci_alloc_command+0x44/0x130
[] xhci_run+0x4cc/0x630
[] usb_add_hcd+0x3bb/0x950
[] usb_hcd_pci_probe+0x188/0x500
[] xhci_pci_probe+0x2c/0x220
[] local_pci_probe+0x45/0xa0
[] work_for_cpu_fn+0x14/0x20
[] process_one_work+0x149/0x360
[] worker_thread+0x1d8/0x3c0
[] kthread+0x109/0x140
[] ret_from_fork+0x25/0x30
[] 0x

Signed-off-by: Shu Wang 
---
 drivers/usb/host/xhci.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 56f85df..b2a8179 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -622,8 +622,10 @@ int xhci_run(struct usb_hcd *hcd)
if (!command)
return -ENOMEM;
 
-   xhci_queue_vendor_command(xhci, command, 0, 0, 0,
+   ret = xhci_queue_vendor_command(xhci, command, 0, 0, 0,
TRB_TYPE(TRB_NEC_GET_FW));
+   if (ret)
+   xhci_free_command(xhci, command);
}
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
"Finished xhci_run for USB2 roothub");
-- 
2.5.0

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


Re: [PATCH 2/9] USB: chipidea: remove unneeded MODULE_VERSION() usage

2017-07-19 Thread Peter Chen
On Wed, Jul 19, 2017 at 02:17:37PM +0200, Greg Kroah-Hartman wrote:
> MODULE_VERSION is useless for in-kernel drivers, so remove the use of it
> in the chipidea CI13XXX driver.
> 
> Cc: Peter Chen 
> Signed-off-by: Greg Kroah-Hartman 
> ---
>  drivers/usb/chipidea/ci_hdrc_pci.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/usb/chipidea/ci_hdrc_pci.c 
> b/drivers/usb/chipidea/ci_hdrc_pci.c
> index b635ab67490d..39414e4b2d81 100644
> --- a/drivers/usb/chipidea/ci_hdrc_pci.c
> +++ b/drivers/usb/chipidea/ci_hdrc_pci.c
> @@ -170,5 +170,4 @@ module_pci_driver(ci_hdrc_pci_driver);
>  MODULE_AUTHOR("MIPS - David Lopo ");
>  MODULE_DESCRIPTION("MIPS CI13XXX USB Peripheral Controller");
>  MODULE_LICENSE("GPL");
> -MODULE_VERSION("June 2008");
>  MODULE_ALIAS("platform:ci13xxx_pci");

Acked-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: USB 3.0 is broken on Odroid Xu4 on latest kernel

2017-07-19 Thread Krzysztof Kozlowski
On Wed, Jul 19, 2017 at 09:13:29PM +0300, Felipe Balbi wrote:
> 
> Hi,
> 
> Anand Moon  writes:
> > Hi Krzysztof,
> >
> > Today I tried to compile the latest kernel for Odroid xu4.
> > using exynos_defconfig I build and loaded the kernel.
> > but to my surprise usb 3.0 device and missing.
> >
> > odroid login: root
> > Password:
> > Last login: Wed Jul 19 14:01:44 UTC 2017 on ttySAC2
> > Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.13.0-rc1-xu4ml-27846-g74cbd96 
> > armv7l)
> 
> Dude, you have 27 thousand patches on top of v4.13-rc1??? Try vanilla
> v4.13-rc1 and try a git bisect.

Hi Anand,

Beside Felipe's comment, I do not have XU4. I cannot reproduce it on
XU3-Lite (but there is difference in USB2 and USB3, AFAIR).

$ uname -a
Linux odroidxu3 4.13.0-rc1-00071-ge06fdaf40a5c #1051 SMP PREEMPT Wed Jul 19 
22:07:41 CEST 2017 armv7l GNU/Linux
$ lsusb
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast 
Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Try to follow Felipe's advice of using vanilla kernel from Linus and
bisecting it.

Best regards,
Krzysztof

--
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/9] Bug fixes and improvements to Broadcom BDC driver

2017-07-19 Thread Al Cooper
V2 Changes:
- Add support for USB phys. We need to handle systems with either
  a single phy or systems with both a USB2.0 and USB3.0 phy
- Fixes to the dt-bindings document based on feedback from 
  Rob Herring. Changes include changing the compatible base
  name to "brcm,bdc" because "brcm,bdc-udc" seemed redundant
- Add proper suspend/resume support with clock control
- Split out code cleanup into separate patch

Bug fixes and improvements to the Broadcom USB STB BDC driver.

Al Cooper (8):
  usb: bdc: Fix misleading register names
  dt-bindings: usb: bdc: Add Device Tree binding for Broadcom UDC driver
  usb: bdc: Add clock enable for new chips with a separate BDC clock
  usb: bdc: Small code cleanup
  usb: bdc: Add support for suspend/resume
  usb: bdc: fix "xsf for ep not enabled" errror
  usb: bdc: Enable in Kconfig for ARCH_BRCMSTB systems
  usb: bdc: Add support for USB phy

Florian Fainelli (1):
  usb: bdc: hook a quick Device Tree compatible string

 Documentation/devicetree/bindings/usb/brcm,bdc.txt |  29 
 drivers/usb/gadget/udc/bdc/Kconfig |   1 +
 drivers/usb/gadget/udc/bdc/bdc.h   |  24 ++--
 drivers/usb/gadget/udc/bdc/bdc_core.c  | 148 +++--
 drivers/usb/gadget/udc/bdc/bdc_dbg.c   |  16 +--
 drivers/usb/gadget/udc/bdc/bdc_ep.c|   4 +-
 drivers/usb/gadget/udc/bdc/bdc_udc.c   |   7 +-
 7 files changed, 197 insertions(+), 32 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,bdc.txt

-- 
1.9.0.138.g2de3478

--
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/9] dt-bindings: usb: bdc: Add Device Tree binding for Broadcom UDC driver

2017-07-19 Thread Al Cooper
Add Device Tree binding document for Broadcom USB Device
Controller (BDC).

Signed-off-by: Al Cooper 
---
 Documentation/devicetree/bindings/usb/brcm,bdc.txt | 29 ++
 1 file changed, 29 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/brcm,bdc.txt

diff --git a/Documentation/devicetree/bindings/usb/brcm,bdc.txt 
b/Documentation/devicetree/bindings/usb/brcm,bdc.txt
new file mode 100644
index 000..63e63af
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/brcm,bdc.txt
@@ -0,0 +1,29 @@
+Broadcom USB Device Controller (BDC)
+
+
+Required properties:
+
+- compatible: must be one of:
+"brcm,bdc-v0.16"
+"brcm,bdc"
+- reg: the base register address and length
+- interrupts: the interrupt line for this controller
+
+Optional properties:
+
+On Broadcom STB platforms, these properties are required:
+
+- phys: phandle to one or two USB PHY blocks
+NOTE: Some SoC's have a single phy and some have
+USB 2.0 and USB 3.0 phys
+- clocks: phandle to the functional clock of this block
+
+Example:
+
+bdc@f0b02000 {
+compatible = "brcm,bdc-v0.16";
+reg = <0xf0b02000 0xfc4>;
+interrupts = <0x0 0x60 0x0>;
+phys = <_0 0x0>;
+clocks = <_usbd>;
+};
-- 
1.9.0.138.g2de3478

--
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/9] usb: bdc: Fix misleading register names

2017-07-19 Thread Al Cooper
The BDC endpoint status registers 0-7 were originally each going
to be an array of regsiters. This was later changed to being a
single register. The register definitions are being changed from:
"#define BDC_EPSTS0(n)  (0x60 + (n * 0x10))"
to
"#define BDC_EPSTS0 0x60"
to reflect this change and to avoid future coding mistakes.

Signed-off-by: Al Cooper 
---
 drivers/usb/gadget/udc/bdc/bdc.h | 16 
 drivers/usb/gadget/udc/bdc/bdc_dbg.c | 16 
 drivers/usb/gadget/udc/bdc/bdc_ep.c  |  4 ++--
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/gadget/udc/bdc/bdc.h b/drivers/usb/gadget/udc/bdc/bdc.h
index 916d471..3664808 100644
--- a/drivers/usb/gadget/udc/bdc/bdc.h
+++ b/drivers/usb/gadget/udc/bdc/bdc.h
@@ -83,14 +83,14 @@
 
 #define BDC_DVCSA  0x50
 #define BDC_DVCSB  0x54
-#define BDC_EPSTS0(n)  (0x60 + (n * 0x10))
-#define BDC_EPSTS1(n)  (0x64 + (n * 0x10))
-#define BDC_EPSTS2(n)  (0x68 + (n * 0x10))
-#define BDC_EPSTS3(n)  (0x6c + (n * 0x10))
-#define BDC_EPSTS4(n)  (0x70 + (n * 0x10))
-#define BDC_EPSTS5(n)  (0x74 + (n * 0x10))
-#define BDC_EPSTS6(n)  (0x78 + (n * 0x10))
-#define BDC_EPSTS7(n)  (0x7c + (n * 0x10))
+#define BDC_EPSTS0 0x60
+#define BDC_EPSTS1 0x64
+#define BDC_EPSTS2 0x68
+#define BDC_EPSTS3 0x6c
+#define BDC_EPSTS4 0x70
+#define BDC_EPSTS5 0x74
+#define BDC_EPSTS6 0x78
+#define BDC_EPSTS7 0x7c
 #define BDC_SRRBAL(n)  (0x200 + (n * 0x10))
 #define BDC_SRRBAH(n)  (0x204 + (n * 0x10))
 #define BDC_SRRINT(n)  (0x208 + (n * 0x10))
diff --git a/drivers/usb/gadget/udc/bdc/bdc_dbg.c 
b/drivers/usb/gadget/udc/bdc/bdc_dbg.c
index 5945dbc..ac98f6f 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_dbg.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_dbg.c
@@ -40,28 +40,28 @@ void bdc_dump_epsts(struct bdc *bdc)
 {
u32 temp;
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS0(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS0);
dev_vdbg(bdc->dev, "BDC_EPSTS0:0x%08x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS1(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS1);
dev_vdbg(bdc->dev, "BDC_EPSTS1:0x%x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS2(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS2);
dev_vdbg(bdc->dev, "BDC_EPSTS2:0x%08x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS3(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS3);
dev_vdbg(bdc->dev, "BDC_EPSTS3:0x%08x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS4(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS4);
dev_vdbg(bdc->dev, "BDC_EPSTS4:0x%08x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS5(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS5);
dev_vdbg(bdc->dev, "BDC_EPSTS5:0x%08x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS6(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS6);
dev_vdbg(bdc->dev, "BDC_EPSTS6:0x%08x\n", temp);
 
-   temp = bdc_readl(bdc->regs, BDC_EPSTS7(0));
+   temp = bdc_readl(bdc->regs, BDC_EPSTS7);
dev_vdbg(bdc->dev, "BDC_EPSTS7:0x%08x\n", temp);
 }
 
diff --git a/drivers/usb/gadget/udc/bdc/bdc_ep.c 
b/drivers/usb/gadget/udc/bdc/bdc_ep.c
index ff1ef24..bfd8f7a 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_ep.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_ep.c
@@ -777,9 +777,9 @@ static int ep_dequeue(struct bdc_ep *ep, struct bdc_req 
*req)
 */
 
/* The current hw dequeue pointer */
-   tmp_32 = bdc_readl(bdc->regs, BDC_EPSTS0(0));
+   tmp_32 = bdc_readl(bdc->regs, BDC_EPSTS0);
deq_ptr_64 = tmp_32;
-   tmp_32 = bdc_readl(bdc->regs, BDC_EPSTS1(0));
+   tmp_32 = bdc_readl(bdc->regs, BDC_EPSTS1);
deq_ptr_64 |= ((u64)tmp_32 << 32);
 
/* we have the dma addr of next bd that will be fetched by hardware */
-- 
1.9.0.138.g2de3478

--
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/9] usb: bdc: Small code cleanup

2017-07-19 Thread Al Cooper
Signed-off-by: Al Cooper 
---
 drivers/usb/gadget/udc/bdc/bdc_core.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c 
b/drivers/usb/gadget/udc/bdc/bdc_core.c
index dda7b43..c2bfae2 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_core.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
@@ -488,28 +488,29 @@ static int bdc_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, bdc);
bdc->irq = irq;
bdc->dev = dev;
-   dev_dbg(bdc->dev, "bdc->regs: %p irq=%d\n", bdc->regs, bdc->irq);
+   dev_dbg(dev, "bdc->regs: %p irq=%d\n", bdc->regs, bdc->irq);
 
temp = bdc_readl(bdc->regs, BDC_BDCCAP1);
if ((temp & BDC_P64) &&
!dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64))) {
-   dev_dbg(bdc->dev, "Using 64-bit address\n");
+   dev_dbg(dev, "Using 64-bit address\n");
} else {
-   ret = dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(32));
+   ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
if (ret) {
-   dev_err(bdc->dev, "No suitable DMA config available, 
abort\n");
+   dev_err(dev,
+   "No suitable DMA config available, abort\n");
return -ENOTSUPP;
}
-   dev_dbg(bdc->dev, "Using 32-bit address\n");
+   dev_dbg(dev, "Using 32-bit address\n");
}
ret = bdc_hw_init(bdc);
if (ret) {
-   dev_err(bdc->dev, "BDC init failure:%d\n", ret);
+   dev_err(dev, "BDC init failure:%d\n", ret);
return ret;
}
ret = bdc_udc_init(bdc);
if (ret) {
-   dev_err(bdc->dev, "BDC Gadget init failure:%d\n", ret);
+   dev_err(dev, "BDC Gadget init failure:%d\n", ret);
goto cleanup;
}
return 0;
-- 
1.9.0.138.g2de3478

--
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/9] usb: bdc: Add clock enable for new chips with a separate BDC clock

2017-07-19 Thread Al Cooper
Newer SoC's have added a BDC clock to the Device Tree, so get
and enable it.

Signed-off-by: Al Cooper 
Signed-off-by: Florian Fainelli 
---
 drivers/usb/gadget/udc/bdc/bdc_core.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c 
b/drivers/usb/gadget/udc/bdc/bdc_core.c
index e9bd8d4..dda7b43 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_core.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "bdc.h"
 #include "bdc_dbg.h"
@@ -452,8 +453,22 @@ static int bdc_probe(struct platform_device *pdev)
int irq;
u32 temp;
struct device *dev = >dev;
+   struct clk *clk;
 
dev_dbg(dev, "%s()\n", __func__);
+
+   clk = devm_clk_get(dev, "sw_usbd");
+   if (IS_ERR(clk)) {
+   dev_info(dev, "Clock not found in Device Tree\n");
+   clk = NULL;
+   }
+
+   ret = clk_prepare_enable(clk);
+   if (ret) {
+   dev_err(dev, "could not enable clock\n");
+   return ret;
+   }
+
bdc = devm_kzalloc(dev, sizeof(*bdc), GFP_KERNEL);
if (!bdc)
return -ENOMEM;
-- 
1.9.0.138.g2de3478

--
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/9] usb: bdc: hook a quick Device Tree compatible string

2017-07-19 Thread Al Cooper
From: Florian Fainelli 

Allows Device Tree probing

Signed-off-by: Florian Fainelli 
Signed-off-by: Al Cooper 
---
 drivers/usb/gadget/udc/bdc/bdc.h  | 4 ++--
 drivers/usb/gadget/udc/bdc/bdc_core.c | 8 
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/udc/bdc/bdc.h b/drivers/usb/gadget/udc/bdc/bdc.h
index 3664808..f657a4e 100644
--- a/drivers/usb/gadget/udc/bdc/bdc.h
+++ b/drivers/usb/gadget/udc/bdc/bdc.h
@@ -27,8 +27,8 @@
 #include 
 #include 
 
-#define BRCM_BDC_NAME "bdc_usb3"
-#define BRCM_BDC_DESC "BDC device controller driver"
+#define BRCM_BDC_NAME "bdc"
+#define BRCM_BDC_DESC "Broadcom USB Device Controller driver"
 
 #define DMA_ADDR_INVALID(~(dma_addr_t)0)
 
diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c 
b/drivers/usb/gadget/udc/bdc/bdc_core.c
index c2bfae2..bc0729b 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_core.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
@@ -533,9 +533,17 @@ static int bdc_remove(struct platform_device *pdev)
return 0;
 }
 
+static const struct of_device_id bdc_of_match[] = {
+   { .compatible = "brcm,bdc-v0.16" },
+   { .compatible = "brcm,bdc" },
+   { /* sentinel */ }
+};
+
 static struct platform_driver bdc_driver = {
.driver = {
.name   = BRCM_BDC_NAME,
+   .owner  = THIS_MODULE,
+   .of_match_table = bdc_of_match,
},
.probe  = bdc_probe,
.remove = bdc_remove,
-- 
1.9.0.138.g2de3478

--
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 7/9] usb: bdc: fix "xsf for ep not enabled" errror

2017-07-19 Thread Al Cooper
This patch essentially clears the port status change bits at the
correct times. It is necessary because the driver was not handling
the change bits correctly for events during device
connection/disconnection and bus enumeration. So, one of them (PCC)
was left stuck sometimes causing the "xsf for ep not enabled"
error we get on first connection. This was found by the Android team.
This was debugged and fixed by Sasi Kumar.

Signed-off-by: Al Cooper 
---
 drivers/usb/gadget/udc/bdc/bdc_udc.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/udc/bdc/bdc_udc.c 
b/drivers/usb/gadget/udc/bdc/bdc_udc.c
index aae7458..c843461 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_udc.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_udc.c
@@ -249,6 +249,7 @@ void bdc_sr_uspc(struct bdc *bdc, struct bdc_sr *sreport)
disconn = true;
else if ((uspc & BDC_PCS) && !BDC_PST(uspc))
connected = true;
+   clear_flags |= BDC_PCC;
}
 
/* Change in VBus and VBus is present */
@@ -259,16 +260,16 @@ void bdc_sr_uspc(struct bdc *bdc, struct bdc_sr *sreport)
bdc_softconn(bdc);
usb_gadget_set_state(>gadget, USB_STATE_POWERED);
}
-   clear_flags = BDC_VBC;
+   clear_flags |= BDC_VBC;
} else if ((uspc & BDC_PRS) || (uspc & BDC_PRC) || disconn) {
/* Hot reset, warm reset, 2.0 bus reset or disconn */
dev_dbg(bdc->dev, "Port reset or disconn\n");
bdc_uspc_disconnected(bdc, disconn);
-   clear_flags = BDC_PCC|BDC_PCS|BDC_PRS|BDC_PRC;
+   clear_flags |= BDC_PRC;
} else if ((uspc & BDC_PSC) && (uspc & BDC_PCS)) {
/* Change in Link state */
handle_link_state_change(bdc, uspc);
-   clear_flags = BDC_PSC|BDC_PCS;
+   clear_flags |= BDC_PSC;
}
 
/*
-- 
1.9.0.138.g2de3478

--
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 9/9] usb: bdc: Add support for USB phy

2017-07-19 Thread Al Cooper
If a phy is specified in the device tree node, get it and use it.
This was based on a patch by:
"Srinath Mannam "

Signed-off-by: Al Cooper 
---
 drivers/usb/gadget/udc/bdc/bdc.h  |  3 ++
 drivers/usb/gadget/udc/bdc/bdc_core.c | 74 ++-
 2 files changed, 75 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/udc/bdc/bdc.h b/drivers/usb/gadget/udc/bdc/bdc.h
index 67c5f23..6df0352 100644
--- a/drivers/usb/gadget/udc/bdc/bdc.h
+++ b/drivers/usb/gadget/udc/bdc/bdc.h
@@ -413,6 +413,9 @@ struct bdc {
/* device lock */
spinlock_t  lock;
 
+   /* generic phy */
+   struct phy  **phys;
+   int num_phys;
/* num of endpoints for a particular instantiation of IP */
unsigned int num_eps;
/*
diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c 
b/drivers/usb/gadget/udc/bdc/bdc_core.c
index 2690b6f..7a8af4b 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_core.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -445,6 +446,43 @@ static int bdc_hw_init(struct bdc *bdc)
return 0;
 }
 
+static int bdc_phy_init(struct bdc *bdc)
+{
+   int phy_num;
+   int ret;
+
+   for (phy_num = 0; phy_num < bdc->num_phys; phy_num++) {
+   ret = phy_init(bdc->phys[phy_num]);
+   if (ret)
+   goto err_exit_phy;
+   ret = phy_power_on(bdc->phys[phy_num]);
+   if (ret) {
+   phy_exit(bdc->phys[phy_num]);
+   goto err_exit_phy;
+   }
+   }
+
+   return 0;
+
+err_exit_phy:
+   while (--phy_num >= 0) {
+   phy_power_off(bdc->phys[phy_num]);
+   phy_exit(bdc->phys[phy_num]);
+   }
+
+   return ret;
+}
+
+static void bdc_phy_exit(struct bdc *bdc)
+{
+   int phy_num;
+
+   for (phy_num = 0; phy_num < bdc->num_phys; phy_num++) {
+   phy_power_off(bdc->phys[phy_num]);
+   phy_exit(bdc->phys[phy_num]);
+   }
+}
+
 static int bdc_probe(struct platform_device *pdev)
 {
struct bdc *bdc;
@@ -454,6 +492,7 @@ static int bdc_probe(struct platform_device *pdev)
u32 temp;
struct device *dev = >dev;
struct clk *clk;
+   int phy_num;
 
dev_dbg(dev, "%s()\n", __func__);
 
@@ -492,6 +531,35 @@ static int bdc_probe(struct platform_device *pdev)
bdc->dev = dev;
dev_dbg(dev, "bdc->regs: %p irq=%d\n", bdc->regs, bdc->irq);
 
+   bdc->num_phys = of_count_phandle_with_args(dev->of_node,
+   "phys", "#phy-cells");
+   if (bdc->num_phys > 0) {
+   bdc->phys = devm_kcalloc(dev, bdc->num_phys,
+   sizeof(struct phy *), GFP_KERNEL);
+   if (!bdc->phys)
+   return -ENOMEM;
+   } else {
+   bdc->num_phys = 0;
+   }
+   dev_info(dev, "Using %d phy(s)\n", bdc->num_phys);
+
+   for (phy_num = 0; phy_num < bdc->num_phys; phy_num++) {
+   bdc->phys[phy_num] = devm_of_phy_get_by_index(
+   dev, dev->of_node, phy_num);
+   if (IS_ERR(bdc->phys[phy_num])) {
+   ret = PTR_ERR(bdc->phys[phy_num]);
+   dev_err(bdc->dev,
+   "BDC phy specified but not found:%d\n", ret);
+   return ret;
+   }
+   }
+
+   ret = bdc_phy_init(bdc);
+   if (ret) {
+   dev_err(bdc->dev, "BDC phy init failure:%d\n", ret);
+   return ret;
+   }
+
temp = bdc_readl(bdc->regs, BDC_BDCCAP1);
if ((temp & BDC_P64) &&
!dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64))) {
@@ -508,7 +576,7 @@ static int bdc_probe(struct platform_device *pdev)
ret = bdc_hw_init(bdc);
if (ret) {
dev_err(dev, "BDC init failure:%d\n", ret);
-   return ret;
+   goto phycleanup;
}
ret = bdc_udc_init(bdc);
if (ret) {
@@ -519,7 +587,8 @@ static int bdc_probe(struct platform_device *pdev)
 
 cleanup:
bdc_hw_exit(bdc);
-
+phycleanup:
+   bdc_phy_exit(bdc);
return ret;
 }
 
@@ -531,6 +600,7 @@ static int bdc_remove(struct platform_device *pdev)
dev_dbg(bdc->dev, "%s ()\n", __func__);
bdc_udc_exit(bdc);
bdc_hw_exit(bdc);
+   bdc_phy_exit(bdc);
clk_disable_unprepare(bdc->clk);
return 0;
 }
-- 
1.9.0.138.g2de3478

--
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/9] usb: bdc: Add support for suspend/resume

2017-07-19 Thread Al Cooper
Based on a previous commit by Danesh Petigara 
that added resume to solve the following problem:
"The BDC driver will fail after resuming from S3 suspend and this
will cause any upper layer gadget driver to fail."
This commit also adds support for suspend and manages the clock during
suspend/resume.

Signed-off-by: Al Cooper 
---
 drivers/usb/gadget/udc/bdc/bdc.h  |  1 +
 drivers/usb/gadget/udc/bdc/bdc_core.c | 36 +++
 2 files changed, 37 insertions(+)

diff --git a/drivers/usb/gadget/udc/bdc/bdc.h b/drivers/usb/gadget/udc/bdc/bdc.h
index f657a4e..67c5f23 100644
--- a/drivers/usb/gadget/udc/bdc/bdc.h
+++ b/drivers/usb/gadget/udc/bdc/bdc.h
@@ -454,6 +454,7 @@ struct bdc {
 * Func Wake packet every 2.5 secs. Refer to USB3 spec section 8.5.6.4
 */
struct delayed_work func_wake_notify;
+   struct clk  *clk;
 };
 
 static inline u32 bdc_readl(void __iomem *base, u32 offset)
diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c 
b/drivers/usb/gadget/udc/bdc/bdc_core.c
index bc0729b..2690b6f 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_core.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
@@ -473,6 +473,8 @@ static int bdc_probe(struct platform_device *pdev)
if (!bdc)
return -ENOMEM;
 
+   bdc->clk = clk;
+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
bdc->regs = devm_ioremap_resource(dev, res);
if (IS_ERR(bdc->regs)) {
@@ -529,10 +531,43 @@ static int bdc_remove(struct platform_device *pdev)
dev_dbg(bdc->dev, "%s ()\n", __func__);
bdc_udc_exit(bdc);
bdc_hw_exit(bdc);
+   clk_disable_unprepare(bdc->clk);
+   return 0;
+}
+
+#ifdef CONFIG_PM_SLEEP
+static int bdc_suspend(struct device *dev)
+{
+   struct bdc *bdc = dev_get_drvdata(dev);
+
+   clk_disable_unprepare(bdc->clk);
+   return 0;
+}
+
+static int bdc_resume(struct device *dev)
+{
+   struct bdc *bdc = dev_get_drvdata(dev);
+   int ret;
+
+   ret = clk_prepare_enable(bdc->clk);
+   if (ret) {
+   dev_err(bdc->dev, "err enabling the clock\n");
+   return ret;
+   }
+   ret = bdc_reinit(bdc);
+   if (ret) {
+   dev_err(bdc->dev, "err in bdc reinit\n");
+   return ret;
+   }
 
return 0;
 }
 
+#endif /* CONFIG_PM_SLEEP */
+
+static SIMPLE_DEV_PM_OPS(bdc_pm_ops, bdc_suspend,
+   bdc_resume);
+
 static const struct of_device_id bdc_of_match[] = {
{ .compatible = "brcm,bdc-v0.16" },
{ .compatible = "brcm,bdc" },
@@ -543,6 +578,7 @@ static int bdc_remove(struct platform_device *pdev)
.driver = {
.name   = BRCM_BDC_NAME,
.owner  = THIS_MODULE,
+   .pm = _pm_ops,
.of_match_table = bdc_of_match,
},
.probe  = bdc_probe,
-- 
1.9.0.138.g2de3478

--
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 8/9] usb: bdc: Enable in Kconfig for ARCH_BRCMSTB systems

2017-07-19 Thread Al Cooper
Many ARM based Broadcom STB SoC's have a USB BDC controller so
enable this driver for these systems.

Signed-off-by: Al Cooper 
---
 drivers/usb/gadget/udc/bdc/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/gadget/udc/bdc/Kconfig 
b/drivers/usb/gadget/udc/bdc/Kconfig
index eb8b553..c74ac25 100644
--- a/drivers/usb/gadget/udc/bdc/Kconfig
+++ b/drivers/usb/gadget/udc/bdc/Kconfig
@@ -1,6 +1,7 @@
 config USB_BDC_UDC
tristate "Broadcom USB3.0 device controller IP driver(BDC)"
depends on USB_GADGET && HAS_DMA
+   default ARCH_BRCMSTB
 
help
BDC is Broadcom's USB3.0 device controller IP. If your SOC has a BDC IP
-- 
1.9.0.138.g2de3478

--
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 3.0 is broken on Odroid Xu4 on latest kernel

2017-07-19 Thread Felipe Balbi

Hi,

Anand Moon  writes:
> Hi Krzysztof,
>
> Today I tried to compile the latest kernel for Odroid xu4.
> using exynos_defconfig I build and loaded the kernel.
> but to my surprise usb 3.0 device and missing.
>
> odroid login: root
> Password:
> Last login: Wed Jul 19 14:01:44 UTC 2017 on ttySAC2
> Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.13.0-rc1-xu4ml-27846-g74cbd96 
> armv7l)

Dude, you have 27 thousand patches on top of v4.13-rc1??? Try vanilla
v4.13-rc1 and try a git bisect.

-- 
balbi
--
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 v2 1/3] mux: Add mux_control_get_optional() API

2017-07-19 Thread Stephen Boyd
Quoting Peter Rosin (2017-07-19 00:15:38)
> On 2017-07-19 04:08, Stephen Boyd wrote:
> > Quoting Peter Rosin (2017-07-17 01:20:14)
> >> On 2017-07-14 23:40, Stephen Boyd wrote:
> >>> @@ -441,6 +447,8 @@ struct mux_control *mux_control_get(struct device 
> >>> *dev, const char *mux_name)
> >>>   if (mux_name) {
> >>>   index = of_property_match_string(np, "mux-control-names",
> >>>mux_name);
> >>> + if (index == -EINVAL && optional)
> >>> + return NULL;
> >>
> >> What about -ENODATA?
> > 
> > At this point in the code we're finding the index of a mux-control-names
> > property so I was trying to handle the case where there isn't a
> > mux-control-names property at all
> 
> Yes, you indeed need to check for -EINVAL to catch that. No argument
> about that.

Ok.

> 
> >   but we're looking for something
> > optional anyway. If there is a property, then we would see some other
> > error if something went wrong and then pass the error up. There is a
> > hole where there isn't a mux-control-names property and we're looking
> > for something that's optional, but there is a mux-control property. Do
> > we care though? The DT seems broken then.
> 
> I was thinking about the case where mux-control-names names *other* muxes
> but not the one asked for in this call. That's not broken and should be
> handled. The way I read it, you get -ENODATA in that case?

Yes that would return -ENODATA. Similarly, it would be returned if we
had a boolean mux-control-names property (which is completely broken).

> 
> >> And if an optional mux is found here, but lookup
> >> fails later in e.g. the of_parse_phandle_with_args call, then I think
> >> an error should be returned. Because that seems like an indication that
> >> DT specifies that there *should* be a mux, but then there isn't one.
> > 
> > of_parse_phandle_with_args() would return ENOENT when there isn't a
> > mux-control property in DT. So I've trapped that case and returned an
> > "optional mux" pointer of NULL. I think we handle the case you mention,
> > where some index is found but it returns an error, because that would
> > return some error besides -ENOENT.
> > 
> > Sorry, I'm not really following what you're suggesting. Maybe it got
> > mixed up with the NULL vs. non-NULL return value from mux_control_get().
> 
> What I mean is that if you have passed a mux_name and the index of that
> name was indeed found in the of_property_match_string call, then any
> failure from of_parse_phandle_with_args indicates a bad DT and should
> IMO result in an error. I.e., when evaluating the result from
> of_parse_phandle_with_args, you should account for the optional param
> if and only if mux_name is NULL.
> 
> You can do that by e.g. setting optional to false after looking up the
> mux_name index (because at that point the mux is no longer considered
> optional). E.g. as the last statement in the if (!mux_name) block.
> 

Ok got it. I'll rework the logic.
--
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 v7 0/4] reset: APIs to manage a list of resets

2017-07-19 Thread Philipp Zabel
A set of patches to allow consumers to get and de/assert or trigger
a number of resets at the same time. A patch on top of Vivek's original
API extension is added to hide the reset_control_array behind a struct
reset_control so that the consumer doesn't have to care about the difference
between a singular reset control and a reset control controlling an array
of resets, except when requesting it.

This series also contains reset controls patches for dwc3-of-simple
and tegra pmc drivers.
A small patch is added in this series to correctly re-order the
resource handling in dwc3_of_simple_remove().

The series is tested on torvald's master branch the device tree
patches to enable usb on db820c.

Changes since v6:
 - Removed leftover reset_control_array_put stub.

Changes since v5:
 - Fixed devm/of_reset_control_array_get stub return values in the
   "reset: hide reset control arrays behind struct reset_control" patch.
 - Merged "reset: hide reset control arrays behind struct reset_control" patch
   into "reset: Add APIs to manage array of resets" patch, to avoid adding
   new API functions in one patch that are removed in the other.
 - Updated commit message of "soc/tegra: pmc: Use the new reset APIs to manage
   reset controllers" patch.
 - Dropped already merged "reset: use kref for reference counting" patch.

Changes since v4:
 - Added a patch to hide reset control arrays behind struct reset_control
   and adapted the consumer patches. This could be merged with the reset
   array API patch if we think this is a good idea.

Changes since v3:
 - Squashed of_reset_control_get_count() patch in the second patch that
   adds the reset control array APIs.
 - The error path after getting count through of_reset_control_get_count()
   now returns NULL pointer in case when 'optional' flag is true.
 - Added code in reset_control_array_assert() to deassert the
   already asserted resets in the error case.
 - Using of_reset_control_array_get_optional_exclusive() in dwc3 patch
   to request the reset control array.
 - Added a patch to fix the order in which resources are handled in
   dwc3_of_simple_remove() path.
 - Added tegra_powergate->reset to take care of single reset control
   passed from the client drivers.

Changes since v2:
 - Addressed comments to make APIs inline with gpiod API.
 - Moved number of reset controls in 'struct reset_control_array'
   so that the footprint is reduced.
 - of_reset_control_array_get() and devm_reset_control_array_get()
   now return pointer to the newly created reset control array.
 - Added comments to mention that the reset control array APIs don't
   guarantee any particular order when handling the reset controls.
 - Dropped 'name' from reset_control_array' since the interface is meant
   for a bunch of anonymous resets that can all be asserted or deasserted
   in arbitrary order.
 - Fixed returns for APIs reported by kbuild.
 - Fixed 'for' clause guards reported by kbuild.

Changes since v1:
 - Addressed comment for error handling in of_reset_control_get_count()
 - Added patch to manage reset controller array.
 - Rebased dwc3-of-simple changes based on the new set of APIs
   for reset control array.
 - Added a patch for soc/tegra/pmc driver to use the new set of
   reset control array APIs.

Vivek Gautam (4):
  reset: Add APIs to manage array of resets
  usb: dwc3: of-simple: Re-order resource handling in remove
  usb: dwc3: of-simple: Add support to get resets for the device
  soc/tegra: pmc: Use the new reset APIs to manage reset controllers

 drivers/reset/core.c  | 211 +-
 drivers/soc/tegra/pmc.c   |  82 ---
 drivers/usb/dwc3/dwc3-of-simple.c |  29 +-
 include/linux/reset.h |  68 
 4 files changed, 324 insertions(+), 66 deletions(-)

-- 
2.11.0

--
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 v7 3/4] usb: dwc3: of-simple: Add support to get resets for the device

2017-07-19 Thread Philipp Zabel
From: Vivek Gautam 

Add support to get a list of resets available for the device.
These resets must be kept de-asserted until the device is
in use.

Cc: Felipe Balbi 
Signed-off-by: Vivek Gautam 
[p.za...@pengutronix.de: switch to hidden reset control array]
Signed-off-by: Philipp Zabel 
---
No changes since v6.
---
 drivers/usb/dwc3/dwc3-of-simple.c | 27 +--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-of-simple.c 
b/drivers/usb/dwc3/dwc3-of-simple.c
index a9bac09d3750d..23d2221bde9df 100644
--- a/drivers/usb/dwc3/dwc3-of-simple.c
+++ b/drivers/usb/dwc3/dwc3-of-simple.c
@@ -29,11 +29,13 @@
 #include 
 #include 
 #include 
+#include 
 
 struct dwc3_of_simple {
struct device   *dev;
struct clk  **clks;
int num_clocks;
+   struct reset_control*resets;
 };
 
 static int dwc3_of_simple_clk_init(struct dwc3_of_simple *simple, int count)
@@ -96,9 +98,20 @@ static int dwc3_of_simple_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, simple);
simple->dev = dev;
 
+   simple->resets = of_reset_control_array_get_optional_exclusive(np);
+   if (IS_ERR(simple->resets)) {
+   ret = PTR_ERR(simple->resets);
+   dev_err(dev, "failed to get device resets, err=%d\n", ret);
+   return ret;
+   }
+
+   ret = reset_control_deassert(simple->resets);
+   if (ret)
+   goto err_resetc_put;
+
ret = dwc3_of_simple_clk_init(simple, of_clk_get_parent_count(np));
if (ret)
-   return ret;
+   goto err_resetc_assert;
 
ret = of_platform_populate(np, NULL, NULL, dev);
if (ret) {
@@ -107,7 +120,7 @@ static int dwc3_of_simple_probe(struct platform_device 
*pdev)
clk_put(simple->clks[i]);
}
 
-   return ret;
+   goto err_resetc_assert;
}
 
pm_runtime_set_active(dev);
@@ -115,6 +128,13 @@ static int dwc3_of_simple_probe(struct platform_device 
*pdev)
pm_runtime_get_sync(dev);
 
return 0;
+
+err_resetc_assert:
+   reset_control_assert(simple->resets);
+
+err_resetc_put:
+   reset_control_put(simple->resets);
+   return ret;
 }
 
 static int dwc3_of_simple_remove(struct platform_device *pdev)
@@ -130,6 +150,9 @@ static int dwc3_of_simple_remove(struct platform_device 
*pdev)
clk_put(simple->clks[i]);
}
 
+   reset_control_assert(simple->resets);
+   reset_control_put(simple->resets);
+
pm_runtime_put_sync(dev);
pm_runtime_disable(dev);
 
-- 
2.11.0

--
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 v7 2/4] usb: dwc3: of-simple: Re-order resource handling in remove

2017-07-19 Thread Philipp Zabel
From: Vivek Gautam 

Move clock handling after of_platform_depopulate to achieve
a sequence that is reverse of the probe sequence.

Cc: Felipe Balbi 
Signed-off-by: Vivek Gautam 
---
No changes since v6.
---
 drivers/usb/dwc3/dwc3-of-simple.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-of-simple.c 
b/drivers/usb/dwc3/dwc3-of-simple.c
index fe414e7a9c78c..a9bac09d3750d 100644
--- a/drivers/usb/dwc3/dwc3-of-simple.c
+++ b/drivers/usb/dwc3/dwc3-of-simple.c
@@ -123,13 +123,13 @@ static int dwc3_of_simple_remove(struct platform_device 
*pdev)
struct device   *dev = >dev;
int i;
 
+   of_platform_depopulate(dev);
+
for (i = 0; i < simple->num_clocks; i++) {
clk_disable_unprepare(simple->clks[i]);
clk_put(simple->clks[i]);
}
 
-   of_platform_depopulate(dev);
-
pm_runtime_put_sync(dev);
pm_runtime_disable(dev);
 
-- 
2.11.0

--
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 v7 1/4] reset: Add APIs to manage array of resets

2017-07-19 Thread Philipp Zabel
From: Vivek Gautam 

Many devices may want to request a bunch of resets and control them. So
it's better to manage them as an array. Add APIs to _get() an array of
reset_control, reusing the _assert(), _deassert(), and _reset() APIs for
single reset controls. Since reset controls already may control multiple
reset lines with a single hardware bit, from the user perspective, reset
control arrays are not at all different from single reset controls.
Note that these APIs don't guarantee that the reset lines managed in the
array are handled in any particular order.

Cc: Felipe Balbi 
Cc: Jon Hunter 
Signed-off-by: Vivek Gautam 
[p.za...@pengutronix.de: changed API to hide reset control arrays behind
 struct reset_control]
Signed-off-by: Philipp Zabel 
---
Changes since v6:
 - Removed leftover reset_control_array_put stub.
---
 drivers/reset/core.c  | 211 +-
 include/linux/reset.h |  68 
 2 files changed, 278 insertions(+), 1 deletion(-)

diff --git a/drivers/reset/core.c b/drivers/reset/core.c
index 0090784ff4105..c8fb4426b218a 100644
--- a/drivers/reset/core.c
+++ b/drivers/reset/core.c
@@ -43,11 +43,24 @@ struct reset_control {
unsigned int id;
struct kref refcnt;
bool shared;
+   bool array;
atomic_t deassert_count;
atomic_t triggered_count;
 };
 
 /**
+ * struct reset_control_array - an array of reset controls
+ * @base: reset control for compatibility with reset control API functions
+ * @num_rstcs: number of reset controls
+ * @rstc: array of reset controls
+ */
+struct reset_control_array {
+   struct reset_control base;
+   unsigned int num_rstcs;
+   struct reset_control *rstc[];
+};
+
+/**
  * of_reset_simple_xlate - translate reset_spec to the reset line number
  * @rcdev: a pointer to the reset controller device
  * @reset_spec: reset line specifier as found in the device tree
@@ -135,6 +148,65 @@ int devm_reset_controller_register(struct device *dev,
 }
 EXPORT_SYMBOL_GPL(devm_reset_controller_register);
 
+static inline struct reset_control_array *
+rstc_to_array(struct reset_control *rstc) {
+   return container_of(rstc, struct reset_control_array, base);
+}
+
+static int reset_control_array_reset(struct reset_control_array *resets)
+{
+   int ret, i;
+
+   for (i = 0; i < resets->num_rstcs; i++) {
+   ret = reset_control_reset(resets->rstc[i]);
+   if (ret)
+   return ret;
+   }
+
+   return 0;
+}
+
+static int reset_control_array_assert(struct reset_control_array *resets)
+{
+   int ret, i;
+
+   for (i = 0; i < resets->num_rstcs; i++) {
+   ret = reset_control_assert(resets->rstc[i]);
+   if (ret)
+   goto err;
+   }
+
+   return 0;
+
+err:
+   while (i--)
+   reset_control_deassert(resets->rstc[i]);
+   return ret;
+}
+
+static int reset_control_array_deassert(struct reset_control_array *resets)
+{
+   int ret, i;
+
+   for (i = 0; i < resets->num_rstcs; i++) {
+   ret = reset_control_deassert(resets->rstc[i]);
+   if (ret)
+   goto err;
+   }
+
+   return 0;
+
+err:
+   while (i--)
+   reset_control_assert(resets->rstc[i]);
+   return ret;
+}
+
+static inline bool reset_control_is_array(struct reset_control *rstc)
+{
+   return rstc->array;
+}
+
 /**
  * reset_control_reset - reset the controlled device
  * @rstc: reset controller
@@ -158,6 +230,9 @@ int reset_control_reset(struct reset_control *rstc)
if (WARN_ON(IS_ERR(rstc)))
return -EINVAL;
 
+   if (reset_control_is_array(rstc))
+   return reset_control_array_reset(rstc_to_array(rstc));
+
if (!rstc->rcdev->ops->reset)
return -ENOTSUPP;
 
@@ -202,6 +277,9 @@ int reset_control_assert(struct reset_control *rstc)
if (WARN_ON(IS_ERR(rstc)))
return -EINVAL;
 
+   if (reset_control_is_array(rstc))
+   return reset_control_array_assert(rstc_to_array(rstc));
+
if (!rstc->rcdev->ops->assert)
return -ENOTSUPP;
 
@@ -240,6 +318,9 @@ int reset_control_deassert(struct reset_control *rstc)
if (WARN_ON(IS_ERR(rstc)))
return -EINVAL;
 
+   if (reset_control_is_array(rstc))
+   return reset_control_array_deassert(rstc_to_array(rstc));
+
if (!rstc->rcdev->ops->deassert)
return -ENOTSUPP;
 
@@ -266,7 +347,7 @@ int reset_control_status(struct reset_control *rstc)
if (!rstc)
return 0;
 
-   if (WARN_ON(IS_ERR(rstc)))
+   if (WARN_ON(IS_ERR(rstc)) || reset_control_is_array(rstc))
return -EINVAL;
 
if (rstc->rcdev->ops->status)
@@ -404,6 +485,16 @@ struct 

[PATCH v7 4/4] soc/tegra: pmc: Use the new reset APIs to manage reset controllers

2017-07-19 Thread Philipp Zabel
From: Vivek Gautam 

Make use of of_reset_control_array_get_exclusive() to manage
an array of reset controllers available with the device.

Cc: Jon Hunter 
Cc: Thierry Reding 
Signed-off-by: Vivek Gautam 
[p.za...@pengutronix.de: switch to hidden reset control array]
Signed-off-by: Philipp Zabel 
---
No changes since v6.
---
 drivers/soc/tegra/pmc.c | 82 -
 1 file changed, 20 insertions(+), 62 deletions(-)

diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
index e233dd5dcab3d..749b218147a19 100644
--- a/drivers/soc/tegra/pmc.c
+++ b/drivers/soc/tegra/pmc.c
@@ -124,8 +124,7 @@ struct tegra_powergate {
unsigned int id;
struct clk **clks;
unsigned int num_clks;
-   struct reset_control **resets;
-   unsigned int num_resets;
+   struct reset_control *reset;
 };
 
 struct tegra_io_pad_soc {
@@ -348,32 +347,14 @@ static int tegra_powergate_enable_clocks(struct 
tegra_powergate *pg)
return err;
 }
 
-static int tegra_powergate_reset_assert(struct tegra_powergate *pg)
+static inline int tegra_powergate_reset_assert(struct tegra_powergate *pg)
 {
-   unsigned int i;
-   int err;
-
-   for (i = 0; i < pg->num_resets; i++) {
-   err = reset_control_assert(pg->resets[i]);
-   if (err)
-   return err;
-   }
-
-   return 0;
+   return reset_control_assert(pg->reset);
 }
 
-static int tegra_powergate_reset_deassert(struct tegra_powergate *pg)
+static inline int tegra_powergate_reset_deassert(struct tegra_powergate *pg)
 {
-   unsigned int i;
-   int err;
-
-   for (i = 0; i < pg->num_resets; i++) {
-   err = reset_control_deassert(pg->resets[i]);
-   if (err)
-   return err;
-   }
-
-   return 0;
+   return reset_control_deassert(pg->reset);
 }
 
 static int tegra_powergate_power_up(struct tegra_powergate *pg,
@@ -566,8 +547,7 @@ int tegra_powergate_sequence_power_up(unsigned int id, 
struct clk *clk,
pg.id = id;
pg.clks = 
pg.num_clks = 1;
-   pg.resets = 
-   pg.num_resets = 1;
+   pg.reset = IS_ERR(rst) ? NULL : rst;
 
err = tegra_powergate_power_up(, false);
if (err)
@@ -755,45 +735,26 @@ static int tegra_powergate_of_get_clks(struct 
tegra_powergate *pg,
 static int tegra_powergate_of_get_resets(struct tegra_powergate *pg,
 struct device_node *np, bool off)
 {
-   struct reset_control *rst;
-   unsigned int i, count;
int err;
 
-   count = of_count_phandle_with_args(np, "resets", "#reset-cells");
-   if (count == 0)
-   return -ENODEV;
-
-   pg->resets = kcalloc(count, sizeof(rst), GFP_KERNEL);
-   if (!pg->resets)
-   return -ENOMEM;
-
-   for (i = 0; i < count; i++) {
-   pg->resets[i] = of_reset_control_get_by_index(np, i);
-   if (IS_ERR(pg->resets[i])) {
-   err = PTR_ERR(pg->resets[i]);
-   goto error;
-   }
-
-   if (off)
-   err = reset_control_assert(pg->resets[i]);
-   else
-   err = reset_control_deassert(pg->resets[i]);
-
-   if (err) {
-   reset_control_put(pg->resets[i]);
-   goto error;
-   }
+   pg->reset = of_reset_control_array_get_exclusive(np);
+   if (IS_ERR(pg->reset)) {
+   pr_err("failed to get device resets\n");
+   return PTR_ERR(pg->reset);
}
 
-   pg->num_resets = count;
+   if (off)
+   err = reset_control_assert(pg->reset);
+   else
+   err = reset_control_deassert(pg->reset);
 
-   return 0;
+   if (err)
+   goto put_reset;
 
-error:
-   while (i--)
-   reset_control_put(pg->resets[i]);
+   return 0;
 
-   kfree(pg->resets);
+put_reset:
+   reset_control_put(pg->reset);
 
return err;
 }
@@ -885,10 +846,7 @@ static void tegra_powergate_add(struct tegra_pmc *pmc, 
struct device_node *np)
pm_genpd_remove(>genpd);
 
 remove_resets:
-   while (pg->num_resets--)
-   reset_control_put(pg->resets[pg->num_resets]);
-
-   kfree(pg->resets);
+   reset_control_put(pg->reset);
 
 remove_clks:
while (pg->num_clks--)
-- 
2.11.0

--
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 086/102] usb: chipidea: msm: explicitly request exclusive reset control

2017-07-19 Thread Philipp Zabel
Commit a53e35db70d1 ("reset: Ensure drivers are explicit when requesting
reset lines") started to transition the reset control request API calls
to explicitly state whether the driver needs exclusive or shared reset
control behavior. Convert all drivers requesting exclusive resets to the
explicit API call so the temporary transition helpers can be removed.

No functional changes.

Cc: Peter Chen 
Cc: Greg Kroah-Hartman 
Cc: linux-usb@vger.kernel.org
Signed-off-by: Philipp Zabel 
---
 drivers/usb/chipidea/ci_hdrc_msm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c 
b/drivers/usb/chipidea/ci_hdrc_msm.c
index 0bdfcdcbf7a5a..0cee09192d946 100644
--- a/drivers/usb/chipidea/ci_hdrc_msm.c
+++ b/drivers/usb/chipidea/ci_hdrc_msm.c
@@ -197,7 +197,7 @@ static int ci_hdrc_msm_probe(struct platform_device *pdev)
  CI_HDRC_OVERRIDE_PHY_CONTROL;
ci->pdata.notify_event = ci_hdrc_msm_notify_event;
 
-   reset = devm_reset_control_get(>dev, "core");
+   reset = devm_reset_control_get_exclusive(>dev, "core");
if (IS_ERR(reset))
return PTR_ERR(reset);
 
-- 
2.11.0

--
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 v4] usb:gadget:hid: {GET,SET} PROTOCOL Support

2017-07-19 Thread Abdulhadi Mohamed
The current f_hid driver doesn't handle GET_PROCOTOL and 
SET_PROCOTOL requests, which are required to operate HID
gadgets in BOOT mode. This patch implements this feature for 
devices that have the same implementation for REPORT and BOOT mode 
so that these devices are recognized by older BIOSes.


Signed-off-by: Abdulhadi Mohamed 

---
V4: Replaced patch message to correctly describe changes and 
added descriptions about previous revisions
v3: Fixed formatting/whitespace errors using checkpatch.pl
v2: Added HID protocol macros for clarity as per Alan's suggestions
Removed unnessecary code related to remote wakeup call 
Removed goto stall for handling set_protocol 
---
 drivers/usb/gadget/function/f_hid.c | 17 -
 include/linux/hid.h |  6 ++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/function/f_hid.c 
b/drivers/usb/gadget/function/f_hid.c
index 5eea448..c60b882 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c
@@ -44,6 +44,7 @@ struct f_hidg {
/* configuration */
unsigned char   bInterfaceSubClass;
unsigned char   bInterfaceProtocol;
+   unsigned char   protocol;
unsigned short  report_desc_length;
char*report_desc;
unsigned short  report_length;
@@ -527,7 +528,9 @@ static int hidg_setup(struct usb_function *f,
case ((USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8
  | HID_REQ_GET_PROTOCOL):
VDBG(cdev, "get_protocol\n");
-   goto stall;
+   length = min_t(unsigned int, length, 1);
+   ((u8 *) req->buf)[0] = hidg->protocol;
+   goto respond;
break;
 
case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8
@@ -539,6 +542,17 @@ static int hidg_setup(struct usb_function *f,
case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8
  | HID_REQ_SET_PROTOCOL):
VDBG(cdev, "set_protocol\n");
+   if (value > HID_REPORT_PROTOCOL)
+   goto stall;
+   length = 0;
+   /*
+* We assume that programs implementing the Boot protocol
+* are also compatible with the Report Protocol
+*/
+   if (hidg->bInterfaceSubClass == USB_INTERFACE_SUBCLASS_BOOT) {
+   hidg->protocol = value;
+   goto respond;
+   }
goto stall;
break;
 
@@ -768,6 +782,7 @@ static int hidg_bind(struct usb_configuration *c, struct 
usb_function *f)
/* set descriptor dynamic values */
hidg_interface_desc.bInterfaceSubClass = hidg->bInterfaceSubClass;
hidg_interface_desc.bInterfaceProtocol = hidg->bInterfaceProtocol;
+   hidg->protocol = HID_REPORT_PROTOCOL;
hidg_ss_in_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length);
hidg_ss_in_comp_desc.wBytesPerInterval =
cpu_to_le16(hidg->report_length);
diff --git a/include/linux/hid.h b/include/linux/hid.h
index b2ec827..29d06c8 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -347,6 +347,12 @@ struct hid_item {
 #define HID_GROUP_LOGITECH_DJ_DEVICE   0x0102
 
 /*
+ * HID protocol status
+ */
+#define HID_REPORT_PROTOCOL1
+#define HID_BOOT_PROTOCOL  0
+
+/*
  * This is the global environment of the parser. This information is
  * persistent for main-items. The global environment can be saved and
  * restored with PUSH/POP statements.
-- 
2.9.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 092/102] usb: phy: qcom-8x16-usb: explicitly request exclusive reset control

2017-07-19 Thread Philipp Zabel
Commit a53e35db70d1 ("reset: Ensure drivers are explicit when requesting
reset lines") started to transition the reset control request API calls
to explicitly state whether the driver needs exclusive or shared reset
control behavior. Convert all drivers requesting exclusive resets to the
explicit API call so the temporary transition helpers can be removed.

No functional changes.

Cc: Felipe Balbi 
Cc: Greg Kroah-Hartman 
Cc: linux-usb@vger.kernel.org
Signed-off-by: Philipp Zabel 
---
 drivers/usb/phy/phy-qcom-8x16-usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/phy/phy-qcom-8x16-usb.c 
b/drivers/usb/phy/phy-qcom-8x16-usb.c
index b6a83a5cbad36..b9c31dc7bd026 100644
--- a/drivers/usb/phy/phy-qcom-8x16-usb.c
+++ b/drivers/usb/phy/phy-qcom-8x16-usb.c
@@ -232,7 +232,7 @@ static int phy_8x16_read_devicetree(struct phy_8x16 *qphy)
if (ret)
return ret;
 
-   qphy->phy_reset = devm_reset_control_get(dev, "phy");
+   qphy->phy_reset = devm_reset_control_get_exclusive(dev, "phy");
if (IS_ERR(qphy->phy_reset))
return PTR_ERR(qphy->phy_reset);
 
-- 
2.11.0

--
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 087/102] usb: dwc2: explicitly request exclusive reset control

2017-07-19 Thread Philipp Zabel
Commit a53e35db70d1 ("reset: Ensure drivers are explicit when requesting
reset lines") started to transition the reset control request API calls
to explicitly state whether the driver needs exclusive or shared reset
control behavior. Convert all drivers requesting exclusive resets to the
explicit API call so the temporary transition helpers can be removed.

No functional changes.

Cc: John Youn 
Cc: Greg Kroah-Hartman 
Cc: linux-usb@vger.kernel.org
Signed-off-by: Philipp Zabel 
---
 drivers/usb/dwc2/platform.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index daf0d37acb37f..b9ec45b5f85d4 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -211,7 +211,8 @@ static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg)
 {
int i, ret;
 
-   hsotg->reset = devm_reset_control_get_optional(hsotg->dev, "dwc2");
+   hsotg->reset = devm_reset_control_get_optional_exclusive(hsotg->dev,
+"dwc2");
if (IS_ERR(hsotg->reset)) {
ret = PTR_ERR(hsotg->reset);
dev_err(hsotg->dev, "error getting reset control %d\n", ret);
-- 
2.11.0

--
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 089/102] usb: host: xhci-tegra: explicitly request exclusive reset control

2017-07-19 Thread Philipp Zabel
Commit a53e35db70d1 ("reset: Ensure drivers are explicit when requesting
reset lines") started to transition the reset control request API calls
to explicitly state whether the driver needs exclusive or shared reset
control behavior. Convert all drivers requesting exclusive resets to the
explicit API call so the temporary transition helpers can be removed.

No functional changes.

Cc: Mathias Nyman 
Cc: Greg Kroah-Hartman 
Cc: Thierry Reding 
Cc: Jonathan Hunter 
Cc: linux-usb@vger.kernel.org
Cc: linux-te...@vger.kernel.org
Signed-off-by: Philipp Zabel 
---
 drivers/usb/host/xhci-tegra.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
index 74436f8ca5382..ba53ee63d450c 100644
--- a/drivers/usb/host/xhci-tegra.c
+++ b/drivers/usb/host/xhci-tegra.c
@@ -933,14 +933,16 @@ static int tegra_xusb_probe(struct platform_device *pdev)
if (IS_ERR(tegra->padctl))
return PTR_ERR(tegra->padctl);
 
-   tegra->host_rst = devm_reset_control_get(>dev, "xusb_host");
+   tegra->host_rst = devm_reset_control_get_exclusive(>dev,
+  "xusb_host");
if (IS_ERR(tegra->host_rst)) {
err = PTR_ERR(tegra->host_rst);
dev_err(>dev, "failed to get xusb_host reset: %d\n", err);
goto put_padctl;
}
 
-   tegra->ss_rst = devm_reset_control_get(>dev, "xusb_ss");
+   tegra->ss_rst = devm_reset_control_get_exclusive(>dev,
+"xusb_ss");
if (IS_ERR(tegra->ss_rst)) {
err = PTR_ERR(tegra->ss_rst);
dev_err(>dev, "failed to get xusb_ss reset: %d\n", err);
-- 
2.11.0

--
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 088/102] usb: host: ehci-tegra: explicitly request exclusive reset control

2017-07-19 Thread Philipp Zabel
Commit a53e35db70d1 ("reset: Ensure drivers are explicit when requesting
reset lines") started to transition the reset control request API calls
to explicitly state whether the driver needs exclusive or shared reset
control behavior. Convert all drivers requesting exclusive resets to the
explicit API call so the temporary transition helpers can be removed.

No functional changes.

Cc: Alan Stern 
Cc: Greg Kroah-Hartman 
Cc: Thierry Reding 
Cc: Jonathan Hunter 
Cc: linux-usb@vger.kernel.org
Cc: linux-te...@vger.kernel.org
Signed-off-by: Philipp Zabel 
---
 drivers/usb/host/ehci-tegra.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 9a3d7db5be57c..c60c43f66f313 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -94,7 +94,8 @@ static int tegra_reset_usb_controller(struct platform_device 
*pdev)
struct reset_control *usb1_reset;
 
if (!has_utmi_pad_registers)
-   usb1_reset = of_reset_control_get(phy_np, "utmi-pads");
+   usb1_reset = of_reset_control_get_exclusive(phy_np,
+   
"utmi-pads");
else
usb1_reset = tegra->rst;
 
@@ -450,7 +451,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)
goto cleanup_hcd_create;
}
 
-   tegra->rst = devm_reset_control_get(>dev, "usb");
+   tegra->rst = devm_reset_control_get_exclusive(>dev, "usb");
if (IS_ERR(tegra->rst)) {
dev_err(>dev, "Can't get ehci reset\n");
err = PTR_ERR(tegra->rst);
-- 
2.11.0

--
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 091/102] usb: phy: msm: explicitly request exclusive reset control

2017-07-19 Thread Philipp Zabel
Commit a53e35db70d1 ("reset: Ensure drivers are explicit when requesting
reset lines") started to transition the reset control request API calls
to explicitly state whether the driver needs exclusive or shared reset
control behavior. Convert all drivers requesting exclusive resets to the
explicit API call so the temporary transition helpers can be removed.

No functional changes.

Cc: Felipe Balbi 
Cc: Greg Kroah-Hartman 
Cc: linux-usb@vger.kernel.org
Signed-off-by: Philipp Zabel 
---
 drivers/usb/phy/phy-msm-usb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 8fb86a5f458e0..c4d93b391d281 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1653,11 +1653,11 @@ static int msm_otg_read_dt(struct platform_device 
*pdev, struct msm_otg *motg)
if (!pdata->phy_type)
return 1;
 
-   motg->link_rst = devm_reset_control_get(>dev, "link");
+   motg->link_rst = devm_reset_control_get_exclusive(>dev, "link");
if (IS_ERR(motg->link_rst))
return PTR_ERR(motg->link_rst);
 
-   motg->phy_rst = devm_reset_control_get(>dev, "phy");
+   motg->phy_rst = devm_reset_control_get_exclusive(>dev, "phy");
if (IS_ERR(motg->phy_rst))
motg->phy_rst = NULL;
 
-- 
2.11.0

--
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 090/102] usb: musb: sunxi: explicitly request exclusive reset control

2017-07-19 Thread Philipp Zabel
Commit a53e35db70d1 ("reset: Ensure drivers are explicit when requesting
reset lines") started to transition the reset control request API calls
to explicitly state whether the driver needs exclusive or shared reset
control behavior. Convert all drivers requesting exclusive resets to the
explicit API call so the temporary transition helpers can be removed.

No functional changes.

Cc: Bin Liu 
Cc: Greg Kroah-Hartman 
Cc: Maxime Ripard 
Cc: Chen-Yu Tsai 
Cc: linux-usb@vger.kernel.org
Signed-off-by: Philipp Zabel 
---
 drivers/usb/musb/sunxi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/musb/sunxi.c b/drivers/usb/musb/sunxi.c
index c9a09b5bb6e59..7eec1acbc729a 100644
--- a/drivers/usb/musb/sunxi.c
+++ b/drivers/usb/musb/sunxi.c
@@ -747,7 +747,7 @@ static int sunxi_musb_probe(struct platform_device *pdev)
}
 
if (test_bit(SUNXI_MUSB_FL_HAS_RESET, >flags)) {
-   glue->rst = devm_reset_control_get(>dev, NULL);
+   glue->rst = devm_reset_control_get_exclusive(>dev, NULL);
if (IS_ERR(glue->rst)) {
if (PTR_ERR(glue->rst) == -EPROBE_DEFER)
return -EPROBE_DEFER;
-- 
2.11.0

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


Re: [PATCH 1/3] mfd: Add support for FTDI FT232H devices

2017-07-19 Thread Anatolij Gustschin
On Wed, 19 Jul 2017 13:39:36 +
David Laight david.lai...@aculab.com wrote:

>From: Anatolij Gustschin
>> Sent: 19 July 2017 14:30  
>...
>> >Stupid question, I know, but I cannot help thinking: If you have an
>> >EEPROM then why the h... don't you use an application specific device
>> >ID?  
>> 
>> It would make sense for adapter devices that you can buy and plug.
>> In my particular case the configuration device with FTDI chips is
>> internal part of embedded board, the configuration interface is
>> never exposed to end users. I doesn't make sense to register an
>> ID for such hardware.  
>
>Sounds like you should absolutely be registering an ID so that
>nothing can try to use it using the default one.

The intended usage can already be enforced by rejecting not signed
bootloader/kernel/firmware.

Anatolij
--
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 v2 1/1] usb: core: hub: controller driver name may be NULL

2017-07-19 Thread Alan Stern
On Wed, 19 Jul 2017, Peter Chen wrote:

> The controller driver may be NULL if the controller device
> is the middle device between platform device and roothub.
> This middle device may not need a device driver due to all
> hardware control can be at platform device driver, this
> platform device is usually a dual-role USB controller device.
> 
> The benefit of using this middle device is we can keep both
> controller device's private data (known as struct usb_hcd)
> for USB core use, and platform device's private data for
> platform driver use.
> 
> Signed-off-by: Peter Chen 
> ---
> Changes for v2:
> - Simplify the code per Alan's suggestion

Acked-by: Alan Stern 

>  drivers/usb/core/hub.c | 17 +++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> index 4ee2a6a..acba56b 100644
> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
> @@ -4383,6 +4383,7 @@ hub_port_init(struct usb_hub *hub, struct usb_device 
> *udev, int port1,
>   enum usb_device_speed   oldspeed = udev->speed;
>   const char  *speed;
>   int devnum = udev->devnum;
> + const char  *driver_name;
>  
>   /* root hub ports have a slightly longer reset period
>* (from USB 2.0 spec, section 7.1.7.5)
> @@ -4450,11 +4451,23 @@ hub_port_init(struct usb_hub *hub, struct usb_device 
> *udev, int port1,
>   else
>   speed = usb_speed_string(udev->speed);
>  
> + /*
> +  * The controller driver may be NULL if the controller device
> +  * is the middle device between platform device and roothub.
> +  * This middle device may not need a device driver due to
> +  * all hardware control can be at platform device driver, this
> +  * platform device is usually a dual-role USB controller device.
> +  */
> + if (udev->bus->controller->driver)
> + driver_name = udev->bus->controller->driver->name;
> + else
> + driver_name = udev->bus->sysdev->driver->name;
> +
>   if (udev->speed < USB_SPEED_SUPER)
>   dev_info(>dev,
>   "%s %s USB device number %d using %s\n",
>   (udev->config) ? "reset" : "new", speed,
> - devnum, udev->bus->controller->driver->name);
> + devnum, driver_name);
>  
>   /* Set up TT records, if needed  */
>   if (hdev->tt) {
> @@ -4586,7 +4599,7 @@ hub_port_init(struct usb_hub *hub, struct usb_device 
> *udev, int port1,
>   "%s SuperSpeed%s USB device 
> number %d using %s\n",
>   (udev->config) ? "reset" : 
> "new",
>(udev->speed == USB_SPEED_SUPER_PLUS) 
> ? "Plus" : "",
> - devnum, 
> udev->bus->controller->driver->name);
> +  devnum, driver_name);
>   }
>  
>   /* cope with hardware quirkiness:
> 

--
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:gadget:hid: {GET,SET} PROTOCOL Support

2017-07-19 Thread Alan Stern
On Wed, 19 Jul 2017, Abdulhadi Mohamed wrote:

> Currently linux HID gadgets do not support remote wakeup (the ability
> to wake up a host from suspend). This is an important feature for
> gadgets that want to properly emulate the normal operation of a mouse
> and keyboard. Ultimately, This feature has to be enabled/supported by
> the underlying UDC driver to have any impact. This version fixes all 
> previous formatting errors.

This description has no connection to the patch contents!

The patch is about adding support for the Get-Protocol and Set-Protocol 
requests to the f_hid driver.  It is not about remote wakeup or UDC 
drivers.

A patch cannot be accepted without a reasonable description.

Alan Stern

> 
> 
> Signed-off-by: Abdulhadi Mohamed 
> 
> ---
>  drivers/usb/gadget/function/f_hid.c | 17 -
>  include/linux/hid.h |  6 ++
>  2 files changed, 22 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/function/f_hid.c 
> b/drivers/usb/gadget/function/f_hid.c
> index 5eea448..c60b882 100644
> --- a/drivers/usb/gadget/function/f_hid.c
> +++ b/drivers/usb/gadget/function/f_hid.c
> @@ -44,6 +44,7 @@ struct f_hidg {
>   /* configuration */
>   unsigned char   bInterfaceSubClass;
>   unsigned char   bInterfaceProtocol;
> + unsigned char   protocol;
>   unsigned short  report_desc_length;
>   char*report_desc;
>   unsigned short  report_length;
> @@ -527,7 +528,9 @@ static int hidg_setup(struct usb_function *f,
>   case ((USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8
> | HID_REQ_GET_PROTOCOL):
>   VDBG(cdev, "get_protocol\n");
> - goto stall;
> + length = min_t(unsigned int, length, 1);
> + ((u8 *) req->buf)[0] = hidg->protocol;
> + goto respond;
>   break;
>  
>   case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8
> @@ -539,6 +542,17 @@ static int hidg_setup(struct usb_function *f,
>   case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8
> | HID_REQ_SET_PROTOCOL):
>   VDBG(cdev, "set_protocol\n");
> + if (value > HID_REPORT_PROTOCOL)
> + goto stall;
> + length = 0;
> + /*
> +  * We assume that programs implementing the Boot protocol
> +  * are also compatible with the Report Protocol
> +  */
> + if (hidg->bInterfaceSubClass == USB_INTERFACE_SUBCLASS_BOOT) {
> + hidg->protocol = value;
> + goto respond;
> + }
>   goto stall;
>   break;
>  
> @@ -768,6 +782,7 @@ static int hidg_bind(struct usb_configuration *c, struct 
> usb_function *f)
>   /* set descriptor dynamic values */
>   hidg_interface_desc.bInterfaceSubClass = hidg->bInterfaceSubClass;
>   hidg_interface_desc.bInterfaceProtocol = hidg->bInterfaceProtocol;
> + hidg->protocol = HID_REPORT_PROTOCOL;
>   hidg_ss_in_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length);
>   hidg_ss_in_comp_desc.wBytesPerInterval =
>   cpu_to_le16(hidg->report_length);
> diff --git a/include/linux/hid.h b/include/linux/hid.h
> index b2ec827..29d06c8 100644
> --- a/include/linux/hid.h
> +++ b/include/linux/hid.h
> @@ -347,6 +347,12 @@ struct hid_item {
>  #define HID_GROUP_LOGITECH_DJ_DEVICE 0x0102
>  
>  /*
> + * HID protocol status
> + */
> +#define HID_REPORT_PROTOCOL  1
> +#define HID_BOOT_PROTOCOL0
> +
> +/*
>   * This is the global environment of the parser. This information is
>   * persistent for main-items. The global environment can be saved and
>   * restored with PUSH/POP statements.
> 

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


USB 3.0 is broken on Odroid Xu4 on latest kernel

2017-07-19 Thread Anand Moon
Hi Krzysztof,

Today I tried to compile the latest kernel for Odroid xu4.
using exynos_defconfig I build and loaded the kernel.
but to my surprise usb 3.0 device and missing.

odroid login: root
Password:
Last login: Wed Jul 19 14:01:44 UTC 2017 on ttySAC2
Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.13.0-rc1-xu4ml-27846-g74cbd96 armv7l)

 * Documentation:  https://help.ubuntu.com
 * Management: https://landscape.canonical.com
 * Support:https://ubuntu.com/advantage
root@odroid:~# lsusb
Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 0603:0002 Novatek Microelectronics Corp.
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
root@odroid:~# lsusb -t
/:  Bus 06.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 5000M
/:  Bus 05.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 480M
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 5000M
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 480M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=exynos-ohci/3p, 12M
|__ Port 1: Dev 2, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
|__ Port 1: Dev 2, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=exynos-ehci/3p, 480M

Full dmesg can be found on blow link.
https://pastebin.com/K3xfPCPe

The reason for failed is below.

[7.187096] usb usb4-port1: connect-debounce failed

I tried to debug this but failed to find the root cause.
Nothing is connected to the UBS 3.0 port for the failure to cause.

If I load old kernel it seen to work correctly.
If you provoid some input I will give this a try.

Best Regards
-Anand
--
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: Convert to using %pOF instead of full_name

2017-07-19 Thread Rob Herring
On Wed, Jul 19, 2017 at 2:40 AM, Felipe Balbi  wrote:
>
> Hi,
>
> Rob Herring  writes:
>> Now that we have a custom printf format specifier, convert users of
>> full_name to use %pOF instead. This is preparation to remove storing
>> of the full path string for each node.
>>
>> Signed-off-by: Rob Herring 
>> Cc: Greg Kroah-Hartman 
>> Cc: Felipe Balbi 
>> Cc: linux-usb@vger.kernel.org
>
> is this going through your tree?

No, please apply.

>
> Acked-by: Felipe Balbi 
>
> --
> balbi
--
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 9/9] USB: usbip: remove unneeded MODULE_VERSION() usage

2017-07-19 Thread Shuah Khan
On 07/19/2017 06:17 AM, Greg Kroah-Hartman wrote:
> MODULE_VERSION is useless for in-kernel drivers, so just remove all
> usage of it in the USB usbip drivers.  Along with this, the
> USBIP_VERSION macros was removed as is was also pointless, as well as
> printing out the driver version to the syslog at init time, which is not
> necessary at all.
> 
> Cc: Valentina Manea 
> Cc: Shuah Khan 
> Signed-off-by: Greg Kroah-Hartman 
> ---
>  drivers/usb/usbip/stub_main.c| 2 --
>  drivers/usb/usbip/usbip_common.c | 2 --
>  drivers/usb/usbip/usbip_common.h | 2 --
>  drivers/usb/usbip/vhci_hcd.c | 2 --
>  4 files changed, 8 deletions(-)
> 
> diff --git a/drivers/usb/usbip/stub_main.c b/drivers/usb/usbip/stub_main.c
> index 660180a5d5c4..7170404e8979 100644
> --- a/drivers/usb/usbip/stub_main.c
> +++ b/drivers/usb/usbip/stub_main.c
> @@ -302,7 +302,6 @@ static int __init usbip_host_init(void)
>   goto err_create_file;
>   }
>  
> - pr_info(DRIVER_DESC " v" USBIP_VERSION "\n");
>   return ret;
>  
>  err_create_file:
> @@ -335,4 +334,3 @@ module_exit(usbip_host_exit);
>  MODULE_AUTHOR(DRIVER_AUTHOR);
>  MODULE_DESCRIPTION(DRIVER_DESC);
>  MODULE_LICENSE("GPL");
> -MODULE_VERSION(USBIP_VERSION);
> diff --git a/drivers/usb/usbip/usbip_common.c 
> b/drivers/usb/usbip/usbip_common.c
> index cab2b71a80d0..2281f3562870 100644
> --- a/drivers/usb/usbip/usbip_common.c
> +++ b/drivers/usb/usbip/usbip_common.c
> @@ -763,7 +763,6 @@ static int __init usbip_core_init(void)
>  {
>   int ret;
>  
> - pr_info(DRIVER_DESC " v" USBIP_VERSION "\n");
>   ret = usbip_init_eh();
>   if (ret)
>   return ret;
> @@ -783,4 +782,3 @@ module_exit(usbip_core_exit);
>  MODULE_AUTHOR(DRIVER_AUTHOR);
>  MODULE_DESCRIPTION(DRIVER_DESC);
>  MODULE_LICENSE("GPL");
> -MODULE_VERSION(USBIP_VERSION);
> diff --git a/drivers/usb/usbip/usbip_common.h 
> b/drivers/usb/usbip/usbip_common.h
> index f8573a52e41a..3050fc99a417 100644
> --- a/drivers/usb/usbip/usbip_common.h
> +++ b/drivers/usb/usbip/usbip_common.h
> @@ -34,8 +34,6 @@
>  #include 
>  #include 
>  
> -#define USBIP_VERSION "1.0.0"
> -
>  #undef pr_fmt
>  
>  #ifdef DEBUG
> diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
> index 2c4b2fd40406..c747623990da 100644
> --- a/drivers/usb/usbip/vhci_hcd.c
> +++ b/drivers/usb/usbip/vhci_hcd.c
> @@ -1516,7 +1516,6 @@ static int __init vhci_hcd_init(void)
>   }
>   }
>  
> - pr_info(DRIVER_DESC " v" USBIP_VERSION "\n");
>   return ret;
>  
>  err_add_hcd:
> @@ -1542,4 +1541,3 @@ module_exit(vhci_hcd_exit);
>  MODULE_AUTHOR(DRIVER_AUTHOR);
>  MODULE_DESCRIPTION(DRIVER_DESC);
>  MODULE_LICENSE("GPL");
> -MODULE_VERSION(USBIP_VERSION);
> 


Looks good to me.

Acked-by: Shuah Khan 

thanks,
-- Shuah
--
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:gadget:hid: {GET,SET} PROTOCOL Support

2017-07-19 Thread Greg KH
On Wed, Jul 19, 2017 at 02:41:56PM +0100, Abdulhadi Mohamed wrote:
> Currently linux HID gadgets do not support remote wakeup (the ability
> to wake up a host from suspend). This is an important feature for
> gadgets that want to properly emulate the normal operation of a mouse
> and keyboard. Ultimately, This feature has to be enabled/supported by
> the underlying UDC driver to have any impact. This version fixes all 
> previous formatting errors.
> 
> 
> Signed-off-by: Abdulhadi Mohamed 
> 
> ---
>  drivers/usb/gadget/function/f_hid.c | 17 -
>  include/linux/hid.h |  6 ++
>  2 files changed, 22 insertions(+), 1 deletion(-)

What changed from v2?  Always put that below the --- line as the
Documentation tells you to.

v4?

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 1/4] usb: musb: add helper function musb_ep_xfertype_string

2017-07-19 Thread Bin Liu
On Tue, Jul 18, 2017 at 07:33:07PM +0300, Sergei Shtylyov wrote:
> Hello!
> 
> On 07/18/2017 06:13 PM, Bin Liu wrote:
> 
> >Add helper function musb_ep_xfertype_string() to return the ep transfer
> >type string.
> >
> >Signed-off-by: Bin Liu 
> 
>Doesn't this belong to USB core? What's MUSB specific about it?

This was my first thought, because many drivers do this conversion
without using a helper function. But everyone returns different spelling
of the string (for example, for the Control type, the return is any of
"Control", "CONTROL", "control", "ctrl", and "CTL"), I am not sure how
to unify it without breaking backward compatibility.

Regards,
-Bin.

--
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:gadget:hid: {GET,SET} PROTOCOL Support

2017-07-19 Thread Abdulhadi Mohamed
Currently linux HID gadgets do not support remote wakeup (the ability
to wake up a host from suspend). This is an important feature for
gadgets that want to properly emulate the normal operation of a mouse
and keyboard. Ultimately, This feature has to be enabled/supported by
the underlying UDC driver to have any impact. This version fixes all 
previous formatting errors.


Signed-off-by: Abdulhadi Mohamed 

---
 drivers/usb/gadget/function/f_hid.c | 17 -
 include/linux/hid.h |  6 ++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/function/f_hid.c 
b/drivers/usb/gadget/function/f_hid.c
index 5eea448..c60b882 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c
@@ -44,6 +44,7 @@ struct f_hidg {
/* configuration */
unsigned char   bInterfaceSubClass;
unsigned char   bInterfaceProtocol;
+   unsigned char   protocol;
unsigned short  report_desc_length;
char*report_desc;
unsigned short  report_length;
@@ -527,7 +528,9 @@ static int hidg_setup(struct usb_function *f,
case ((USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8
  | HID_REQ_GET_PROTOCOL):
VDBG(cdev, "get_protocol\n");
-   goto stall;
+   length = min_t(unsigned int, length, 1);
+   ((u8 *) req->buf)[0] = hidg->protocol;
+   goto respond;
break;
 
case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8
@@ -539,6 +542,17 @@ static int hidg_setup(struct usb_function *f,
case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8
  | HID_REQ_SET_PROTOCOL):
VDBG(cdev, "set_protocol\n");
+   if (value > HID_REPORT_PROTOCOL)
+   goto stall;
+   length = 0;
+   /*
+* We assume that programs implementing the Boot protocol
+* are also compatible with the Report Protocol
+*/
+   if (hidg->bInterfaceSubClass == USB_INTERFACE_SUBCLASS_BOOT) {
+   hidg->protocol = value;
+   goto respond;
+   }
goto stall;
break;
 
@@ -768,6 +782,7 @@ static int hidg_bind(struct usb_configuration *c, struct 
usb_function *f)
/* set descriptor dynamic values */
hidg_interface_desc.bInterfaceSubClass = hidg->bInterfaceSubClass;
hidg_interface_desc.bInterfaceProtocol = hidg->bInterfaceProtocol;
+   hidg->protocol = HID_REPORT_PROTOCOL;
hidg_ss_in_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length);
hidg_ss_in_comp_desc.wBytesPerInterval =
cpu_to_le16(hidg->report_length);
diff --git a/include/linux/hid.h b/include/linux/hid.h
index b2ec827..29d06c8 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -347,6 +347,12 @@ struct hid_item {
 #define HID_GROUP_LOGITECH_DJ_DEVICE   0x0102
 
 /*
+ * HID protocol status
+ */
+#define HID_REPORT_PROTOCOL1
+#define HID_BOOT_PROTOCOL  0
+
+/*
  * This is the global environment of the parser. This information is
  * persistent for main-items. The global environment can be saved and
  * restored with PUSH/POP statements.
-- 
2.9.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


RE: [PATCH 1/3] mfd: Add support for FTDI FT232H devices

2017-07-19 Thread David Laight
From: Anatolij Gustschin
> Sent: 19 July 2017 14:30
...
> >Stupid question, I know, but I cannot help thinking: If you have an
> >EEPROM then why the h... don't you use an application specific device
> >ID?
> 
> It would make sense for adapter devices that you can buy and plug.
> In my particular case the configuration device with FTDI chips is
> internal part of embedded board, the configuration interface is
> never exposed to end users. I doesn't make sense to register an
> ID for such hardware.

Sounds like you should absolutely be registering an ID so that
nothing can try to use it using the default one.

David



Re: [PATCH 1/3] mfd: Add support for FTDI FT232H devices

2017-07-19 Thread Anatolij Gustschin
On Wed, 12 Jul 2017 11:11:46 +0200
Bjørn Mork bj...@mork.no wrote:

>Johan Hovold  writes:
>> On Tue, Jul 11, 2017 at 08:52:37AM +0200, Anatolij Gustschin wrote:
>>  
>>> For devices with connected EEPROM some modes (including UART) are
>>> configurable in the EEPROM. For devices without EEPROM the default
>>> mode is always UART, but FIFO-, Bitbang- and MPSSE-mode can be
>>> switched via commands to the the chip.  
>>
>> IIRC we should be able read from the EEPROM, and I would at least expect
>> there to be a way to retrieve the current mode as well.  
>
>Stupid question, I know, but I cannot help thinking: If you have an
>EEPROM then why the h... don't you use an application specific device
>ID?

It would make sense for adapter devices that you can buy and plug.
In my particular case the configuration device with FTDI chips is
internal part of embedded board, the configuration interface is
never exposed to end users. I doesn't make sense to register an
ID for such hardware.

Thanks,
Anatolij
--
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 4/9] USB: gadget: remove unneeded MODULE_VERSION() usage

2017-07-19 Thread Laurent Pinchart
Hi Greg,

Thank you for the patch.

On Wednesday 19 Jul 2017 14:17:39 Greg Kroah-Hartman wrote:
> MODULE_VERSION is useless for in-kernel drivers, so just remove all
> usage of it in the USB gadget drivers.  Along with this, some
> DRIVER_VERSION macros were removed as they are also pointless.
> 
> Cc: Laurent Pinchart 
> Cc: Felipe Balbi 
> Signed-off-by: Greg Kroah-Hartman 
> ---
>  drivers/usb/gadget/legacy/webcam.c   | 1 -

Reviewed-by: Laurent Pinchart 

>  drivers/usb/gadget/udc/mv_udc_core.c | 2 --
>  drivers/usb/gadget/udc/s3c2410_udc.c | 4 +---
>  3 files changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/usb/gadget/legacy/webcam.c
> b/drivers/usb/gadget/legacy/webcam.c index f9661cd627c8..82c13fce9232
> 100644
> --- a/drivers/usb/gadget/legacy/webcam.c
> +++ b/drivers/usb/gadget/legacy/webcam.c
> @@ -436,5 +436,4 @@ module_usb_composite_driver(webcam_driver);
>  MODULE_AUTHOR("Laurent Pinchart");
>  MODULE_DESCRIPTION("Webcam Video Gadget");
>  MODULE_LICENSE("GPL");
> -MODULE_VERSION("0.1.0");
> 
> diff --git a/drivers/usb/gadget/udc/mv_udc_core.c
> b/drivers/usb/gadget/udc/mv_udc_core.c index 8a708d0a1042..4103bf7cf52a
> 100644
> --- a/drivers/usb/gadget/udc/mv_udc_core.c
> +++ b/drivers/usb/gadget/udc/mv_udc_core.c
> @@ -39,7 +39,6 @@
>  #include "mv_udc.h"
> 
>  #define DRIVER_DESC  "Marvell PXA USB Device Controller driver"
> -#define DRIVER_VERSION   "8 Nov 2010"
> 
>  #define ep_dir(ep)   (((ep)->ep_num == 0) ? \
>   ((ep)->udc->ep0_dir) : ((ep)->direction))
> @@ -2427,5 +2426,4 @@ module_platform_driver(udc_driver);
>  MODULE_ALIAS("platform:mv-udc");
>  MODULE_DESCRIPTION(DRIVER_DESC);
>  MODULE_AUTHOR("Chao Xie ");
> -MODULE_VERSION(DRIVER_VERSION);
>  MODULE_LICENSE("GPL");
> diff --git a/drivers/usb/gadget/udc/s3c2410_udc.c
> b/drivers/usb/gadget/udc/s3c2410_udc.c index 4643a01262b4..394abd5d65c0
> 100644
> --- a/drivers/usb/gadget/udc/s3c2410_udc.c
> +++ b/drivers/usb/gadget/udc/s3c2410_udc.c
> @@ -51,7 +51,6 @@
>  #include "s3c2410_udc.h"
> 
>  #define DRIVER_DESC  "S3C2410 USB Device Controller Gadget"
> -#define DRIVER_VERSION   "29 Apr 2007"
>  #define DRIVER_AUTHOR"Herbert Pötzl , " \
>   "Arnaud Patard "
> 
> @@ -1996,7 +1995,7 @@ static int __init udc_init(void)
>  {
>   int retval;
> 
> - dprintk(DEBUG_NORMAL, "%s: version %s\n", gadget_name, 
DRIVER_VERSION);
> + dprintk(DEBUG_NORMAL, "%s\n", gadget_name);
> 
>   s3c2410_udc_debugfs_root = debugfs_create_dir(gadget_name, NULL);
>   if (IS_ERR(s3c2410_udc_debugfs_root)) {
> @@ -2027,5 +2026,4 @@ module_exit(udc_exit);
> 
>  MODULE_AUTHOR(DRIVER_AUTHOR);
>  MODULE_DESCRIPTION(DRIVER_DESC);
> -MODULE_VERSION(DRIVER_VERSION);
>  MODULE_LICENSE("GPL");

-- 
Regards,

Laurent Pinchart

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


Re: [PATCH 1/3] mfd: Add support for FTDI FT232H devices

2017-07-19 Thread Anatolij Gustschin
On Wed, 19 Jul 2017 10:59:34 +0200
Johan Hovold jo...@kernel.org wrote:
...
>> > +static const struct mfd_cell ftdi_cells[] = {
>> > +  { .name = "ftdi-cbus-gpio", },
>> > +  { .name = "ftdi-mpsse-i2c", },
>> > +  { .name = "ftdi-mpsse-spi", },
>> > +  { .name = "ftdi-fifo-fpp-mgr", },
>> > +};  
>> 
>> Correct me if I'm wrong, but aren't these modes really mutually
>> exclusive, possibly with exception of cbus-gpio (some pins are at least
>> available as GPIOs in MPSSE mode)? Then MFD is not is not the right fit
>> here either.  
>
>You never replied to this, and I'm afraid there are more issue with this
>series.

Sorry, unfortunately I'm too busy with other stuff. Will try to find
time to rework.

>> And as David Laight already pointed out, your ftdi-fifo-fpp-mgr driver
>> seems too application specific for a generic chip like this.  
>
>Of which this is one is one of the major.

Thanks all for feedback. I'm still pondering how to interface the
fpga manager driver to FTDI FIFO driver.

>In short, your driver is much to application specific and is probably
>something that needs to be implemented in userspace using libftdi.

I have a requirement to use the fpga manager framework, therefore the
kernel driver is needed. Our usage scenario is a multi stage fpga
configuration process, the first stage is a pre-configuration via
FTDI SPI/FIFO, all subsequent stages are also done by other fpga
manager drivers. libftdi based driver already existed for hardware
bring-up, now I need similar functionality as kernel fpga manager.

>Speaking of libftdi, you seem to have copied or borrowed a lot of code
>and protocol from libftdi and this should have been mentioned in commit
>messages and file headers (not just in a comment to one specific
>function).

I'll mention this in next patch series.

>These chips can be used for a many different applications (also in FIFO
>mode) so you cannot tie a driver to it exposing just a specific
>interface for programming a certain class of FPGAs.

Agreed.

Anatolij
--
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 6/9] USB: misc: remove unneeded MODULE_VERSION() usage

2017-07-19 Thread Greg Kroah-Hartman
On Wed, Jul 19, 2017 at 02:30:20PM +0200, Richard Leitner wrote:
> On 07/19/2017 02:17 PM, Greg Kroah-Hartman wrote:
> > MODULE_VERSION is useless for in-kernel drivers, so just remove all
> > usage of it in the USB misc drivers.  Along with this, some
> > DRIVER_VERSION macros were removed as they are also pointless.
> 
> ...
> 
> > diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
> > index 91f66d68bcb7..135c91c434bf 100644
> > --- a/drivers/usb/misc/usb251xb.c
> > +++ b/drivers/usb/misc/usb251xb.c
> > @@ -114,7 +114,6 @@
> >  
> >  #define DRIVER_NAME"usb251xb"
> >  #define DRIVER_DESC"Microchip USB 2.0 Hi-Speed Hub Controller"
> > -#define DRIVER_VERSION "1.0"
> >  
> >  struct usb251xb {
> > struct device *dev;
> 
> As I'm pretty new to kernel development I don't know if it's
> needed/wanted in this case, but if so please feel free to add
> 
> Acked-by: Richard Leitner 

It's always needed/wanted to get this, 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 7/9] USB: phy: remove unneeded MODULE_VERSION() usage

2017-07-19 Thread Greg Kroah-Hartman
On Wed, Jul 19, 2017 at 03:27:18PM +0300, Felipe Balbi wrote:
> 
> Hi,
> 
> Greg Kroah-Hartman  writes:
> > MODULE_VERSION is useless for in-kernel drivers, so remove the
> > use of it in the marvel phy driver, along with the DRIVER_VERSION
> > define.
> >
> > Cc: Felipe Balbi 
> > Signed-off-by: Greg Kroah-Hartman 
> 
> similarly, if you want me to take it let me know. Otherwise:
> 
> Acked-by: Felipe Balbi 

Mine is easy enough, 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 4/9] USB: gadget: remove unneeded MODULE_VERSION() usage

2017-07-19 Thread Greg Kroah-Hartman
On Wed, Jul 19, 2017 at 03:26:22PM +0300, Felipe Balbi wrote:
> 
> Hi,
> 
> Greg Kroah-Hartman  writes:
> > MODULE_VERSION is useless for in-kernel drivers, so just remove all
> > usage of it in the USB gadget drivers.  Along with this, some
> > DRIVER_VERSION macros were removed as they are also pointless.
> >
> > Cc: Laurent Pinchart 
> > Cc: Felipe Balbi 
> > Signed-off-by: Greg Kroah-Hartman 
> 
> If you want me to take this through my tree, let me know. Otherwise:
> 
> Acked-by: Felipe Balbi 

I can take these through my tree, 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 6/9] USB: misc: remove unneeded MODULE_VERSION() usage

2017-07-19 Thread Richard Leitner
On 07/19/2017 02:17 PM, Greg Kroah-Hartman wrote:
> MODULE_VERSION is useless for in-kernel drivers, so just remove all
> usage of it in the USB misc drivers.  Along with this, some
> DRIVER_VERSION macros were removed as they are also pointless.

...

> diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
> index 91f66d68bcb7..135c91c434bf 100644
> --- a/drivers/usb/misc/usb251xb.c
> +++ b/drivers/usb/misc/usb251xb.c
> @@ -114,7 +114,6 @@
>  
>  #define DRIVER_NAME  "usb251xb"
>  #define DRIVER_DESC  "Microchip USB 2.0 Hi-Speed Hub Controller"
> -#define DRIVER_VERSION   "1.0"
>  
>  struct usb251xb {
>   struct device *dev;

As I'm pretty new to kernel development I don't know if it's
needed/wanted in this case, but if so please feel free to add

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


Re: [PATCH 7/9] USB: phy: remove unneeded MODULE_VERSION() usage

2017-07-19 Thread Felipe Balbi

Hi,

Greg Kroah-Hartman  writes:
> MODULE_VERSION is useless for in-kernel drivers, so remove the
> use of it in the marvel phy driver, along with the DRIVER_VERSION
> define.
>
> Cc: Felipe Balbi 
> Signed-off-by: Greg Kroah-Hartman 

similarly, if you want me to take it let me know. Otherwise:

Acked-by: Felipe Balbi 

-- 
balbi
--
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 4/9] USB: gadget: remove unneeded MODULE_VERSION() usage

2017-07-19 Thread Felipe Balbi

Hi,

Greg Kroah-Hartman  writes:
> MODULE_VERSION is useless for in-kernel drivers, so just remove all
> usage of it in the USB gadget drivers.  Along with this, some
> DRIVER_VERSION macros were removed as they are also pointless.
>
> Cc: Laurent Pinchart 
> Cc: Felipe Balbi 
> Signed-off-by: Greg Kroah-Hartman 

If you want me to take this through my tree, let me know. Otherwise:

Acked-by: Felipe Balbi 

-- 
balbi
--
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 6/9] USB: misc: remove unneeded MODULE_VERSION() usage

2017-07-19 Thread Greg Kroah-Hartman
MODULE_VERSION is useless for in-kernel drivers, so just remove all
usage of it in the USB misc drivers.  Along with this, some
DRIVER_VERSION macros were removed as they are also pointless.

Cc: Keith Packard 
Cc: Juergen Stuber 
Cc: Cesar Miquel 
Cc: Richard Leitner 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/misc/adutux.c | 2 --
 drivers/usb/misc/chaoskey.c   | 2 --
 drivers/usb/misc/cytherm.c| 1 -
 drivers/usb/misc/idmouse.c| 2 --
 drivers/usb/misc/iowarrior.c  | 4 +---
 drivers/usb/misc/ldusb.c  | 1 -
 drivers/usb/misc/legousbtower.c   | 2 --
 drivers/usb/misc/rio500.c | 4 
 drivers/usb/misc/trancevibrator.c | 2 --
 drivers/usb/misc/usb251xb.c   | 1 -
 drivers/usb/misc/uss720.c | 7 +--
 11 files changed, 2 insertions(+), 26 deletions(-)

diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c
index dfd54ea4808f..1c0ada75c35d 100644
--- a/drivers/usb/misc/adutux.c
+++ b/drivers/usb/misc/adutux.c
@@ -29,8 +29,6 @@
 #include 
 #include 
 
-/* Version Information */
-#define DRIVER_VERSION "v0.0.13"
 #define DRIVER_AUTHOR "John Homppi"
 #define DRIVER_DESC "adutux (see www.ontrak.net)"
 
diff --git a/drivers/usb/misc/chaoskey.c b/drivers/usb/misc/chaoskey.c
index 15d4e64d3b65..abec6e604a62 100644
--- a/drivers/usb/misc/chaoskey.c
+++ b/drivers/usb/misc/chaoskey.c
@@ -42,12 +42,10 @@ static int chaoskey_rng_read(struct hwrng *rng, void *data,
dev_err(&(usb_if)->dev, format, ## arg)
 
 /* Version Information */
-#define DRIVER_VERSION "v0.1"
 #define DRIVER_AUTHOR  "Keith Packard, kei...@keithp.com"
 #define DRIVER_DESC"Altus Metrum ChaosKey driver"
 #define DRIVER_SHORT   "chaoskey"
 
-MODULE_VERSION(DRIVER_VERSION);
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
diff --git a/drivers/usb/misc/cytherm.c b/drivers/usb/misc/cytherm.c
index 9d8bb8dacdcd..63207c42acf6 100644
--- a/drivers/usb/misc/cytherm.c
+++ b/drivers/usb/misc/cytherm.c
@@ -20,7 +20,6 @@
 #include 
 #include 
 
-#define DRIVER_VERSION "v1.0"
 #define DRIVER_AUTHOR "Erik Rigtorp"
 #define DRIVER_DESC "Cypress USB Thermometer driver"
 
diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c
index 81fcbf024c65..39d8fedfaf3b 100644
--- a/drivers/usb/misc/idmouse.c
+++ b/drivers/usb/misc/idmouse.c
@@ -33,8 +33,6 @@
 #define HEADER "P5 225 289 255 "
 #define IMGSIZE ((WIDTH * HEIGHT) + sizeof(HEADER)-1)
 
-/* version information */
-#define DRIVER_VERSION "0.6"
 #define DRIVER_SHORT   "idmouse"
 #define DRIVER_AUTHOR  "Florian 'Floe' Echtler "
 #define DRIVER_DESC"Siemens ID Mouse FingerTIP Sensor Driver"
diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index 7ca4c7e0ea0d..be5881303681 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -21,10 +21,8 @@
 #include 
 #include 
 
-/* Version Information */
-#define DRIVER_VERSION "v0.4.0"
 #define DRIVER_AUTHOR "Christian Lucht "
-#define DRIVER_DESC "USB IO-Warrior driver (Linux 2.6.x)"
+#define DRIVER_DESC "USB IO-Warrior driver"
 
 #define USB_VENDOR_ID_CODEMERCS1984
 /* low speed iowarrior */
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c
index 9d9487c66f87..680bddb3ce05 100644
--- a/drivers/usb/misc/ldusb.c
+++ b/drivers/usb/misc/ldusb.c
@@ -112,7 +112,6 @@ static const struct usb_device_id ld_usb_table[] = {
{ } /* Terminating entry */
 };
 MODULE_DEVICE_TABLE(usb, ld_usb_table);
-MODULE_VERSION("V0.14");
 MODULE_AUTHOR("Michael Hund ");
 MODULE_DESCRIPTION("LD USB Driver");
 MODULE_LICENSE("GPL");
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c
index 0782ac6f5edf..5628f678ab59 100644
--- a/drivers/usb/misc/legousbtower.c
+++ b/drivers/usb/misc/legousbtower.c
@@ -88,8 +88,6 @@
 #include 
 
 
-/* Version Information */
-#define DRIVER_VERSION "v0.96"
 #define DRIVER_AUTHOR "Juergen Stuber "
 #define DRIVER_DESC "LEGO USB Tower Driver"
 
diff --git a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c
index b106ce76997b..ddfebb144aaa 100644
--- a/drivers/usb/misc/rio500.c
+++ b/drivers/usb/misc/rio500.c
@@ -43,10 +43,6 @@
 
 #include "rio500_usb.h"
 
-/*
- * Version Information
- */
-#define DRIVER_VERSION "v1.1"
 #define DRIVER_AUTHOR "Cesar Miquel "
 #define DRIVER_DESC "USB Rio 500 driver"
 
diff --git a/drivers/usb/misc/trancevibrator.c 
b/drivers/usb/misc/trancevibrator.c
index 9795457723d8..1862ed15ce28 100644
--- a/drivers/usb/misc/trancevibrator.c
+++ b/drivers/usb/misc/trancevibrator.c
@@ -25,8 +25,6 @@
 #include 
 #include 
 
-/* Version Information */
-#define DRIVER_VERSION "v1.1"
 #define DRIVER_AUTHOR "Sam Hocevar, s...@zoy.org"
 #define 

[PATCH 8/9] USB: realtek_cr: remove unneeded MODULE_VERSION() usage

2017-07-19 Thread Greg Kroah-Hartman
MODULE_VERSION is useless for in-kernel drivers, so remove the
use of it in the Realtek USB card reader driver.

Cc: Alan Stern 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/storage/realtek_cr.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
index 4176d1af9bf2..ec83b3b5efa9 100644
--- a/drivers/usb/storage/realtek_cr.c
+++ b/drivers/usb/storage/realtek_cr.c
@@ -47,7 +47,6 @@
 MODULE_DESCRIPTION("Driver for Realtek USB Card Reader");
 MODULE_AUTHOR("wwang ");
 MODULE_LICENSE("GPL");
-MODULE_VERSION("1.03");
 
 static int auto_delink_en = 1;
 module_param(auto_delink_en, int, S_IRUGO | S_IWUSR);
-- 
2.13.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 7/9] USB: phy: remove unneeded MODULE_VERSION() usage

2017-07-19 Thread Greg Kroah-Hartman
MODULE_VERSION is useless for in-kernel drivers, so remove the
use of it in the marvel phy driver, along with the DRIVER_VERSION
define.

Cc: Felipe Balbi 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/phy/phy-mv-usb.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c
index 697a741a0cb1..6e84a5710407 100644
--- a/drivers/usb/phy/phy-mv-usb.c
+++ b/drivers/usb/phy/phy-mv-usb.c
@@ -29,10 +29,8 @@
 #include "phy-mv-usb.h"
 
 #defineDRIVER_DESC "Marvell USB OTG transceiver driver"
-#defineDRIVER_VERSION  "Jan 20, 2010"
 
 MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_VERSION(DRIVER_VERSION);
 MODULE_LICENSE("GPL");
 
 static const char driver_name[] = "mv-otg";
-- 
2.13.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 5/9] USB: microtek: remove unneeded DRIVER_VERSION macro

2017-07-19 Thread Greg Kroah-Hartman
No one uses the DRIVER_VERSION define in this driver, so just delete it.

Cc: Oliver Neukum 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/image/microtek.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c
index a4dbb0cd80da..0b21ba757bba 100644
--- a/drivers/usb/image/microtek.c
+++ b/drivers/usb/image/microtek.c
@@ -137,10 +137,6 @@
 
 #include "microtek.h"
 
-/*
- * Version Information
- */
-#define DRIVER_VERSION "v0.4.3"
 #define DRIVER_AUTHOR "John Fremlin , Oliver Neukum 
"
 #define DRIVER_DESC "Microtek Scanmaker X6 USB scanner driver"
 
-- 
2.13.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 3/9] USB: cdc-wdm: remove unneeded DRIVER_VERSION define

2017-07-19 Thread Greg Kroah-Hartman
No one uses the DRIVER_VERSION define in this driver, so just delete it.

Cc: Oliver Neukum 
Cc: "Bjørn Mork" 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/class/cdc-wdm.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 8f972247b1c1..5aacea1978a5 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -26,10 +26,6 @@
 #include 
 #include 
 
-/*
- * Version Information
- */
-#define DRIVER_VERSION "v0.03"
 #define DRIVER_AUTHOR "Oliver Neukum"
 #define DRIVER_DESC "USB Abstract Control Model driver for USB WCM Device 
Management"
 
-- 
2.13.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 1/9] USB: atm: remove unneeded MODULE_VERSION() usage

2017-07-19 Thread Greg Kroah-Hartman
MODULE_VERSION is useless for in-kernel drivers, so just remove all
usage of it in the USB ATM drivers.  Along with this, some
DRIVER_VERSION macros were removed as they are also pointless.

Cc: Duncan Sands 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/atm/cxacru.c   | 2 --
 drivers/usb/atm/speedtch.c | 4 +---
 drivers/usb/atm/usbatm.c   | 4 +---
 drivers/usb/atm/xusbatm.c  | 1 -
 4 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index d65a64c29b85..5160a4a966b3 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -43,7 +43,6 @@
 #include "usbatm.h"
 
 #define DRIVER_AUTHOR  "Roman Kagan, David Woodhouse, Duncan Sands, Simon 
Arlott"
-#define DRIVER_VERSION "0.4"
 #define DRIVER_DESC"Conexant AccessRunner ADSL USB modem driver"
 
 static const char cxacru_driver_name[] = "cxacru";
@@ -1380,4 +1379,3 @@ module_usb_driver(cxacru_usb_driver);
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
-MODULE_VERSION(DRIVER_VERSION);
diff --git a/drivers/usb/atm/speedtch.c b/drivers/usb/atm/speedtch.c
index 5083eb5b0d5e..a5b1ac05fd9d 100644
--- a/drivers/usb/atm/speedtch.c
+++ b/drivers/usb/atm/speedtch.c
@@ -40,8 +40,7 @@
 #include "usbatm.h"
 
 #define DRIVER_AUTHOR  "Johan Verrept, Duncan Sands "
-#define DRIVER_VERSION "1.10"
-#define DRIVER_DESC"Alcatel SpeedTouch USB driver version " DRIVER_VERSION
+#define DRIVER_DESC"Alcatel SpeedTouch USB driver"
 
 static const char speedtch_driver_name[] = "speedtch";
 
@@ -962,4 +961,3 @@ module_usb_driver(speedtch_usb_driver);
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
-MODULE_VERSION(DRIVER_VERSION);
diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
index 3e80aa3b917a..75a5ff2f8a0f 100644
--- a/drivers/usb/atm/usbatm.c
+++ b/drivers/usb/atm/usbatm.c
@@ -93,8 +93,7 @@ static int usbatm_print_packet(struct usbatm_data *instance, 
const unsigned char
 #endif
 
 #define DRIVER_AUTHOR  "Johan Verrept, Duncan Sands "
-#define DRIVER_VERSION "1.10"
-#define DRIVER_DESC"Generic USB ATM/DSL I/O, version " DRIVER_VERSION
+#define DRIVER_DESC"Generic USB ATM/DSL I/O"
 
 static const char usbatm_driver_name[] = "usbatm";
 
@@ -1315,7 +1314,6 @@ module_exit(usbatm_usb_exit);
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
-MODULE_VERSION(DRIVER_VERSION);
 
 /
 **  debug  **
diff --git a/drivers/usb/atm/xusbatm.c b/drivers/usb/atm/xusbatm.c
index a87597f88a84..c73c1ec3005e 100644
--- a/drivers/usb/atm/xusbatm.c
+++ b/drivers/usb/atm/xusbatm.c
@@ -228,4 +228,3 @@ module_exit(xusbatm_exit);
 MODULE_AUTHOR("Roman Kagan, Duncan Sands");
 MODULE_DESCRIPTION("Driver for USB ADSL modems initialized in userspace");
 MODULE_LICENSE("GPL");
-MODULE_VERSION("0.1");
-- 
2.13.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 4/9] USB: gadget: remove unneeded MODULE_VERSION() usage

2017-07-19 Thread Greg Kroah-Hartman
MODULE_VERSION is useless for in-kernel drivers, so just remove all
usage of it in the USB gadget drivers.  Along with this, some
DRIVER_VERSION macros were removed as they are also pointless.

Cc: Laurent Pinchart 
Cc: Felipe Balbi 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/gadget/legacy/webcam.c   | 1 -
 drivers/usb/gadget/udc/mv_udc_core.c | 2 --
 drivers/usb/gadget/udc/s3c2410_udc.c | 4 +---
 3 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/usb/gadget/legacy/webcam.c 
b/drivers/usb/gadget/legacy/webcam.c
index f9661cd627c8..82c13fce9232 100644
--- a/drivers/usb/gadget/legacy/webcam.c
+++ b/drivers/usb/gadget/legacy/webcam.c
@@ -436,5 +436,4 @@ module_usb_composite_driver(webcam_driver);
 MODULE_AUTHOR("Laurent Pinchart");
 MODULE_DESCRIPTION("Webcam Video Gadget");
 MODULE_LICENSE("GPL");
-MODULE_VERSION("0.1.0");
 
diff --git a/drivers/usb/gadget/udc/mv_udc_core.c 
b/drivers/usb/gadget/udc/mv_udc_core.c
index 8a708d0a1042..4103bf7cf52a 100644
--- a/drivers/usb/gadget/udc/mv_udc_core.c
+++ b/drivers/usb/gadget/udc/mv_udc_core.c
@@ -39,7 +39,6 @@
 #include "mv_udc.h"
 
 #define DRIVER_DESC"Marvell PXA USB Device Controller driver"
-#define DRIVER_VERSION "8 Nov 2010"
 
 #define ep_dir(ep) (((ep)->ep_num == 0) ? \
((ep)->udc->ep0_dir) : ((ep)->direction))
@@ -2427,5 +2426,4 @@ module_platform_driver(udc_driver);
 MODULE_ALIAS("platform:mv-udc");
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_AUTHOR("Chao Xie ");
-MODULE_VERSION(DRIVER_VERSION);
 MODULE_LICENSE("GPL");
diff --git a/drivers/usb/gadget/udc/s3c2410_udc.c 
b/drivers/usb/gadget/udc/s3c2410_udc.c
index 4643a01262b4..394abd5d65c0 100644
--- a/drivers/usb/gadget/udc/s3c2410_udc.c
+++ b/drivers/usb/gadget/udc/s3c2410_udc.c
@@ -51,7 +51,6 @@
 #include "s3c2410_udc.h"
 
 #define DRIVER_DESC"S3C2410 USB Device Controller Gadget"
-#define DRIVER_VERSION "29 Apr 2007"
 #define DRIVER_AUTHOR  "Herbert Pötzl , " \
"Arnaud Patard "
 
@@ -1996,7 +1995,7 @@ static int __init udc_init(void)
 {
int retval;
 
-   dprintk(DEBUG_NORMAL, "%s: version %s\n", gadget_name, DRIVER_VERSION);
+   dprintk(DEBUG_NORMAL, "%s\n", gadget_name);
 
s3c2410_udc_debugfs_root = debugfs_create_dir(gadget_name, NULL);
if (IS_ERR(s3c2410_udc_debugfs_root)) {
@@ -2027,5 +2026,4 @@ module_exit(udc_exit);
 
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_VERSION(DRIVER_VERSION);
 MODULE_LICENSE("GPL");
-- 
2.13.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 9/9] USB: usbip: remove unneeded MODULE_VERSION() usage

2017-07-19 Thread Greg Kroah-Hartman
MODULE_VERSION is useless for in-kernel drivers, so just remove all
usage of it in the USB usbip drivers.  Along with this, the
USBIP_VERSION macros was removed as is was also pointless, as well as
printing out the driver version to the syslog at init time, which is not
necessary at all.

Cc: Valentina Manea 
Cc: Shuah Khan 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/usbip/stub_main.c| 2 --
 drivers/usb/usbip/usbip_common.c | 2 --
 drivers/usb/usbip/usbip_common.h | 2 --
 drivers/usb/usbip/vhci_hcd.c | 2 --
 4 files changed, 8 deletions(-)

diff --git a/drivers/usb/usbip/stub_main.c b/drivers/usb/usbip/stub_main.c
index 660180a5d5c4..7170404e8979 100644
--- a/drivers/usb/usbip/stub_main.c
+++ b/drivers/usb/usbip/stub_main.c
@@ -302,7 +302,6 @@ static int __init usbip_host_init(void)
goto err_create_file;
}
 
-   pr_info(DRIVER_DESC " v" USBIP_VERSION "\n");
return ret;
 
 err_create_file:
@@ -335,4 +334,3 @@ module_exit(usbip_host_exit);
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
-MODULE_VERSION(USBIP_VERSION);
diff --git a/drivers/usb/usbip/usbip_common.c b/drivers/usb/usbip/usbip_common.c
index cab2b71a80d0..2281f3562870 100644
--- a/drivers/usb/usbip/usbip_common.c
+++ b/drivers/usb/usbip/usbip_common.c
@@ -763,7 +763,6 @@ static int __init usbip_core_init(void)
 {
int ret;
 
-   pr_info(DRIVER_DESC " v" USBIP_VERSION "\n");
ret = usbip_init_eh();
if (ret)
return ret;
@@ -783,4 +782,3 @@ module_exit(usbip_core_exit);
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
-MODULE_VERSION(USBIP_VERSION);
diff --git a/drivers/usb/usbip/usbip_common.h b/drivers/usb/usbip/usbip_common.h
index f8573a52e41a..3050fc99a417 100644
--- a/drivers/usb/usbip/usbip_common.h
+++ b/drivers/usb/usbip/usbip_common.h
@@ -34,8 +34,6 @@
 #include 
 #include 
 
-#define USBIP_VERSION "1.0.0"
-
 #undef pr_fmt
 
 #ifdef DEBUG
diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 2c4b2fd40406..c747623990da 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -1516,7 +1516,6 @@ static int __init vhci_hcd_init(void)
}
}
 
-   pr_info(DRIVER_DESC " v" USBIP_VERSION "\n");
return ret;
 
 err_add_hcd:
@@ -1542,4 +1541,3 @@ module_exit(vhci_hcd_exit);
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
-MODULE_VERSION(USBIP_VERSION);
-- 
2.13.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 2/9] USB: chipidea: remove unneeded MODULE_VERSION() usage

2017-07-19 Thread Greg Kroah-Hartman
MODULE_VERSION is useless for in-kernel drivers, so remove the use of it
in the chipidea CI13XXX driver.

Cc: Peter Chen 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/usb/chipidea/ci_hdrc_pci.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/chipidea/ci_hdrc_pci.c 
b/drivers/usb/chipidea/ci_hdrc_pci.c
index b635ab67490d..39414e4b2d81 100644
--- a/drivers/usb/chipidea/ci_hdrc_pci.c
+++ b/drivers/usb/chipidea/ci_hdrc_pci.c
@@ -170,5 +170,4 @@ module_pci_driver(ci_hdrc_pci_driver);
 MODULE_AUTHOR("MIPS - David Lopo ");
 MODULE_DESCRIPTION("MIPS CI13XXX USB Peripheral Controller");
 MODULE_LICENSE("GPL");
-MODULE_VERSION("June 2008");
 MODULE_ALIAS("platform:ci13xxx_pci");
-- 
2.13.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 0/9] USB: remove MODULE_VERSION usage

2017-07-19 Thread Greg Kroah-Hartman
When a driver is in the kernel tree, the use of MODULE_VERSION and
DRIVER_VERSION and the like is totally pointless and most often,
completly wrong.  So here's a short series dropping all of the
MODULE_VERSION usage from drivers/usb/*

I'll be glad to take this in my tree unless others object...

thanks,

greg k-h

Greg Kroah-Hartman (9):
  USB: atm: remove unneeded MODULE_VERSION() usage
  USB: chipidea: remove unneeded MODULE_VERSION() usage
  USB: cdc-wdm: remove unneeded DRIVER_VERSION define
  USB: gadget: remove unneeded MODULE_VERSION() usage
  USB: microtek: remove unneeded DRIVER_VERSION macro
  USB: misc: remove unneeded MODULE_VERSION() usage
  USB: phy: remove unneeded MODULE_VERSION() usage
  USB: realtek_cr: remove unneeded MODULE_VERSION() usage
  USB: usbip: remove unneeded MODULE_VERSION() usage

 drivers/usb/atm/cxacru.c | 2 --
 drivers/usb/atm/speedtch.c   | 4 +---
 drivers/usb/atm/usbatm.c | 4 +---
 drivers/usb/atm/xusbatm.c| 1 -
 drivers/usb/chipidea/ci_hdrc_pci.c   | 1 -
 drivers/usb/class/cdc-wdm.c  | 4 
 drivers/usb/gadget/legacy/webcam.c   | 1 -
 drivers/usb/gadget/udc/mv_udc_core.c | 2 --
 drivers/usb/gadget/udc/s3c2410_udc.c | 4 +---
 drivers/usb/image/microtek.c | 4 
 drivers/usb/misc/adutux.c| 2 --
 drivers/usb/misc/chaoskey.c  | 2 --
 drivers/usb/misc/cytherm.c   | 1 -
 drivers/usb/misc/idmouse.c   | 2 --
 drivers/usb/misc/iowarrior.c | 4 +---
 drivers/usb/misc/ldusb.c | 1 -
 drivers/usb/misc/legousbtower.c  | 2 --
 drivers/usb/misc/rio500.c| 4 
 drivers/usb/misc/trancevibrator.c| 2 --
 drivers/usb/misc/usb251xb.c  | 1 -
 drivers/usb/misc/uss720.c| 7 +--
 drivers/usb/phy/phy-mv-usb.c | 2 --
 drivers/usb/storage/realtek_cr.c | 1 -
 drivers/usb/usbip/stub_main.c| 2 --
 drivers/usb/usbip/usbip_common.c | 2 --
 drivers/usb/usbip/usbip_common.h | 2 --
 drivers/usb/usbip/vhci_hcd.c | 2 --
 27 files changed, 5 insertions(+), 61 deletions(-)

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


Re: [PATCH 1/3] mfd: Add support for FTDI FT232H devices

2017-07-19 Thread Anatolij Gustschin
On Mon, 10 Jul 2017 14:52:10 +0200
Johan Hovold jo...@kernel.org wrote:

>On Thu, Jul 06, 2017 at 10:49:16PM +0200, Anatolij Gustschin wrote:
>> Add USB part with common functions for USB-GPIO/I2C/SPI master
>> adapters. These allow communication with chip's control, transmit
>> and receive endpoints and will be used by various FT232H drivers.  
>
>> +static const struct mfd_cell ftdi_cells[] = {
>> +{ .name = "ftdi-cbus-gpio", },
>> +{ .name = "ftdi-mpsse-i2c", },
>> +{ .name = "ftdi-mpsse-spi", },
>> +{ .name = "ftdi-fifo-fpp-mgr", },
>> +};  
>
>Correct me if I'm wrong, but aren't these modes really mutually
>exclusive, possibly with exception of cbus-gpio (some pins are at least
>available as GPIOs in MPSSE mode)? Then MFD is not is not the right fit
>here either.

MPSSE and FIFO modes are mutually exclusive, but I'm not sure about
MPSSE and CBUS-GPIO. CBUS-GPIO didn't work as expected when I was
testing with MPSSE SPI master driver, but maybe it is a driver issue.
FT245 FIFO and CBUS GPIO can be switched by a control request, when
FIFO mode is configured in the EEPROM.

>And as David Laight already pointed out, your ftdi-fifo-fpp-mgr driver
>seems too application specific for a generic chip like this.

Yes, I agree. I'm thinking of a rework to add a FIFO driver instead
and use it in the fpp-mgr driver. Is that the right direction? 

Thanks,
Anatolij
--
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: Issues with a VL813 based USB 3.0 Hub

2017-07-19 Thread Linus Lüssing
On Fri, Jul 14, 2017 at 10:28:48AM +0200, Linus Lüssing wrote:
> On Fri, Jul 14, 2017 at 02:41:24PM +0700, Lars Melin wrote:
> > On 2017-07-14 13:58, Linus Lüssing wrote:
> > 
> > >---
> > >$ dmesg
> > >[...]
> > >[166914.044029] usb 1-1.6.1: new full-speed USB device number 23 using 
> > >dwc_otg
> > 
> > dwc_otg is not an official kernel driver, no support for it here.
> 
> Ah, okay, didn't know. Then I'll not only try a newer kernel
> version on the Odroid but will also give it a try on an amd64
> desktop PC next week, good point.

Okay, I was not able to reproduce the issue on an amd64 based
desktop PC. Neither with a vanilla 4.12.2 nor a vanilla 4.9.36
kernel.

Regarding the armhf device, upgrading to the Raspbian provided
4.12.2 kernel [0] did not help, still the same issues.

I've asked on the Raspberry Pi forum now [1] and will debug
things further there then.

Regards, Linus


[0]: https://github.com/raspberrypi/linux/tree/rpi-4.12.y
@commit d52c1ae3a21138

[1]: https://www.raspberrypi.org/forums/viewtopic.php?f=28=188652
--
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 v16 2/7] power: add power sequence library

2017-07-19 Thread Rafael J. Wysocki
On Wednesday, July 19, 2017 10:56:00 AM Peter Chen wrote:
> On Tue, Jul 18, 2017 at 07:06:05PM +0200, Rafael J. Wysocki wrote:
> > On Tue, Jul 18, 2017 at 6:29 AM, Peter Chen  wrote:
> > > On Mon, Jul 17, 2017 at 03:39:07PM +0200, Rafael J. Wysocki wrote:
> > >> > Sorry, I should describe more.
> > >> >
> > >> > Let's take USB bus as an example, when the new USB device is at the
> > >> > host port, the device structure at device model is not created until
> > >> > it is discoverable by the USB bus. If this new USB device needs to be
> > >> > powered on before can be discoverable by the bus, the device structure
> > >> > will be not created without powering on operation. The code 
> > >> > usb_alloc_dev
> > >> > (drivers/usb/core/usb.c) is only called for discoverable device.
> > >> >
> > >> > Unlike the other bus, eg, platform bus, it creates device structure
> > >> > according to DT node. The USB bus was designed for hot plug model, the
> > >> > device structure is for discoverable device. In recent years, we begin
> > >> > to have some hard-wired USB device, Eg, onboard USB-hub, onboard USB 4G
> > >> > Modem, etc at the market. It needs some board level power operation 
> > >> > before
> > >> > it can be found by the USB bus. This patch set is designed primarily 
> > >> > for
> > >> > fix this kind of problem. You will see at at pwrseq_generic.c, we use 
> > >> > DT
> > >> > version clock API of_clk_get and DT version gpio API 
> > >> > of_get_named_gpio_flags
> > >> > instead of device structure version, like devm_clk_get and
> > >> > devm_gpiod_get_optional.
> > >> >
> > >> > MMC system has similar use case, it creates power sequence platform
> > >> > device for this issue, but all those power stuffs (clock, gpio, etc)
> > >> > may not be suitable as a dedicated virtual device at DT, they are 
> > >> > belonged
> > >> > to one physical device, so this patch set is created to see if this 
> > >> > issue
> > >> > can be fixed better.
> > >>
> > >> OK, thanks for the explanation.
> > >>
> > >> The above needs to be part of your problem statement.
> > >
> > > Ok, I will add it to cover letter.
> > >
> > >> >
> > >> > The bus will power up all device nodes in this bus according to DT
> > >> > information, the device structure has not created at this time.
> > >>
> > >> OK
> > >>
> > >> I still think that the information on power resources depended on by 
> > >> devices
> > >> should be used for power management as well as for the initial power-up.
> > >>
> > >> The most straightforward way to arrange for that would be to make it 
> > >> possible
> > >> to find the DT node matching the device after the device has been 
> > >> discovered
> > >> and struct device created for it, say by USB.  That would require adding 
> > >> some
> > >> more information on the device to the DT node, probably.
> > >
> > > After the device is created, the device node structure is under struct
> > > device, say dev->of_node. The most difficulty for this issue is the
> > > device creation is dynamic and is after the physical device is
> > > discovered by the bus, the initial power-up is needed before the device
> > > can be discovered by the bus.
> > 
> > So you power up all devices on the bus using the information from
> > of_nodes upfront.
> > 
> 
> I think your mean call pm_device_power_up(struct device *dev) for bus
> level device (eg, USB HUB for USB), yeah, I can do that. But we still
> have below problem:
> 
> Where we can put the kinds of power sequence implementation
> (eg, pwrseq_generic.c) and the match mechanism between device
> node and kinds of power sequence(eg, of_pwrseq_on at core.c)? These
> stuffs can be shared among subsystems, and is better to use
> one framework for it. MMC subsystem adds such things at its core
> folder (drivers/mmc/core/pwrseq*) currently.

The power sequence handling code can be generic IMO, because it doesn't
depend on what bus the devices are on.  It just needs to provide some
services to its users, but you need a clean interface between it and its
users, of course.

There basically are two categories of devices, let's refer to them as USB-type
and MMC-type.  The difference between them, as far as power sequences go,
boils down to initialization and discovery.

For the USB-type ones you need an upfront power-up pass over of_nodes
under the bus controller.  That needs to be initiated by the controller driver,
but may be carried out by the common code.

After that, you need to match of_nodes to devices while discovering them.
That also needs to be initiated by the bus controller, but there may be
a helper function in the common code for that.  It may take a struct device
for the just discovered device and the bus controller's of_node as arguments,
look for an of_node under the bus controller matching the device and then
attach the power sequence information to the struct device as appropriate.

After the power sequence information has been attached to the struct

[PATCH v2 1/1] usb: dwc3: gadget: Correct ISOC DATA PIDs for short packets

2017-07-19 Thread Manu Gautam
The PIDs for Isochronous data transfers are incorrect
for high bandwidth IN endpoints when the request length
is less than EP wMaxPacketSize.
As per spec correct PIDs for ISOC data transfers are:
->For request length <= wMaxPacketSize
- DATA0,
->For wMaxPacketSize < length <= (2 * wMaxPacketSize)
- DATA1,DATA0
->For (2 * wMaxPacketSize) <  length <= (3 * wMaxPacketSize)
- DATA2, DATA1, DATA0.

But driver always sets PCM fields based on wMaxPacketSize
due to which DATA2 happens even for small requests.

Fix this by setting the PCM field of trb->size depending
on request length rather than fixing it to the value
depending on wMaxPacketSize.

Ideally it shouldn't give any issues as dwc3 will send
0-length packet for next IN token if host sends (even
after receiving a short packet). Windows seems to ignore
this but with MacOS frame loss observed when using f_uvc.

Signed-off-by: Manu Gautam 
---
Changes for v2:
- Simplify and add comment as per Felipe's suggestion

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 9e41605a..c0d6c54 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -894,9 +894,41 @@ static void __dwc3_prepare_one_trb(struct dwc3_ep *dep, 
struct dwc3_trb *trb,
if (!node) {
trb->ctrl = DWC3_TRBCTL_ISOCHRONOUS_FIRST;
 
+   /*
+* USB Specification 2.0 Section 5.9.2 states that: "If
+* there is only a single transaction in the microframe,
+* only a DATA0 data packet PID is used.  If there are
+* two transactions per microframe, DATA1 is used for
+* the first transaction data packet and DATA0 is used
+* for the second transaction data packet.  If there are
+* three transactions per microframe, DATA2 is used for
+* the first transaction data packet, DATA1 is used for
+* the second, and DATA0 is used for the third."
+*
+* IOW, we should satisfy the following cases:
+*
+* 1) length <= wMaxPacketSize
+*  - DATA0
+*
+* 2) wMaxPacketSize < length <= (2 * wMaxPacketSize)
+*  - DATA1, DATA0
+*
+* 3) (2*wMaxPacketSize) < length <= (3*wMaxPacketSize)
+*  - DATA2, DATA1, DATA0
+*/
+
if (speed == USB_SPEED_HIGH) {
-   struct usb_ep *ep = >endpoint;
-   trb->size |= DWC3_TRB_SIZE_PCM1(ep->mult - 1);
+   unsigned int mult = dep->endpoint.mult - 1;
+   unsigned int maxp = usb_endpoint_maxp(
+   dep->endpoint.desc);
+
+   if (length <= (maxp << 1))
+   mult--;
+
+   if (length <= maxp)
+   mult--;
+
+   trb->size |= DWC3_TRB_SIZE_PCM1(mult);
}
} else {
trb->ctrl = DWC3_TRBCTL_ISOCHRONOUS;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,\na 
Linux Foundation Collaborative Project

--
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: serial: ftdi_sio: only bind FT232H if UART mode is enabled

2017-07-19 Thread Anatolij Gustschin
On Wed, 19 Jul 2017 11:03:11 +0200
Johan Hovold jo...@kernel.org wrote:

>On Thu, Jul 13, 2017 at 06:25:25PM +0200, Anatolij Gustschin wrote:
>> On FT232H the interface mode can be configured in the EEPROM,
>> and the async UART mode is configured by default. The chip is
>> also in async UART mode if no EEPROM is connected.
>> 
>> Check the EEPROM configuration and do not bind as serial device
>> when different interface mode is programmed in the EEPROM.  
>
>Thanks for the patch. As you may have inferred from my reply to your MFD
>series, this won't be needed for a while still however.
>
>Also note that some people already use asynchronous FIFO mode using this
>driver (also mentioned in the datasheets as an option) so only binding
>in UART mode would be too restrictive.

You probably mean asynchronous bitbang mode, not asynchronous FIFO
mode? This bitbang mode can always be set by sending a chip command
(mentioned as software configured in the datasheets)
Could you please point to code in this driver used for non-UART modes?
I don't see such code by a quick glance. There are some quirks for
various JTAG adapters to skip binding as serial port (the ftdi_sio
driver is not used in JTAG operation modes then). Or do people use
usual serial interface to send data in bitbang modes?

Async and sync FIFO (FT245) modes however can only be configured via
EEPROM settings, at least for FT232H.

Thanks,
Anatolij
--
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: [GIT PULL] USB Fixes for v4.13-rc2

2017-07-19 Thread Greg Kroah-Hartman
On Wed, Jul 19, 2017 at 01:57:26PM +0300, Felipe Balbi wrote:
> 
> Hi Greg,
> 
> here's my first set of fixes for the current -rc cycle. Let me know if
> you want anything to be changed.
> 
> cheers
> 
> The following changes since commit 5771a8c08880cdca3bfb4a3fc6d309d6bba20877:
> 
>   Linux v4.13-rc1 (2017-07-15 15:22:10 -0700)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git 
> fixes-for-v4.13-rc2

Pulled and pushed out, 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


[GIT PULL] USB Fixes for v4.13-rc2

2017-07-19 Thread Felipe Balbi

Hi Greg,

here's my first set of fixes for the current -rc cycle. Let me know if
you want anything to be changed.

cheers

The following changes since commit 5771a8c08880cdca3bfb4a3fc6d309d6bba20877:

  Linux v4.13-rc1 (2017-07-15 15:22:10 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git 
fixes-for-v4.13-rc2

for you to fetch changes up to b8b9c974afee685789fcbb191b52d1790be3608c:

  usb: renesas_usbhs: gadget: disable all eps when the driver stops (2017-07-19 
10:38:22 +0300)


usb: fixes for v4.13-rc2

First set of fixes for the current -rc cycle. Only three fixes on dwc3
this time around (proper order for getting a PHY reference, fix for
unmapping DMA and a fix for requesting IRQ on the OMAP glue layer).

Most fixes are on the renesas USB controller, fixing several old bugs
with most going to stable.

dwc2 also learned that it *must* reset USB Address to zero on Reset
interrupts.

Apart from these, some drivers needed HAS_DMA dependency and there's a
sparse warning fix for bdc udc.


Axel Lin (1):
  usb: gadget: f_mass_storage: Fix the logic to iterate all common->luns

Geert Uytterhoeven (2):
  usb: gadget: udc: USB_RENESAS_USB3 should depend on HAS_DMA
  usb: gadget: udc: USB_SNP_CORE should depend on HAS_DMA

Jack Pham (1):
  usb: dwc3: gadget: only unmap requests from DMA if mapped

Minas Harutyunyan (1):
  usb: dwc2: gadget: On USB RESET reset device address to zero

Ruslan Bilovol (3):
  include: usb: audio: specify exact endiannes of descriptors
  usb: gadget: f_uac1: endianness fixes.
  usb: gadget: f_uac2: endianness fixes.

Vignesh R (2):
  usb: dwc3: core: Call dwc3_core_get_phy() before initializing phys
  usb: dwc3: omap: remove IRQ_NOAUTOEN used with shared irq

Yoshihiro Shimoda (5):
  usb: gadget: udc: renesas_usb3: fix free size in 
renesas_usb3_dma_free_prd()
  usb: gadget: udc: renesas_usb3: fix zlp transfer by the dmac
  usb: gadget: udc: renesas_usb3: protect usb3_ep->started in 
usb3_start_pipen()
  usb: renesas_usbhs: fix usbhsc_resume() for !USBHSF_RUNTIME_PWCTRL
  usb: renesas_usbhs: gadget: disable all eps when the driver stops

kbuild test robot (1):
  usb: gadget: udc: start_udc() can be static

 drivers/usb/dwc2/gadget.c|  3 +++
 drivers/usb/dwc3/core.c  |  6 +++---
 drivers/usb/dwc3/dwc3-omap.c | 18 +++-
 drivers/usb/dwc3/gadget.c|  8 ---
 drivers/usb/gadget/function/f_mass_storage.c |  2 +-
 drivers/usb/gadget/function/f_uac1.c | 20 +-
 drivers/usb/gadget/function/f_uac2.c | 25 --
 drivers/usb/gadget/udc/Kconfig   |  5 +++--
 drivers/usb/gadget/udc/renesas_usb3.c| 14 +
 drivers/usb/gadget/udc/snps_udc_plat.c   |  6 +++---
 drivers/usb/renesas_usbhs/common.c   |  4 +++-
 drivers/usb/renesas_usbhs/mod_gadget.c   | 31 +---
 include/linux/usb/audio-v2.h | 14 ++---
 include/uapi/linux/usb/audio.h   |  6 +++---
 14 files changed, 97 insertions(+), 65 deletions(-)

-- 
balbi


signature.asc
Description: PGP signature


RE: [PATCH] usb: gadget: udc: fix the kernel NULL pointer in composite_setup

2017-07-19 Thread Felipe Balbi

(No top-posting!)

"He, Bo"  writes:
> The patch I submitted is based on the latest kernel, 
> I checked the latest kernel has the same logic, 
> so I send the patch to LKML.

but you haven't reproduced the bug on latest kernel, have you?

Can you send me tracepoint output of one test run (without failures is
fine) I just wanna know what exactly it is that you're doing.

cheers

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH] USB: serial: ftdi_sio: only bind FT232H if UART mode is enabled

2017-07-19 Thread Johan Hovold
On Thu, Jul 13, 2017 at 06:25:25PM +0200, Anatolij Gustschin wrote:
> On FT232H the interface mode can be configured in the EEPROM,
> and the async UART mode is configured by default. The chip is
> also in async UART mode if no EEPROM is connected.
> 
> Check the EEPROM configuration and do not bind as serial device
> when different interface mode is programmed in the EEPROM.

Thanks for the patch. As you may have inferred from my reply to your MFD
series, this won't be needed for a while still however.

Also note that some people already use asynchronous FIFO mode using this
driver (also mentioned in the datasheets as an option) so only binding
in UART mode would be too restrictive.

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


Re: [PATCH 1/3] mfd: Add support for FTDI FT232H devices

2017-07-19 Thread Johan Hovold
On Mon, Jul 10, 2017 at 02:52:10PM +0200, Johan Hovold wrote:
> On Thu, Jul 06, 2017 at 10:49:16PM +0200, Anatolij Gustschin wrote:
> > Add USB part with common functions for USB-GPIO/I2C/SPI master
> > adapters. These allow communication with chip's control, transmit
> > and receive endpoints and will be used by various FT232H drivers.
> 
> > +static const struct mfd_cell ftdi_cells[] = {
> > +   { .name = "ftdi-cbus-gpio", },
> > +   { .name = "ftdi-mpsse-i2c", },
> > +   { .name = "ftdi-mpsse-spi", },
> > +   { .name = "ftdi-fifo-fpp-mgr", },
> > +};
> 
> Correct me if I'm wrong, but aren't these modes really mutually
> exclusive, possibly with exception of cbus-gpio (some pins are at least
> available as GPIOs in MPSSE mode)? Then MFD is not is not the right fit
> here either.

You never replied to this, and I'm afraid there are more issue with this
series.

> And as David Laight already pointed out, your ftdi-fifo-fpp-mgr driver
> seems too application specific for a generic chip like this.

Of which this is one is one of the major.

In short, your driver is much to application specific and is probably
something that needs to be implemented in userspace using libftdi.

Speaking of libftdi, you seem to have copied or borrowed a lot of code
and protocol from libftdi and this should have been mentioned in commit
messages and file headers (not just in a comment to one specific
function).

These chips can be used for a many different applications (also in FIFO
mode) so you cannot tie a driver to it exposing just a specific
interface for programming a certain class of FPGAs.

Johan
--
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: gadget: udc: fix the kernel NULL pointer in composite_setup

2017-07-19 Thread He, Bo
The patch I submitted is based on the latest kernel, 
I checked the latest kernel has the same logic, 
so I send the patch to LKML.

Thanks for your comments.


-Original Message-
From: Felipe Balbi [mailto:ba...@kernel.org] 
Sent: Wednesday, July 19, 2017 3:51 PM
To: He, Bo ; linux-ker...@vger.kernel.org; 
linux-usb@vger.kernel.org
Cc: gre...@linuxfoundation.org; peter.c...@nxp.com; k.opas...@samsung.com; 
ste...@agner.ch; felixhaedi...@web.de; colin.k...@canonical.com; rog...@ti.com; 
f.faine...@gmail.com; Zhang, Yanmin 
Subject: RE: [PATCH] usb: gadget: udc: fix the kernel NULL pointer in 
composite_setup


Hi,

(please don't top-post and also break your lines at 80-columns ;-)

"He, Bo"  writes:
>   1. the issue reproduced very rarely, we run reboot test
>   reproduce the issue, it reproduced two times on two board after
>   more than 1500 cycles reboot.

That's fine, we, somehow, got a use-after-free on the tracepoints. I'm 
interested in fixing that without touching udc-core since that's a dwc3-only 
bug.

>   2. the kernel version is 4.4, the test case is cold reboot, I think 
> it's not android patches cause it, it's the interrupt thread run after the 
> udc->driver->unbind.

Yeah, I need you to try v4.13-rc1. v4.4 is *really* old. I can't accept your 
patch unless I'm certain the bug still exists.

>   3. I check more drivers, like amd5536_udc_stop, at91_stop,
>   atmel_usba_stop, bcm63xx_udc_stop, s3c_hsudc_stop, all the
>   interrupt disable will be in the udc_stop(), so we need
>   guarantee to stop the interrupt then release the resource.

Right, we also disable the interrupt on ->udc_stop(). See below:

static void __dwc3_gadget_stop(struct dwc3 *dwc) {
dwc3_gadget_disable_irq(dwc);
__dwc3_gadget_ep_disable(dwc->eps[0]);
__dwc3_gadget_ep_disable(dwc->eps[1]);
}

static int dwc3_gadget_stop(struct usb_gadget *g) {
struct dwc3 *dwc = gadget_to_dwc(g);
unsigned long   flags;
int epnum;

spin_lock_irqsave(>lock, flags);

if (pm_runtime_suspended(dwc->dev))
goto out;

__dwc3_gadget_stop(dwc);

for (epnum = 2; epnum < DWC3_ENDPOINTS_NUM; epnum++) {
struct dwc3_ep  *dep = dwc->eps[epnum];

if (!dep)
continue;

if (!(dep->flags & DWC3_EP_END_TRANSFER_PENDING))
continue;

wait_event_lock_irq(dep->wait_end_transfer,
!(dep->flags & 
DWC3_EP_END_TRANSFER_PENDING),
dwc->lock);
}

out:
dwc->gadget_driver  = NULL;
spin_unlock_irqrestore(>lock, flags);

free_irq(dwc->irq_gadget, dwc->ev_buf);

return 0;
}

--
balbi
--
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: gadget: udc: fix the kernel NULL pointer in composite_setup

2017-07-19 Thread Felipe Balbi

Hi,

(please don't top-post and also break your lines at 80-columns ;-)

"He, Bo"  writes:
>   1. the issue reproduced very rarely, we run reboot test
>   reproduce the issue, it reproduced two times on two board after
>   more than 1500 cycles reboot.

That's fine, we, somehow, got a use-after-free on the tracepoints. I'm
interested in fixing that without touching udc-core since that's a
dwc3-only bug.

>   2. the kernel version is 4.4, the test case is cold reboot, I think 
> it's not android patches cause it, it's the interrupt thread run after the 
> udc->driver->unbind.

Yeah, I need you to try v4.13-rc1. v4.4 is *really* old. I can't accept
your patch unless I'm certain the bug still exists.

>   3. I check more drivers, like amd5536_udc_stop, at91_stop,
>   atmel_usba_stop, bcm63xx_udc_stop, s3c_hsudc_stop, all the
>   interrupt disable will be in the udc_stop(), so we need
>   guarantee to stop the interrupt then release the resource.

Right, we also disable the interrupt on ->udc_stop(). See below:

static void __dwc3_gadget_stop(struct dwc3 *dwc)
{
dwc3_gadget_disable_irq(dwc);
__dwc3_gadget_ep_disable(dwc->eps[0]);
__dwc3_gadget_ep_disable(dwc->eps[1]);
}

static int dwc3_gadget_stop(struct usb_gadget *g)
{
struct dwc3 *dwc = gadget_to_dwc(g);
unsigned long   flags;
int epnum;

spin_lock_irqsave(>lock, flags);

if (pm_runtime_suspended(dwc->dev))
goto out;

__dwc3_gadget_stop(dwc);

for (epnum = 2; epnum < DWC3_ENDPOINTS_NUM; epnum++) {
struct dwc3_ep  *dep = dwc->eps[epnum];

if (!dep)
continue;

if (!(dep->flags & DWC3_EP_END_TRANSFER_PENDING))
continue;

wait_event_lock_irq(dep->wait_end_transfer,
!(dep->flags & 
DWC3_EP_END_TRANSFER_PENDING),
dwc->lock);
}

out:
dwc->gadget_driver  = NULL;
spin_unlock_irqrestore(>lock, flags);

free_irq(dwc->irq_gadget, dwc->ev_buf);

return 0;
}

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH] usb: dwc3: gadget: Correct ISOC DATA PIDs for short packets

2017-07-19 Thread Felipe Balbi

Hi,

Manu Gautam  writes:
>> Manu Gautam  writes:
 Manu Gautam  writes:
 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index aea9a5b..b81547d 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -854,8 +854,13 @@ static void __dwc3_prepare_one_trb(struct dwc3_ep 
> *dep, struct dwc3_trb *trb,
>   trb->ctrl = DWC3_TRBCTL_ISOCHRONOUS_FIRST;
>  
>   if (speed == USB_SPEED_HIGH) {
> - struct usb_ep *ep = >endpoint;
> - trb->size |= DWC3_TRB_SIZE_PCM1(ep->mult - 1);
> + unsigned int maxp = usb_endpoint_maxp(
> + dep->endpoint.desc);
> + unsigned int rem = length % maxp;
> + unsigned int mult = (length / maxp) & 0x3;
> +
> + trb->size |= DWC3_TRB_SIZE_PCM1(
> + rem ? mult : mult - 1);
 Manu, It seems to me like we shouldn't be relying on req->length. Which
 gadget driver are you using to test this?
>>> f_uvc function is used.
>>> In bus analyzer logs there are DATA2, DATA1 PIDs even for a 2K byte TRB
>>> (also last packet of the video frame are always less than maxpacket size).
>> Understood, yeah it makes sense, although I think your patch can be
>> simplified. Seems to me that it should be enough to set PCM1 to
>> req->length / usb_endpoint_maxp(), no?
>
> Still need to take care of two things:
> 1. Handle case if If req>length is more than 3K (buggy function driver)
> 2. We don't need to send extra packet for isoc if length is multiple of maxp.
> Hence, remainder must be checked.
>
>> Or, if we want to make use of ep->mult, we could:
>>
>>  unsigned int mult = ep->mult - 1;
>>
>>  if (req->length < (usb_endpoint_maxp() << 1))
>>  mult--;
>
> I think it should be <=
> E.g. for 2k size only two transfers should take place)
>
>
>>  if (req->length < usb_endpoint_maxp())
>>  mult--;
> <=
>
>>  trb->size |= DWC3_TRB_SIZE_PCM1(mult);
>>
>> how about that?
>>
>
> This also looks fine and I can send the updated patch.

please do. While doing that, please also add a comment pointing out the
USB Spec section you took it from and a simplified text of why we need
it. This way, nobody will dare changing that part of the code without
checking the spec ;-)

IOW, add something akin to:

/*
 * USB Specification X.x Section Y states that ""
 *
 * IOW, we should satisfy the following cases:
 *
 * i) req->length <= wMaxPacketSize
 *  - DATA0
 *
 * ii) wMaxPacketSize < req->length <= (2 * wMaxPacketSize)
 *  - DATA0, DATA1
 *
 * iii) (2 * maxPayloadSize) < req->length <= (3 * maxPayloadSize)
 *  - DATA2, DATA1, DATA0
 */

Or something similar to that.

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH] usb: Convert to using %pOF instead of full_name

2017-07-19 Thread Felipe Balbi

Hi,

Rob Herring  writes:
> Now that we have a custom printf format specifier, convert users of
> full_name to use %pOF instead. This is preparation to remove storing
> of the full path string for each node.
>
> Signed-off-by: Rob Herring 
> Cc: Greg Kroah-Hartman 
> Cc: Felipe Balbi 
> Cc: linux-usb@vger.kernel.org

is this going through your tree?

Acked-by: Felipe Balbi 

-- 
balbi


signature.asc
Description: PGP signature


[PATCH 1/1] usb: xhci: fix spinlock recursion for USB2 test mode

2017-07-19 Thread Peter Chen
Both xhci_hub_control and xhci_disable_slot tries to hold spinlock, the
spinlock recursion occurs when enters USB2 test mode. Fix it by unlock
spinlock before calling xhci_disable_slot.

Cc: 
Fixes: 0f1d832ed1fb ("usb: xhci: Add port test modes support for usb2")
Signed-off-by: Peter Chen 
---
 drivers/usb/host/xhci-hub.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 1adae9e..741ff92 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -603,12 +603,14 @@ static int xhci_enter_test_mode(struct xhci_hcd *xhci,
 
/* Disable all Device Slots */
xhci_dbg(xhci, "Disable all slots\n");
+   spin_unlock_irqrestore(>lock, *flags);
for (i = 1; i <= HCS_MAX_SLOTS(xhci->hcs_params1); i++) {
retval = xhci_disable_slot(xhci, NULL, i);
if (retval)
xhci_err(xhci, "Failed to disable slot %d, %d. Enter 
test mode anyway\n",
 i, retval);
}
+   spin_lock_irqsave(>lock, *flags);
/* Put all ports to the Disable state by clear PP */
xhci_dbg(xhci, "Disable all port (PP = 0)\n");
/* Power off USB3 ports*/
-- 
2.7.4

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


[PATCH 2/2] usb: renesas_usbhs: gadget: disable all eps when the driver stops

2017-07-19 Thread Yoshihiro Shimoda
A gadget driver will not disable eps immediately when ->disconnect()
is called. But, since this driver assumes all eps stop after
the ->disconnect(), unexpected behavior happens (especially in system
suspend).
So, this patch disables all eps in usbhsg_try_stop(). After disabling
eps by renesas_usbhs driver, since some functions will be called by
both a gadget and renesas_usbhs driver, renesas_usbhs driver should
protect uep->pipe. To protect uep->pipe easily, this patch adds a new
lock in struct usbhsg_uep.

Fixes: 2f98382dc ("usb: renesas_usbhs: Add Renesas USBHS Gadget")
Cc:  # v3.0+
Signed-off-by: Yoshihiro Shimoda 
---
 drivers/usb/renesas_usbhs/mod_gadget.c | 31 ---
 1 file changed, 24 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c 
b/drivers/usb/renesas_usbhs/mod_gadget.c
index 5bc7a61..93fba90 100644
--- a/drivers/usb/renesas_usbhs/mod_gadget.c
+++ b/drivers/usb/renesas_usbhs/mod_gadget.c
@@ -37,6 +37,7 @@ struct usbhsg_request {
 struct usbhsg_uep {
struct usb_epep;
struct usbhs_pipe   *pipe;
+   spinlock_t  lock;   /* protect the pipe */
 
char ep_name[EP_NAME_SIZE];
 
@@ -636,10 +637,16 @@ static int usbhsg_ep_enable(struct usb_ep *ep,
 static int usbhsg_ep_disable(struct usb_ep *ep)
 {
struct usbhsg_uep *uep = usbhsg_ep_to_uep(ep);
-   struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep);
+   struct usbhs_pipe *pipe;
+   unsigned long flags;
+   int ret = 0;
 
-   if (!pipe)
-   return -EINVAL;
+   spin_lock_irqsave(>lock, flags);
+   pipe = usbhsg_uep_to_pipe(uep);
+   if (!pipe) {
+   ret = -EINVAL;
+   goto out;
+   }
 
usbhsg_pipe_disable(uep);
usbhs_pipe_free(pipe);
@@ -647,6 +654,9 @@ static int usbhsg_ep_disable(struct usb_ep *ep)
uep->pipe->mod_private  = NULL;
uep->pipe   = NULL;
 
+out:
+   spin_unlock_irqrestore(>lock, flags);
+
return 0;
 }
 
@@ -696,8 +706,11 @@ static int usbhsg_ep_dequeue(struct usb_ep *ep, struct 
usb_request *req)
 {
struct usbhsg_uep *uep = usbhsg_ep_to_uep(ep);
struct usbhsg_request *ureq = usbhsg_req_to_ureq(req);
-   struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep);
+   struct usbhs_pipe *pipe;
+   unsigned long flags;
 
+   spin_lock_irqsave(>lock, flags);
+   pipe = usbhsg_uep_to_pipe(uep);
if (pipe)
usbhs_pkt_pop(pipe, usbhsg_ureq_to_pkt(ureq));
 
@@ -706,6 +719,7 @@ static int usbhsg_ep_dequeue(struct usb_ep *ep, struct 
usb_request *req)
 * even if the pipe is NULL.
 */
usbhsg_queue_pop(uep, ureq, -ECONNRESET);
+   spin_unlock_irqrestore(>lock, flags);
 
return 0;
 }
@@ -852,10 +866,10 @@ static int usbhsg_try_stop(struct usbhs_priv *priv, u32 
status)
 {
struct usbhsg_gpriv *gpriv = usbhsg_priv_to_gpriv(priv);
struct usbhs_mod *mod = usbhs_mod_get_current(priv);
-   struct usbhsg_uep *dcp = usbhsg_gpriv_to_dcp(gpriv);
+   struct usbhsg_uep *uep;
struct device *dev = usbhs_priv_to_dev(priv);
unsigned long flags;
-   int ret = 0;
+   int ret = 0, i;
 
/  spin lock /
usbhs_lock(priv, flags);
@@ -887,7 +901,9 @@ static int usbhsg_try_stop(struct usbhs_priv *priv, u32 
status)
usbhs_sys_set_test_mode(priv, 0);
usbhs_sys_function_ctrl(priv, 0);
 
-   usbhsg_ep_disable(>ep);
+   /* disable all eps */
+   usbhsg_for_each_uep_with_dcp(uep, gpriv, i)
+   usbhsg_ep_disable(>ep);
 
dev_dbg(dev, "stop gadget\n");
 
@@ -1069,6 +1085,7 @@ int usbhs_mod_gadget_probe(struct usbhs_priv *priv)
ret = -ENOMEM;
goto usbhs_mod_gadget_probe_err_gpriv;
}
+   spin_lock_init(>lock);
 
gpriv->transceiver = usb_get_phy(USB_PHY_TYPE_UNDEFINED);
dev_info(dev, "%stransceiver found\n",
-- 
1.9.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 1/2] usb: renesas_usbhs: fix usbhsc_resume() for !USBHSF_RUNTIME_PWCTRL

2017-07-19 Thread Yoshihiro Shimoda
This patch fixes an issue that some registers may be not initialized
after resume if the USBHSF_RUNTIME_PWCTRL is not set. Otherwise,
if a cable is not connected, the driver will not enable INTENB0.VBSE
after resume. And then, the driver cannot detect the VBUS.

Fixes: ca8a282a5373 ("usb: gadget: renesas_usbhs: add suspend/resume support")
Cc:  # v3.2+
Signed-off-by: Yoshihiro Shimoda 
---
 drivers/usb/renesas_usbhs/common.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/renesas_usbhs/common.c 
b/drivers/usb/renesas_usbhs/common.c
index 623c513..f0ce304 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -752,8 +752,10 @@ static int usbhsc_resume(struct device *dev)
struct usbhs_priv *priv = dev_get_drvdata(dev);
struct platform_device *pdev = usbhs_priv_to_pdev(priv);
 
-   if (!usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL))
+   if (!usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL)) {
usbhsc_power_ctrl(priv, 1);
+   usbhs_mod_autonomy_mode(priv);
+   }
 
usbhs_platform_call(priv, phy_reset, pdev);
 
-- 
1.9.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 0/2] usb: renesas_usbhs: fixes for system suspend/resume

2017-07-19 Thread Yoshihiro Shimoda
This patch set is based on the latest Felipe's usb.git / testing/fixes branch
(the commit id = 781001ff9678e5df048cca3d4290c1638a28cafa).

Yoshihiro Shimoda (2):
  usb: renesas_usbhs: fix usbhsc_resume() for !USBHSF_RUNTIME_PWCTRL
  usb: renesas_usbhs: gadget: disable all eps when the driver stops

 drivers/usb/renesas_usbhs/common.c |  4 +++-
 drivers/usb/renesas_usbhs/mod_gadget.c | 31 ---
 2 files changed, 27 insertions(+), 8 deletions(-)

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


Re: [PATCH v2 1/3] mux: Add mux_control_get_optional() API

2017-07-19 Thread Peter Rosin
On 2017-07-19 04:08, Stephen Boyd wrote:
> Quoting Peter Rosin (2017-07-17 01:20:14)
>> On 2017-07-14 23:40, Stephen Boyd wrote:
>>> diff --git a/drivers/mux/mux-core.c b/drivers/mux/mux-core.c
>>> index 90b8995f07cb..a0e5bf16f02f 100644
>>> --- a/drivers/mux/mux-core.c
>>> +++ b/drivers/mux/mux-core.c
>>> @@ -289,6 +289,9 @@ EXPORT_SYMBOL_GPL(devm_mux_chip_register);
>>>   */
>>>  unsigned int mux_control_states(struct mux_control *mux)
>>>  {
>>> + if (!mux)
>>> + return 0;
>>> +
>>
>> I don't think this is appropriate. For this function, it might be ok,
>> but...
>>
>>>   return mux->states;
>>>  }
>>>  EXPORT_SYMBOL_GPL(mux_control_states);
>>> @@ -338,6 +341,9 @@ int mux_control_select(struct mux_control *mux, 
>>> unsigned int state)
>>>  {
>>>   int ret;
>>>  
>>> + if (!mux)
>>> + return 0;
>>> +
>>
>> ...here and for other cases below it's very odd to return "ok", when
>> -EINVAL or something seems much more appropriate. And if -EINVAL is
>> returned here, the benefit of returning fake values for anything
>> pretty much falls apart.
>>
>> I simply don't like it, and prefer if the consumer code is arranged
>> to not call the mux functions when the optional get() does not find
>> the mux.
> 
> Do you want the callers of the mux APIs to know that an optional mux
> isn't there, and then have checks at all callsites on optional muxes to
> make sure consumers don't call the mux functions? Won't that duplicate
> lots of checks in drivers for something the core could treat as a don't
> care case? Sorry, I don't understand why the consumer cares that it was
> there or not when it is optional.

Ok, I had a look around to figure out how others handle this, and e.g.
gpio has (ugly) macros (VALIDATE_DESC) to handle this. I guess you are
right and I'm wrong. So, please keep all the if (!mux) checks.

Thanks for insisting!

>>
>>>   ret = down_killable(>lock);
>>>   if (ret < 0)
>>>   return ret;
>>> @@ -370,6 +376,9 @@ int mux_control_try_select(struct mux_control *mux, 
>>> unsigned int state)
>>>  {
>>>   int ret;
>>>  
>>> + if (!mux)
>>> + return 0;
>>> +
>>>   if (down_trylock(>lock))
>>>   return -EBUSY;
>>>  
>>> @@ -398,6 +407,9 @@ int mux_control_deselect(struct mux_control *mux)
>>>  {
>>>   int ret = 0;
>>>  
>>> + if (!mux)
>>> + return 0;
>>> +
>>>   if (mux->idle_state != MUX_IDLE_AS_IS &&
>>>   mux->idle_state != mux->cached_state)
>>>   ret = mux_control_set(mux, mux->idle_state);
>>> @@ -422,14 +434,8 @@ static struct mux_chip 
>>> *of_find_mux_chip_by_node(struct device_node *np)
>>>   return dev ? to_mux_chip(dev) : NULL;
>>>  }
>>>  
>>> -/**
>>> - * mux_control_get() - Get the mux-control for a device.
>>> - * @dev: The device that needs a mux-control.
>>> - * @mux_name: The name identifying the mux-control.
>>> - *
>>> - * Return: A pointer to the mux-control, or an ERR_PTR with a negative 
>>> errno.
>>> - */
>>> -struct mux_control *mux_control_get(struct device *dev, const char 
>>> *mux_name)
>>> +struct mux_control *
>>> +__mux_control_get(struct device *dev, const char *mux_name, bool optional)
>>>  {
>>>   struct device_node *np = dev->of_node;
>>>   struct of_phandle_args args;
>>> @@ -441,6 +447,8 @@ struct mux_control *mux_control_get(struct device *dev, 
>>> const char *mux_name)
>>>   if (mux_name) {
>>>   index = of_property_match_string(np, "mux-control-names",
>>>mux_name);
>>> + if (index == -EINVAL && optional)
>>> + return NULL;
>>
>> What about -ENODATA?
> 
> At this point in the code we're finding the index of a mux-control-names
> property so I was trying to handle the case where there isn't a
> mux-control-names property at all

Yes, you indeed need to check for -EINVAL to catch that. No argument
about that.

>   but we're looking for something
> optional anyway. If there is a property, then we would see some other
> error if something went wrong and then pass the error up. There is a
> hole where there isn't a mux-control-names property and we're looking
> for something that's optional, but there is a mux-control property. Do
> we care though? The DT seems broken then.

I was thinking about the case where mux-control-names names *other* muxes
but not the one asked for in this call. That's not broken and should be
handled. The way I read it, you get -ENODATA in that case?

>> And if an optional mux is found here, but lookup
>> fails later in e.g. the of_parse_phandle_with_args call, then I think
>> an error should be returned. Because that seems like an indication that
>> DT specifies that there *should* be a mux, but then there isn't one.
> 
> of_parse_phandle_with_args() would return ENOENT when there isn't a
> mux-control property in DT. So I've trapped that case and returned an
> 

[PATCH v2 1/1] usb: core: hub: controller driver name may be NULL

2017-07-19 Thread Peter Chen
The controller driver may be NULL if the controller device
is the middle device between platform device and roothub.
This middle device may not need a device driver due to all
hardware control can be at platform device driver, this
platform device is usually a dual-role USB controller device.

The benefit of using this middle device is we can keep both
controller device's private data (known as struct usb_hcd)
for USB core use, and platform device's private data for
platform driver use.

Signed-off-by: Peter Chen 
---
Changes for v2:
- Simplify the code per Alan's suggestion

 drivers/usb/core/hub.c | 17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 4ee2a6a..acba56b 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -4383,6 +4383,7 @@ hub_port_init(struct usb_hub *hub, struct usb_device 
*udev, int port1,
enum usb_device_speed   oldspeed = udev->speed;
const char  *speed;
int devnum = udev->devnum;
+   const char  *driver_name;
 
/* root hub ports have a slightly longer reset period
 * (from USB 2.0 spec, section 7.1.7.5)
@@ -4450,11 +4451,23 @@ hub_port_init(struct usb_hub *hub, struct usb_device 
*udev, int port1,
else
speed = usb_speed_string(udev->speed);
 
+   /*
+* The controller driver may be NULL if the controller device
+* is the middle device between platform device and roothub.
+* This middle device may not need a device driver due to
+* all hardware control can be at platform device driver, this
+* platform device is usually a dual-role USB controller device.
+*/
+   if (udev->bus->controller->driver)
+   driver_name = udev->bus->controller->driver->name;
+   else
+   driver_name = udev->bus->sysdev->driver->name;
+
if (udev->speed < USB_SPEED_SUPER)
dev_info(>dev,
"%s %s USB device number %d using %s\n",
(udev->config) ? "reset" : "new", speed,
-   devnum, udev->bus->controller->driver->name);
+   devnum, driver_name);
 
/* Set up TT records, if needed  */
if (hdev->tt) {
@@ -4586,7 +4599,7 @@ hub_port_init(struct usb_hub *hub, struct usb_device 
*udev, int port1,
"%s SuperSpeed%s USB device 
number %d using %s\n",
(udev->config) ? "reset" : 
"new",
 (udev->speed == USB_SPEED_SUPER_PLUS) 
? "Plus" : "",
-   devnum, 
udev->bus->controller->driver->name);
+devnum, driver_name);
}
 
/* cope with hardware quirkiness:
-- 
2.7.4

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


Re: [PATCH v2 RESEND] usb:gadget:hid: {GET,SET} PROCOTOL Support

2017-07-19 Thread Greg KH
On Tue, Jul 18, 2017 at 09:49:35PM +0100, Abdulhadi Mohamed wrote:
> On Tue, Jul 18, 2017 at 10:17:24PM +0200, Greg KH wrote:
> > On Tue, Jul 18, 2017 at 08:47:58PM +0100, Abdulhadi Mohamed wrote:
> > > The current HID function driver doesn't support GET_PROCOTOL and
> > > SET_PROCOTOL commands, which are required to operate the HID gadgets in
> > > BOOT mode. This patch implements this feature for devices that have
> > > the same implementation for REPORT and BOOT mode so that these 
> > > devices are recognized by older BIOSes. 
> > > 
> > > Signed-off-by: Abdulhadi Mohamed 
> > 
> > Any reason you didn't cc: the correct maintainers as well?
> > scripts/get_maintainer.pl will tell you who to contact...
> > 
> 
> Good point, I've looped them back in. 

That's not how to get a patch accepted, you need to resend it properly,
especially as this one is not acceptable for the reasons I previously
pointed out...

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: dwc3: gadget: Correct ISOC DATA PIDs for short packets

2017-07-19 Thread Manu Gautam
Hi,

On 7/18/2017 4:27 PM, Felipe Balbi wrote:
> Hi,
>
> Manu Gautam  writes:
>>> Manu Gautam  writes:
>>> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
 index aea9a5b..b81547d 100644
 --- a/drivers/usb/dwc3/gadget.c
 +++ b/drivers/usb/dwc3/gadget.c
 @@ -854,8 +854,13 @@ static void __dwc3_prepare_one_trb(struct dwc3_ep 
 *dep, struct dwc3_trb *trb,
trb->ctrl = DWC3_TRBCTL_ISOCHRONOUS_FIRST;
  
if (speed == USB_SPEED_HIGH) {
 -  struct usb_ep *ep = >endpoint;
 -  trb->size |= DWC3_TRB_SIZE_PCM1(ep->mult - 1);
 +  unsigned int maxp = usb_endpoint_maxp(
 +  dep->endpoint.desc);
 +  unsigned int rem = length % maxp;
 +  unsigned int mult = (length / maxp) & 0x3;
 +
 +  trb->size |= DWC3_TRB_SIZE_PCM1(
 +  rem ? mult : mult - 1);
>>> Manu, It seems to me like we shouldn't be relying on req->length. Which
>>> gadget driver are you using to test this?
>> f_uvc function is used.
>> In bus analyzer logs there are DATA2, DATA1 PIDs even for a 2K byte TRB
>> (also last packet of the video frame are always less than maxpacket size).
> Understood, yeah it makes sense, although I think your patch can be
> simplified. Seems to me that it should be enough to set PCM1 to
> req->length / usb_endpoint_maxp(), no?

Still need to take care of two things:
1. Handle case if If req>length is more than 3K (buggy function driver)
2. We don't need to send extra packet for isoc if length is multiple of maxp.
Hence, remainder must be checked.

> Or, if we want to make use of ep->mult, we could:
>
>   unsigned int mult = ep->mult - 1;
>
>   if (req->length < (usb_endpoint_maxp() << 1))
>   mult--;

I think it should be <=
E.g. for 2k size only two transfers should take place)


>   if (req->length < usb_endpoint_maxp())
>   mult--;
<=

>   trb->size |= DWC3_TRB_SIZE_PCM1(mult);
>
> how about that?
>

This also looks fine and I can send the updated patch.
--
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