From 5a68e9b57b1c1984dae8a9625bbf1a505d166035 Mon Sep 17 00:00:00 2001 From: Andrzej Pietrasiewicz Date: Thu, 8 Aug 2013 09:43:28 +0200 Subject: usb: gadget: configfs: keep a function if it is not successfully added If usb_add_function() fails then the currently processed function is already not in the list in struct config_usb_cfg, and neither is it in the list in struct usb_configuration. At the err_purge_funcs label the purge_config_funcs() is called, which iterates over all configurations, and in each configuration it iterates over all _successfully_ added functions, and moves them back from the list in struct usb_configuration to the list in struct config_usb_cfg. BUT the function which has just failed adding and caused the unwind process is not taken care of and is effectively lost. This patch modifies the configfs_composite_bind() function so that if the usb_add_function() fails, then the currently processed function is returned to the list in struct config_usb_cfg. It would be tempting to delay the list_del() in question after usb_add_function() invocation, but a struct list_head (&f->list) cannot be stored in more than one list at the same time, so the list_del() must be called before usb_add_function(). Hence, the solution is to list_add() after usb_add_function() in case of error. Signed-off-by: Andrzej Pietrasiewicz Signed-off-by: Kyungmin Park Signed-off-by: Felipe Balbi --- drivers/usb/gadget/configfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index 80e7f75..8f0d614 100644 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c @@ -859,8 +859,10 @@ static int configfs_composite_bind(struct usb_gadget *gadget, list_for_each_entry_safe(f, tmp, &cfg->func_list, list) { list_del(&f->list); ret = usb_add_function(c, f); - if (ret) + if (ret) { + list_add(&f->list, &cfg->func_list); goto err_purge_funcs; + } } usb_ep_autoconfig_reset(cdev->gadget); } -- cgit v1.1 From 7b360f4287e52802b8c62e0608737e8bbfda67e1 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Tue, 13 Aug 2013 19:35:43 +0200 Subject: usb: musb: honour the return value of dma_map_single() Since dma_map_single() may fail it is good to actually check the return code to see if it succeeded. Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Felipe Balbi --- drivers/usb/musb/musb_gadget.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 4376f51..696e9e0 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -76,13 +76,21 @@ static inline void map_dma_buffer(struct musb_request *request, return; if (request->request.dma == DMA_ADDR_INVALID) { - request->request.dma = dma_map_single( + dma_addr_t dma_addr; + int ret; + + dma_addr = dma_map_single( musb->controller, request->request.buf, request->request.length, request->tx ? DMA_TO_DEVICE : DMA_FROM_DEVICE); + ret = dma_mapping_error(musb->controller, dma_addr); + if (ret) + return; + + request->request.dma = dma_addr; request->map_state = MUSB_MAPPED; } else { dma_sync_single_for_device(musb->controller, -- cgit v1.1 From 4ff745710f830f53738324b88623a9b53f257f72 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Fri, 16 Aug 2013 17:32:49 +0200 Subject: usb: phy: am335x-control: make it compile with Randy reported this |drivers/usb/phy/phy-am335x-control.c:45:3: error: implicit declaration |of function '__WARN' [-Werror=implicit-function-declaration] and left it as an excercice to figure out that this happens only with CONFIG_BUG=n. As a fix I replace it with WARN_ON(). And there is a space before return so fix this, too. Reported-by: Randy Dunlap Acked-by: Randy Dunlap Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Felipe Balbi --- drivers/usb/phy/phy-am335x-control.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/phy/phy-am335x-control.c b/drivers/usb/phy/phy-am335x-control.c index 7597545..22cf07d 100644 --- a/drivers/usb/phy/phy-am335x-control.c +++ b/drivers/usb/phy/phy-am335x-control.c @@ -42,8 +42,8 @@ static void am335x_phy_power(struct phy_control *phy_ctrl, u32 id, bool on) reg = AM335X_USB1_CTRL; break; default: - __WARN(); - return; + WARN_ON(1); + return; } val = readl(usb_ctrl->phy_reg + reg); -- cgit v1.1 From bd2fbf3a5602d9721b82e4fc71a68167f3a7ec86 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Fri, 16 Aug 2013 17:40:55 +0200 Subject: dma: cpp41: make it compile with CONFIG_BUG=n Before Randy figures out that this does not compile with CONFIG_BUG=n here is a fix for it. Acked-by: Vinod Koul Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Felipe Balbi --- drivers/dma/cppi41.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c index 5dcebca..e696178 100644 --- a/drivers/dma/cppi41.c +++ b/drivers/dma/cppi41.c @@ -579,7 +579,7 @@ static int cppi41_tear_down_chan(struct cppi41_channel *c) WARN_ON(!c->is_tx && !(pd0 & TD_DESC_IS_RX)); WARN_ON((pd0 & 0x1f) != c->port_num); } else { - __WARN(); + WARN_ON_ONCE(1); } c->td_seen = 1; } -- cgit v1.1 From 0b5c1e62d80c8ee43b9f8435fe54ed097dba6a3c Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Sun, 18 Aug 2013 16:13:13 +0800 Subject: usb: musb: cppi41: fix missing unlock on error in cppi41_dma_callback() Add the missing unlock before return from function cppi41_dma_callback() in the error handling case. Signed-off-by: Wei Yongjun Signed-off-by: Felipe Balbi --- drivers/usb/musb/musb_cppi41.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c index e64701d..ae95974 100644 --- a/drivers/usb/musb/musb_cppi41.c +++ b/drivers/usb/musb/musb_cppi41.c @@ -150,8 +150,10 @@ static void cppi41_dma_callback(void *private_data) remain_bytes, direction, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); - if (WARN_ON(!dma_desc)) + if (WARN_ON(!dma_desc)) { + spin_unlock_irqrestore(&musb->lock, flags); return; + } dma_desc->callback = cppi41_dma_callback; dma_desc->callback_param = channel; -- cgit v1.1 From b130f03fd2b156ba0d1f82f8b3d9624fe342753e Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Mon, 19 Aug 2013 08:24:08 +0200 Subject: usb: musb: avoid null pointer dereference in debug logging Since commit 511f3c53 (usb: gadget: udc-core: fix a regression during gadget driver unbinding) usb_gadget_remove_driver will pass NULL for the driver argument. Signed-off-by: Maarten ter Huurne Signed-off-by: Felipe Balbi --- drivers/usb/musb/musb_gadget.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 696e9e0..b7b8b2b 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -1937,7 +1937,8 @@ static int musb_gadget_stop(struct usb_gadget *g, stop_activity(musb, driver); otg_set_peripheral(musb->xceiv->otg, NULL); - dev_dbg(musb->controller, "unregistering driver %s\n", driver->function); + dev_dbg(musb->controller, "unregistering driver %s\n", + driver ? driver->function : "(removed)"); musb->is_active = 0; musb->gadget_driver = NULL; -- cgit v1.1 From b2fb945d607ec33cbaf47ac1173fbd03511b4fb4 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Sun, 18 Aug 2013 22:20:41 +0200 Subject: usb: gadget: USB_FUSB300 should depend on HAS_DMA If NO_DMA=y: drivers/built-in.o: In function `fusb300_set_idma': drivers/usb/gadget/fusb300_udc.c:946: undefined reference to `usb_gadget_map_request' drivers/usb/gadget/fusb300_udc.c:958: undefined reference to `usb_gadget_unmap_request' Signed-off-by: Geert Uytterhoeven Signed-off-by: Felipe Balbi --- drivers/usb/gadget/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index bddd7ed..af19b56 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -187,7 +187,7 @@ config USB_FSL_USB2 config USB_FUSB300 tristate "Faraday FUSB300 USB Peripheral Controller" - depends on !PHYS_ADDR_T_64BIT + depends on !PHYS_ADDR_T_64BIT && HAS_DMA help Faraday usb device controller FUSB300 driver -- cgit v1.1 From 4ee4f23bb04ef6602910a0adbb0824094ffb4a7d Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Sun, 18 Aug 2013 22:20:42 +0200 Subject: usb: gadget: USB_R8A66597 should depend on HAS_DMA If NO_DMA=y: drivers/built-in.o: In function `sudmac_free_channel': drivers/usb/gadget/r8a66597-udc.c:676: undefined reference to `usb_gadget_unmap_request' drivers/built-in.o: In function `sudmac_alloc_channel': drivers/usb/gadget/r8a66597-udc.c:666: undefined reference to `usb_gadget_map_request' Signed-off-by: Geert Uytterhoeven Signed-off-by: Felipe Balbi --- drivers/usb/gadget/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index af19b56..e1b64c4 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -244,6 +244,7 @@ config USB_PXA25X_SMALL config USB_R8A66597 tristate "Renesas R8A66597 USB Peripheral Controller" + depends on HAS_DMA help R8A66597 is a discrete USB host and peripheral controller chip that supports both full and high speed USB 2.0 data transfers. -- cgit v1.1 From 272b05a9885bfe8575beac0e4fa1a1bc121f17ec Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Sun, 18 Aug 2013 22:20:43 +0200 Subject: usb: gadget: USB_NET2272_DMA should depend on HAS_DMA If NO_DMA=y: drivers/built-in.o: In function `net2272_done': drivers/usb/gadget/net2272.c:386: undefined reference to `usb_gadget_unmap_request' drivers/built-in.o: In function `net2272_queue': drivers/usb/gadget/net2272.c:848: undefined reference to `usb_gadget_map_request' Signed-off-by: Geert Uytterhoeven Signed-off-by: Felipe Balbi --- drivers/usb/gadget/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index e1b64c4..30e2dd8 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -386,7 +386,7 @@ config USB_NET2272 config USB_NET2272_DMA boolean "Support external DMA controller" - depends on USB_NET2272 + depends on USB_NET2272 && HAS_DMA help The NET2272 part can optionally support an external DMA controller, but your board has to have support in the -- cgit v1.1 From 51ef74f6400c731827454d010b35b122103fe9f9 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Mon, 19 Aug 2013 18:00:08 +0200 Subject: usb: musb: dsps: fix devm_ioremap_resource error detection code devm_ioremap_resource returns an ERR_PTR value, not NULL, on failure. Furthermore, the value returned by devm_ioremap_resource should be tested. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @@ expression e,e1; statement S; @@ *e = devm_ioremap_resource(...); if (!e1) S // Signed-off-by: Julia Lawall Signed-off-by: Felipe Balbi --- drivers/usb/musb/musb_dsps.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 4ffbaac..4ad52e7 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -361,8 +361,8 @@ static int dsps_musb_init(struct musb *musb) return -EINVAL; reg_base = devm_ioremap_resource(dev, r); - if (!musb->ctrl_base) - return -EINVAL; + if (IS_ERR(reg_base)) + return PTR_ERR(reg_base); musb->ctrl_base = reg_base; /* NOP driver needs change if supporting dual instance */ -- cgit v1.1 From 9047428894660f8f46305917e519ab62f7395cac Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Tue, 20 Aug 2013 18:35:44 +0200 Subject: usb: musb: only remove host/udc if it has been added musb_shutdown() removes always USB host and device. musb_init_controller() adds host and device depending on port_mode. If port mode is set to HOST then the removal of UDC leads only to: |(NULL device *): gadget not registered. and nothing else happens. If port mode is set to DEVICE and we remove the host then we oops in usb_remove_hcd(). This patch ensures that we only remove host in OTG/host mode and device only in OTG/device mode to avoid any trouble. Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Felipe Balbi --- drivers/usb/musb/musb_gadget.c | 2 ++ drivers/usb/musb/musb_host.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index b7b8b2b..9a08679 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -1812,6 +1812,8 @@ err: void musb_gadget_cleanup(struct musb *musb) { + if (musb->port_mode == MUSB_PORT_MODE_HOST) + return; usb_del_gadget_udc(&musb->g); } diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c index a9695f5..9a2b8c8 100644 --- a/drivers/usb/musb/musb_host.c +++ b/drivers/usb/musb/musb_host.c @@ -2628,6 +2628,8 @@ int musb_host_alloc(struct musb *musb) void musb_host_cleanup(struct musb *musb) { + if (musb->port_mode == MUSB_PORT_MODE_GADGET) + return; usb_remove_hcd(musb->hcd); musb->hcd = NULL; } -- cgit v1.1 From 3b6394b4faccb7dceaaf76fc4e5e40937b61102e Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Tue, 20 Aug 2013 18:35:45 +0200 Subject: usb: musb: dsps fix the typo in reg-names of the dma node I forgot to separete the different names in the reg-names property. This didn't cause anything to fail because the driver does not use the names and simply relies on the order of the memory offsets in reg. This patch fixes this in case it is used later. Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Felipe Balbi --- arch/arm/boot/dts/am33xx.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi index 24d6309..a38f8d3 100644 --- a/arch/arm/boot/dts/am33xx.dtsi +++ b/arch/arm/boot/dts/am33xx.dtsi @@ -470,7 +470,7 @@ 0x47402000 0x1000 0x47403000 0x1000 0x47404000 0x4000>; - reg-names = "glue controller scheduler queuemgr"; + reg-names = "glue", "controller", "scheduler", "queuemgr"; interrupts = <17>; interrupt-names = "glue"; #dma-cells = <2>; -- cgit v1.1 From a0b311ef17fb5d98e2c8d0aee450c1b9030873e0 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Tue, 20 Aug 2013 18:35:46 +0200 Subject: usb: usb: dsps: update device tree bindings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The support for both am335x-USB instances required changes to the device tree bindings. This patch reflects these changes in the bindings document. v3…v4: - remove the child node for USB. This is driver specific on won't be reflected in the device tree - use the "mentor" prefix instead of "mg". - use "dr_mode" istead of "mg,port-mode" for the port mode. The former is used by a few other drivers. v2…v3: - use proper usb-phy nodes in evm, bone and evmsk device tree. v1…v2: - use mg prefix for the Metor Graphics specific attributes - use power in mA not in mA/2 as specifed in the USB2.0 specification - use usbX-phy instead of usbX_phy - use dma-controller instead of dma Cc: Rob Herring Cc: Pawel Moll Cc: Mark Rutland Cc: Stephen Warren Cc: Ian Campbell Cc: devicetree@vger.kernel.org Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Felipe Balbi --- .../devicetree/bindings/usb/am33xx-usb.txt | 222 ++++++++++++++++++--- 1 file changed, 192 insertions(+), 30 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/am33xx-usb.txt b/Documentation/devicetree/bindings/usb/am33xx-usb.txt index dc9dc8c..20c2ff2 100644 --- a/Documentation/devicetree/bindings/usb/am33xx-usb.txt +++ b/Documentation/devicetree/bindings/usb/am33xx-usb.txt @@ -1,35 +1,197 @@ -AM33XX MUSB GLUE - - compatible : Should be "ti,musb-am33xx" - - reg : offset and length of register sets, first usbss, then for musb instances - - interrupts : usbss, musb instance interrupts in order - - ti,hwmods : must be "usb_otg_hs" - - multipoint : Should be "1" indicating the musb controller supports - multipoint. This is a MUSB configuration-specific setting. - - num-eps : Specifies the number of endpoints. This is also a - MUSB configuration-specific setting. Should be set to "16" - - ram-bits : Specifies the ram address size. Should be set to "12" - - port0-mode : Should be "3" to represent OTG. "1" signifies HOST and "2" - represents PERIPHERAL. - - port1-mode : Should be "1" to represent HOST. "3" signifies OTG and "2" - represents PERIPHERAL. - - power : Should be "250". This signifies the controller can supply up to - 500mA when operating in host mode. + AM33xx MUSB +~~~~~~~~~~~~~~~ +- compatible: ti,am33xx-usb +- reg: offset and length of the usbss register sets +- ti,hwmods : must be "usb_otg_hs" + +The glue layer contains multiple child nodes. It is required the have +at least a control module node, USB node and a PHY node. The second USB +node and its PHY node is optional. The DMA node is also optional. + +Reset module +~~~~~~~~~~~~ +- compatible: ti,am335x-usb-ctrl-module +- reg: offset and length of the "USB control registers" in the "Control + Module" block. A second offset and length for the USB wake up control + in the same memory block. +- reg-names: "phy_ctrl" for the "USB control registers" and "wakeup" for + the USB wake up control register. + +USB PHY +~~~~~~~ +compatible: ti,am335x-usb-phy +reg: offset and length of the "USB PHY" register space +ti,ctrl_mod: reference to the "reset module" node +reg-names: phy +The PHY should have a "phy" alias numbered properly in the alias +node. + +USB +~~~ +- compatible: ti,musb-am33xx +- reg: offset and length of "USB Controller Registers", and offset and + length of "USB Core" register space. +- reg-names: control for the ""USB Controller Registers" and "mc" for + "USB Core" register space +- interrupts: USB interrupt number +- interrupt-names: mc +- dr_mode: Should be one of "host", "peripheral" or "otg". +- mentor,multipoint: Should be "1" indicating the musb controller supports + multipoint. This is a MUSB configuration-specific setting. +- mentor,num-eps: Specifies the number of endpoints. This is also a + MUSB configuration-specific setting. Should be set to "16" +- mentor,ram-bits: Specifies the ram address size. Should be set to "12" +- mentor,power: Should be "500". This signifies the controller can supply up to + 500mA when operating in host mode. +- phys: reference to the USB phy +- dmas: specifies the dma channels +- dma-names: specifies the names of the channels. Use "rxN" for receive + and "txN" for transmit endpoints. N specifies the endpoint number. + +The controller should have an "usb" alias numbered properly in the alias +node. + +DMA +~~~ +- compatible: ti,am3359-cppi41 +- reg: offset and length of the following register spaces: USBSS, USB + CPPI DMA Controller, USB CPPI DMA Scheduler, USB Queue Manager +- reg-names: glue, controller, scheduler, queuemgr +- #dma-cells: should be set to 2. The first number represents the + endpoint number (0 … 14 for endpoints 1 … 15 on instance 0 and 15 … 29 + for endpoints 1 … 15 on instance 1). The second number is 0 for RX and + 1 for TX transfers. +- #dma-channels: should be set to 30 representing the 15 endpoints for + each USB instance. Example: +~~~~~~~~ +The following example contains all the nodes as used on am335x-evm: + +aliases { + usb0 = &usb0; + usb1 = &usb1; + phy0 = &usb0_phy; + phy1 = &usb1_phy; +}; -usb@47400000 { - compatible = "ti,musb-am33xx"; - reg = <0x47400000 0x1000 /* usbss */ - 0x47401000 0x800 /* musb instance 0 */ - 0x47401800 0x800>; /* musb instance 1 */ - interrupts = <17 /* usbss */ - 18 /* musb instance 0 */ - 19>; /* musb instance 1 */ - multipoint = <1>; - num-eps = <16>; - ram-bits = <12>; - port0-mode = <3>; - port1-mode = <3>; - power = <250>; +usb: usb@47400000 { + compatible = "ti,am33xx-usb"; + reg = <0x47400000 0x1000>; + ranges; + #address-cells = <1>; + #size-cells = <1>; ti,hwmods = "usb_otg_hs"; + + ctrl_mod: control@44e10000 { + compatible = "ti,am335x-usb-ctrl-module"; + reg = <0x44e10620 0x10 + 0x44e10648 0x4>; + reg-names = "phy_ctrl", "wakeup"; + }; + + usb0_phy: usb-phy@47401300 { + compatible = "ti,am335x-usb-phy"; + reg = <0x47401300 0x100>; + reg-names = "phy"; + ti,ctrl_mod = <&ctrl_mod>; + }; + + usb0: usb@47401000 { + compatible = "ti,musb-am33xx"; + reg = <0x47401400 0x400 + 0x47401000 0x200>; + reg-names = "mc", "control"; + + interrupts = <18>; + interrupt-names = "mc"; + dr_mode = "otg" + mentor,multipoint = <1>; + mentor,num-eps = <16>; + mentor,ram-bits = <12>; + mentor,power = <500>; + phys = <&usb0_phy>; + + dmas = <&cppi41dma 0 0 &cppi41dma 1 0 + &cppi41dma 2 0 &cppi41dma 3 0 + &cppi41dma 4 0 &cppi41dma 5 0 + &cppi41dma 6 0 &cppi41dma 7 0 + &cppi41dma 8 0 &cppi41dma 9 0 + &cppi41dma 10 0 &cppi41dma 11 0 + &cppi41dma 12 0 &cppi41dma 13 0 + &cppi41dma 14 0 &cppi41dma 0 1 + &cppi41dma 1 1 &cppi41dma 2 1 + &cppi41dma 3 1 &cppi41dma 4 1 + &cppi41dma 5 1 &cppi41dma 6 1 + &cppi41dma 7 1 &cppi41dma 8 1 + &cppi41dma 9 1 &cppi41dma 10 1 + &cppi41dma 11 1 &cppi41dma 12 1 + &cppi41dma 13 1 &cppi41dma 14 1>; + dma-names = + "rx1", "rx2", "rx3", "rx4", "rx5", "rx6", "rx7", + "rx8", "rx9", "rx10", "rx11", "rx12", "rx13", + "rx14", "rx15", + "tx1", "tx2", "tx3", "tx4", "tx5", "tx6", "tx7", + "tx8", "tx9", "tx10", "tx11", "tx12", "tx13", + "tx14", "tx15"; + }; + + usb1_phy: usb-phy@47401b00 { + compatible = "ti,am335x-usb-phy"; + reg = <0x47401b00 0x100>; + reg-names = "phy"; + ti,ctrl_mod = <&ctrl_mod>; + }; + + usb1: usb@47401800 { + compatible = "ti,musb-am33xx"; + reg = <0x47401c00 0x400 + 0x47401800 0x200>; + reg-names = "mc", "control"; + interrupts = <19>; + interrupt-names = "mc"; + dr_mode = "host" + mentor,multipoint = <1>; + mentor,num-eps = <16>; + mentor,ram-bits = <12>; + mentor,power = <500>; + phys = <&usb1_phy>; + + dmas = <&cppi41dma 15 0 &cppi41dma 16 0 + &cppi41dma 17 0 &cppi41dma 18 0 + &cppi41dma 19 0 &cppi41dma 20 0 + &cppi41dma 21 0 &cppi41dma 22 0 + &cppi41dma 23 0 &cppi41dma 24 0 + &cppi41dma 25 0 &cppi41dma 26 0 + &cppi41dma 27 0 &cppi41dma 28 0 + &cppi41dma 29 0 &cppi41dma 15 1 + &cppi41dma 16 1 &cppi41dma 17 1 + &cppi41dma 18 1 &cppi41dma 19 1 + &cppi41dma 20 1 &cppi41dma 21 1 + &cppi41dma 22 1 &cppi41dma 23 1 + &cppi41dma 24 1 &cppi41dma 25 1 + &cppi41dma 26 1 &cppi41dma 27 1 + &cppi41dma 28 1 &cppi41dma 29 1>; + dma-names = + "rx1", "rx2", "rx3", "rx4", "rx5", "rx6", "rx7", + "rx8", "rx9", "rx10", "rx11", "rx12", "rx13", + "rx14", "rx15", + "tx1", "tx2", "tx3", "tx4", "tx5", "tx6", "tx7", + "tx8", "tx9", "tx10", "tx11", "tx12", "tx13", + "tx14", "tx15"; + }; + + cppi41dma: dma-controller@07402000 { + compatible = "ti,am3359-cppi41"; + reg = <0x47400000 0x1000 + 0x47402000 0x1000 + 0x47403000 0x1000 + 0x47404000 0x4000>; + reg-names = "glue", "controller", "scheduler", "queuemgr"; + interrupts = <17>; + interrupt-names = "glue"; + #dma-cells = <2>; + #dma-channels = <30>; + #dma-requests = <256>; + }; }; -- cgit v1.1 From c031a7d419340f30e66dc18fab4373ad646ca7e6 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Tue, 20 Aug 2013 18:35:47 +0200 Subject: usb: usb: dsps: update code according to the binding document This relfects the code and dts requires changes due to recent .dts binding updates: - use mg prefix for the Metor Graphics specific attributes - use power in mA not in mA/2 as specifed in the USB2.0 specification - remove the child node for USB. This is driver specific on won't be reflected in the device tree - use the "mentor" prefix instead of "mg". - use "dr_mode" istead of "mg,port-mode" for the port mode. The former is used by a few other drivers. Cc: Rob Herring Cc: Pawel Moll Cc: Mark Rutland Cc: Stephen Warren Cc: Ian Campbell Cc: devicetree@vger.kernel.org Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Felipe Balbi --- arch/arm/boot/dts/am335x-bone.dts | 2 +- arch/arm/boot/dts/am335x-evm.dts | 6 ++-- arch/arm/boot/dts/am335x-evmsk.dts | 2 +- arch/arm/boot/dts/am33xx.dtsi | 67 +++++++++++++++----------------------- drivers/usb/musb/musb_dsps.c | 54 ++++++++++++++++++++---------- 5 files changed, 67 insertions(+), 64 deletions(-) diff --git a/arch/arm/boot/dts/am335x-bone.dts b/arch/arm/boot/dts/am335x-bone.dts index a8907b5..e8447a7 100644 --- a/arch/arm/boot/dts/am335x-bone.dts +++ b/arch/arm/boot/dts/am335x-bone.dts @@ -127,7 +127,7 @@ status = "okay"; }; - phy@47401300 { + usb-phy@47401300 { status = "okay"; }; diff --git a/arch/arm/boot/dts/am335x-evm.dts b/arch/arm/boot/dts/am335x-evm.dts index c26c16c..648a67e 100644 --- a/arch/arm/boot/dts/am335x-evm.dts +++ b/arch/arm/boot/dts/am335x-evm.dts @@ -178,11 +178,11 @@ status = "okay"; }; - phy@47401300 { + usb-phy@47401300 { status = "okay"; }; - phy@47401b00 { + usb-phy@47401b00 { status = "okay"; }; @@ -194,7 +194,7 @@ status = "okay"; }; - dma@07402000 { + dma-controller@07402000 { status = "okay"; }; }; diff --git a/arch/arm/boot/dts/am335x-evmsk.dts b/arch/arm/boot/dts/am335x-evmsk.dts index e92446c..a6c5033 100644 --- a/arch/arm/boot/dts/am335x-evmsk.dts +++ b/arch/arm/boot/dts/am335x-evmsk.dts @@ -214,7 +214,7 @@ status = "okay"; }; - phy@47401300 { + usb-phy@47401300 { status = "okay"; }; diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi index a38f8d3..f9c5da9 100644 --- a/arch/arm/boot/dts/am33xx.dtsi +++ b/arch/arm/boot/dts/am33xx.dtsi @@ -354,7 +354,7 @@ status = "disabled"; }; - usb0_phy: phy@47401300 { + usb0_phy: usb-phy@47401300 { compatible = "ti,am335x-usb-phy"; reg = <0x47401300 0x100>; reg-names = "phy"; @@ -364,25 +364,19 @@ usb0: usb@47401000 { compatible = "ti,musb-am33xx"; - ranges; - #address-cells = <1>; - #size-cells = <1>; - reg = <0x47401000 0x200>; - reg-names = "control"; status = "disabled"; - - musb0: usb@47401400 { - compatible = "mg,musbmhdrc"; - reg = <0x47401400 0x400>; - reg-names = "mc"; - interrupts = <18>; - interrupt-names = "mc"; - multipoint = <1>; - num-eps = <16>; - ram-bits = <12>; - port-mode = <3>; - power = <250>; - phys = <&usb0_phy>; + reg = <0x47401400 0x400 + 0x47401000 0x200>; + reg-names = "mc", "control"; + + interrupts = <18>; + interrupt-names = "mc"; + dr_mode = "otg"; + mentor,multipoint = <1>; + mentor,num-eps = <16>; + mentor,ram-bits = <12>; + mentor,power = <500>; + phys = <&usb0_phy>; dmas = <&cppi41dma 0 0 &cppi41dma 1 0 &cppi41dma 2 0 &cppi41dma 3 0 @@ -406,10 +400,9 @@ "tx1", "tx2", "tx3", "tx4", "tx5", "tx6", "tx7", "tx8", "tx9", "tx10", "tx11", "tx12", "tx13", "tx14", "tx15"; - }; }; - usb1_phy: phy@47401b00 { + usb1_phy: usb-phy@47401b00 { compatible = "ti,am335x-usb-phy"; reg = <0x47401b00 0x100>; reg-names = "phy"; @@ -419,25 +412,18 @@ usb1: usb@47401800 { compatible = "ti,musb-am33xx"; - ranges; - #address-cells = <1>; - #size-cells = <1>; - reg = <0x47401800 0x200>; - reg-names = "control"; status = "disabled"; - - musb1: usb@47401c00 { - compatible = "mg,musbmhdrc"; - reg = <0x47401c00 0x400>; - reg-names = "mc"; - interrupts = <19>; - interrupt-names = "mc"; - multipoint = <1>; - num-eps = <16>; - ram-bits = <12>; - port-mode = <3>; - power = <250>; - phys = <&usb1_phy>; + reg = <0x47401c00 0x400 + 0x47401800 0x200>; + reg-names = "mc", "control"; + interrupts = <19>; + interrupt-names = "mc"; + dr_mode = "otg"; + mentor,multipoint = <1>; + mentor,num-eps = <16>; + mentor,ram-bits = <12>; + mentor,power = <500>; + phys = <&usb1_phy>; dmas = <&cppi41dma 15 0 &cppi41dma 16 0 &cppi41dma 17 0 &cppi41dma 18 0 @@ -461,10 +447,9 @@ "tx1", "tx2", "tx3", "tx4", "tx5", "tx6", "tx7", "tx8", "tx9", "tx10", "tx11", "tx12", "tx13", "tx14", "tx15"; - }; }; - cppi41dma: dma@07402000 { + cppi41dma: dma-controller@07402000 { compatible = "ti,am3359-cppi41"; reg = <0x47400000 0x1000 0x47402000 0x1000 diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 4ad52e7..4ead0f5 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -44,6 +44,7 @@ #include #include #include +#include #include "musb_core.h" @@ -425,35 +426,51 @@ static int get_int_prop(struct device_node *dn, const char *s) return val; } +static int get_musb_port_mode(struct device *dev) +{ + enum usb_dr_mode mode; + + mode = of_usb_get_dr_mode(dev->of_node); + switch (mode) { + case USB_DR_MODE_HOST: + return MUSB_PORT_MODE_HOST; + + case USB_DR_MODE_PERIPHERAL: + return MUSB_PORT_MODE_GADGET; + + case USB_DR_MODE_UNKNOWN: + case USB_DR_MODE_OTG: + default: + return MUSB_PORT_MODE_DUAL_ROLE; + }; +} + static int dsps_create_musb_pdev(struct dsps_glue *glue, struct platform_device *parent) { struct musb_hdrc_platform_data pdata; struct resource resources[2]; + struct resource *res; struct device *dev = &parent->dev; struct musb_hdrc_config *config; struct platform_device *musb; struct device_node *dn = parent->dev.of_node; - struct device_node *child_node; int ret; - child_node = of_get_child_by_name(dn, "usb"); - if (!child_node) - return -EINVAL; - memset(resources, 0, sizeof(resources)); - ret = of_address_to_resource(child_node, 0, &resources[0]); - if (ret) { + res = platform_get_resource_byname(parent, IORESOURCE_MEM, "mc"); + if (!res) { dev_err(dev, "failed to get memory.\n"); - return ret; + return -EINVAL; } + resources[0] = *res; - ret = of_irq_to_resource(child_node, 0, &resources[1]); - if (ret == 0) { + res = platform_get_resource_byname(parent, IORESOURCE_IRQ, "mc"); + if (!res) { dev_err(dev, "failed to get irq.\n"); - ret = -EINVAL; - return ret; + return -EINVAL; } + resources[1] = *res; /* allocate the child platform device */ musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO); @@ -465,7 +482,7 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue, musb->dev.parent = dev; musb->dev.dma_mask = &musb_dmamask; musb->dev.coherent_dma_mask = musb_dmamask; - musb->dev.of_node = of_node_get(child_node); + musb->dev.of_node = of_node_get(dn); glue->musb = musb; @@ -485,11 +502,12 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue, pdata.config = config; pdata.platform_ops = &dsps_ops; - config->num_eps = get_int_prop(child_node, "num-eps"); - config->ram_bits = get_int_prop(child_node, "ram-bits"); - pdata.mode = get_int_prop(child_node, "port-mode"); - pdata.power = get_int_prop(child_node, "power"); - config->multipoint = of_property_read_bool(child_node, "multipoint"); + config->num_eps = get_int_prop(dn, "mentor,num-eps"); + config->ram_bits = get_int_prop(dn, "mentor,ram-bits"); + pdata.mode = get_musb_port_mode(dev); + /* DT keeps this entry in mA, musb expects it as per USB spec */ + pdata.power = get_int_prop(dn, "mentor,power") / 2; + config->multipoint = of_property_read_bool(dn, "mentor,multipoint"); ret = platform_device_add_data(musb, &pdata, sizeof(pdata)); if (ret) { -- cgit v1.1 From 9dfa36218dadf1821da5823773dd689b4e650e00 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Tue, 20 Aug 2013 18:35:48 +0200 Subject: usb: musb: dsps: do not set is_active on the first drvbus interrupt Quite early on init there is an vbus / drvvbus interrupt comming and the dsps code sets is_active to one. As a result we see a lot of |musb_bus_suspend 2459: trying to suspend as a_wait_bcon while active until a device is plugged in with pm_runtime enabled in the kernel. After checking davinci, am35, da8xx I noticed that dsps is actually the only one doing this. So remove it and we won't flooded with mesages and the idle port can be suspended. Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Felipe Balbi --- drivers/usb/musb/musb_dsps.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 4ead0f5..392406d 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -314,7 +314,6 @@ static irqreturn_t dsps_interrupt(int irq, void *hci) jiffies + wrp->poll_seconds * HZ); WARNING("VBUS error workaround (delay coming)\n"); } else if (drvvbus) { - musb->is_active = 1; MUSB_HST_MODE(musb); musb->xceiv->otg->default_a = 1; musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; -- cgit v1.1 From 781f17983015dae33324e34d1bb831e715fa04d4 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Tue, 20 Aug 2013 18:35:49 +0200 Subject: usb: musb: am335x-evm: Do not remove the session bit HOST-only mode This is what I observe: On the first connect, the musb starts with DEVCTL.Session set. On disconnect, musb_core calls try_idle. That functions removes the Session bit signalizing that the session is over (something that only in OTG is required). A new device, that is plugged, is no longer recognized. I've setup a timer and checked the DEVCTL register and I haven't seen a change in VBus and I saw the B-Device bit set. After setting the IDDIG into A mode and forcing the device to behave like a A device, I didn't see a change. Neither VBUS goes to 0b11 nor does a session start request comes. In the TI-v3.2 kernel they skip to call musb_platform_try_idle() in the OTG_STATE_A_WAIT_BCON state while not in OTG mode. Since the second port hast a standard A plug the patch changes the port to run in host mode only and skips the timer which would remove DEVCTL.Session so we can reconnect to another device later. Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Felipe Balbi --- arch/arm/boot/dts/am335x-evm.dts | 1 + drivers/usb/musb/musb_dsps.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/arch/arm/boot/dts/am335x-evm.dts b/arch/arm/boot/dts/am335x-evm.dts index 648a67e..e8ec875 100644 --- a/arch/arm/boot/dts/am335x-evm.dts +++ b/arch/arm/boot/dts/am335x-evm.dts @@ -192,6 +192,7 @@ usb@47401800 { status = "okay"; + dr_mode = "host"; }; dma-controller@07402000 { diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 392406d..4047cbb 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -231,6 +231,8 @@ static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout) glue->last_timer = jiffies; return; } + if (musb->port_mode == MUSB_PORT_MODE_HOST) + return; if (time_after(glue->last_timer, timeout) && timer_pending(&glue->timer)) { -- cgit v1.1 From 2ae847a1b10f3da5931fc9d04cc5950624418cf4 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Tue, 20 Aug 2013 18:35:50 +0200 Subject: usb: musb: am335x: add second port to beagle bone So I assumed that Beagle bone has only one USB port in host mode because the micro USB connector had an USB-UART there. I was wrong a little. The second port runs on host mode, but the micro USB plug is connected to an internal HUB with two ports: one to the USB-UART and one to musb instance one. For that reason, this patch enables both ports: the primary in device mode only and the second in host mode only. Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Felipe Balbi --- arch/arm/boot/dts/am335x-bone.dts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/arm/boot/dts/am335x-bone.dts b/arch/arm/boot/dts/am335x-bone.dts index e8447a7..d318987d 100644 --- a/arch/arm/boot/dts/am335x-bone.dts +++ b/arch/arm/boot/dts/am335x-bone.dts @@ -131,9 +131,22 @@ status = "okay"; }; + usb-phy@47401b00 { + status = "okay"; + }; + usb@47401000 { status = "okay"; }; + + usb@47401800 { + status = "okay"; + dr_mode = "host"; + }; + + dma-controller@07402000 { + status = "okay"; + }; }; i2c0: i2c@44e0b000 { -- cgit v1.1 From d6aafa2bf3bc1ca43405a4b753d91d7549224fdc Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Tue, 20 Aug 2013 18:35:53 +0200 Subject: dma: cpp41: enable pm_runtime during init With enabled pm_runtime in the kernel the device won't work because it is not "on" during the probe function. This patch enables the device via pm_runtime on probe so it remains activated. Acked-by: Vinod Koul Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Felipe Balbi --- drivers/dma/cppi41.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c index e696178..6c4e64f 100644 --- a/drivers/dma/cppi41.c +++ b/drivers/dma/cppi41.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "dmaengine.h" #define DESC_TYPE 27 @@ -960,6 +961,11 @@ static int cppi41_dma_probe(struct platform_device *pdev) goto err_remap; } + pm_runtime_enable(&pdev->dev); + ret = pm_runtime_get_sync(&pdev->dev); + if (ret) + goto err_get_sync; + cdd->queues_rx = glue_info->queues_rx; cdd->queues_tx = glue_info->queues_tx; cdd->td_queue = glue_info->td_queue; @@ -1005,6 +1011,9 @@ err_irq: err_chans: deinit_cpii41(pdev, cdd); err_init_cppi: + pm_runtime_put(&pdev->dev); +err_get_sync: + pm_runtime_disable(&pdev->dev); iounmap(cdd->usbss_mem); iounmap(cdd->ctrl_mem); iounmap(cdd->sched_mem); @@ -1029,6 +1038,8 @@ static int cppi41_dma_remove(struct platform_device *pdev) iounmap(cdd->ctrl_mem); iounmap(cdd->sched_mem); iounmap(cdd->qmgr_mem); + pm_runtime_put(&pdev->dev); + pm_runtime_disable(&pdev->dev); kfree(cdd); return 0; } -- cgit v1.1 From 9473e8cfc7570857dfe872b75f8e535ebac4cf53 Mon Sep 17 00:00:00 2001 From: Anatolij Gustschin Date: Wed, 21 Aug 2013 17:43:31 +0200 Subject: usb: phy: fix build breakage Commit 94ae9843 (usb: phy: rename all phy drivers to phy-$name-usb.c) renamed drivers/usb/phy/otg_fsm.h to drivers/usb/phy/phy-fsm-usb.h but changed drivers/usb/phy/phy-fsm-usb.c to include not existing "phy-otg-fsm.h" instead of new "phy-fsm-usb.h". This breaks building: ... drivers/usb/phy/phy-fsm-usb.c:32:25: fatal error: phy-otg-fsm.h: No such file or directory compilation terminated. make[3]: *** [drivers/usb/phy/phy-fsm-usb.o] Error 1 This commit also missed to modify drivers/usb/phy/phy-fsl-usb.h to include new "phy-fsm-usb.h" instead of "otg_fsm.h" resulting in another build breakage: ... In file included from drivers/usb/phy/phy-fsl-usb.c:46:0: drivers/usb/phy/phy-fsl-usb.h:18:21: fatal error: otg_fsm.h: No such file or directory compilation terminated. make[3]: *** [drivers/usb/phy/phy-fsl-usb.o] Error 1 Fix both issues. Signed-off-by: Anatolij Gustschin Cc: stable@vger.kernel.org Signed-off-by: Felipe Balbi --- drivers/usb/phy/phy-fsl-usb.h | 2 +- drivers/usb/phy/phy-fsm-usb.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/phy/phy-fsl-usb.h b/drivers/usb/phy/phy-fsl-usb.h index ca26628..e1859b8 100644 --- a/drivers/usb/phy/phy-fsl-usb.h +++ b/drivers/usb/phy/phy-fsl-usb.h @@ -15,7 +15,7 @@ * 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "otg_fsm.h" +#include "phy-fsm-usb.h" #include #include diff --git a/drivers/usb/phy/phy-fsm-usb.c b/drivers/usb/phy/phy-fsm-usb.c index c520b35..7f45966 100644 --- a/drivers/usb/phy/phy-fsm-usb.c +++ b/drivers/usb/phy/phy-fsm-usb.c @@ -29,7 +29,7 @@ #include #include -#include "phy-otg-fsm.h" +#include "phy-fsm-usb.h" /* Change USB protocol when there is a protocol change */ static int otg_set_protocol(struct otg_fsm *fsm, int protocol) -- cgit v1.1 From c078a37652477e1b08318df8fe403e02cac5138d Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 22 Aug 2013 13:46:58 +0530 Subject: usb: dwc3: Remove duplicate inclusion of otg.h otg.h header file was included twice. Signed-off-by: Sachin Kamat Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/core.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 577af1b..474162e 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -33,7 +33,6 @@ #include #include -#include #include #include #include -- cgit v1.1 From 1826e9b1bd9139850954acb9c2e0fb230ba94e0d Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 23 Aug 2013 11:14:49 +0300 Subject: usb: gadget: gadgetfs: use after free in dev_release() The call to put_dev() releases "dev". Hopefully, we don't need to set the state to STATE_DEV_DISABLED anyway so I have removed those lines. Signed-off-by: Dan Carpenter Signed-off-by: Felipe Balbi --- drivers/usb/gadget/inode.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c index 570c005..465ef8e 100644 --- a/drivers/usb/gadget/inode.c +++ b/drivers/usb/gadget/inode.c @@ -1270,10 +1270,6 @@ dev_release (struct inode *inode, struct file *fd) dev->buf = NULL; put_dev (dev); - /* other endpoints were all decoupled from this device */ - spin_lock_irq(&dev->lock); - dev->state = STATE_DEV_DISABLED; - spin_unlock_irq(&dev->lock); return 0; } -- cgit v1.1 From df4989954abc5ae160865bec79b0f099086decce Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 23 Aug 2013 11:16:15 +0300 Subject: usb: gadget: gadgetfs: potential use after free in unbind() ffs_data_put() can sometimes free "ffs" so I have moved the call down a line below the dereference. Signed-off-by: Dan Carpenter Signed-off-by: Felipe Balbi --- drivers/usb/gadget/f_fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c index f394f29..1a66c5b 100644 --- a/drivers/usb/gadget/f_fs.c +++ b/drivers/usb/gadget/f_fs.c @@ -1417,8 +1417,8 @@ static void functionfs_unbind(struct ffs_data *ffs) usb_ep_free_request(ffs->gadget->ep0, ffs->ep0req); ffs->ep0req = NULL; ffs->gadget = NULL; - ffs_data_put(ffs); clear_bit(FFS_FL_BOUND, &ffs->flags); + ffs_data_put(ffs); } } -- cgit v1.1 From 0f82768406914d1391ec6d087500db7405f8f68e Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 21 Aug 2013 11:41:22 +0300 Subject: usb: phy: signedness bugs in suspend/resume functions "ret" needs to be signed for the error handling to work. Signed-off-by: Dan Carpenter Signed-off-by: Felipe Balbi --- drivers/usb/phy/phy-omap-usb2.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/usb/phy/phy-omap-usb2.c b/drivers/usb/phy/phy-omap-usb2.c index 844ab68..d266861 100644 --- a/drivers/usb/phy/phy-omap-usb2.c +++ b/drivers/usb/phy/phy-omap-usb2.c @@ -98,8 +98,8 @@ static int omap_usb_set_peripheral(struct usb_otg *otg, static int omap_usb2_suspend(struct usb_phy *x, int suspend) { - u32 ret; struct omap_usb *phy = phy_to_omapusb(x); + int ret; if (suspend && !phy->is_suspended) { omap_control_usb_phy_power(phy->control_dev, 0); @@ -108,8 +108,7 @@ static int omap_usb2_suspend(struct usb_phy *x, int suspend) } else if (!suspend && phy->is_suspended) { ret = pm_runtime_get_sync(phy->dev); if (ret < 0) { - dev_err(phy->dev, "get_sync failed with err %d\n", - ret); + dev_err(phy->dev, "get_sync failed with err %d\n", ret); return ret; } omap_control_usb_phy_power(phy->control_dev, 1); @@ -209,9 +208,9 @@ static int omap_usb2_runtime_suspend(struct device *dev) static int omap_usb2_runtime_resume(struct device *dev) { - u32 ret = 0; struct platform_device *pdev = to_platform_device(dev); struct omap_usb *phy = platform_get_drvdata(pdev); + int ret; ret = clk_enable(phy->wkupclk); if (ret < 0) { -- cgit v1.1 From ffb62a14c7b6109ca4ee9bb360ad867b294acddc Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 21 Aug 2013 11:42:24 +0300 Subject: usb: gadget: double unlocks on error in atmel_usba_start() The "goto out" statements were wrong. We aren't holding any locks at that point so we should return directly. Signed-off-by: Dan Carpenter Signed-off-by: Felipe Balbi --- drivers/usb/gadget/atmel_usba_udc.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c index 40d2338..2cb52e0 100644 --- a/drivers/usb/gadget/atmel_usba_udc.c +++ b/drivers/usb/gadget/atmel_usba_udc.c @@ -1772,7 +1772,7 @@ out: static int atmel_usba_start(struct usb_gadget *gadget, struct usb_gadget_driver *driver) { - int ret = 0; + int ret; struct usba_udc *udc = container_of(gadget, struct usba_udc, gadget); unsigned long flags; @@ -1784,11 +1784,11 @@ static int atmel_usba_start(struct usb_gadget *gadget, ret = clk_prepare_enable(udc->pclk); if (ret) - goto out; + return ret; ret = clk_prepare_enable(udc->hclk); if (ret) { clk_disable_unprepare(udc->pclk); - goto out; + return ret; } DBG(DBG_GADGET, "registered driver `%s'\n", driver->driver.name); @@ -1804,11 +1804,9 @@ static int atmel_usba_start(struct usb_gadget *gadget, usba_writel(udc, CTRL, USBA_ENABLE_MASK); usba_writel(udc, INT_ENB, USBA_END_OF_RESET); } - -out: spin_unlock_irqrestore(&udc->lock, flags); - return ret; + return 0; } static int atmel_usba_stop(struct usb_gadget *gadget, -- cgit v1.1 From 0f2aa8caeaa043f6cbe6281eb72efba5ff860904 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Wed, 21 Aug 2013 12:47:03 +0100 Subject: usb: musb: ux500: Add check for NULL board data Dan Carpenter's automatic Smatch checker found an anomaly in the ux500 MUSB driver, whereby board data was checked before use in all but one occasion. It is believed that it needs to be checked every time. Smatch complaint: drivers/usb/musb/ux500_dma.c:335 ux500_dma_controller_start() error: we previously assumed 'data' could be null (see line 313) Cc: Felipe Balbi Cc: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org Cc: Dan Carpenter Signed-off-by: Lee Jones Signed-off-by: Felipe Balbi --- drivers/usb/musb/ux500_dma.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/musb/ux500_dma.c b/drivers/usb/musb/ux500_dma.c index e51dd9b..3700e97 100644 --- a/drivers/usb/musb/ux500_dma.c +++ b/drivers/usb/musb/ux500_dma.c @@ -333,7 +333,9 @@ static int ux500_dma_controller_start(struct ux500_dma_controller *controller) if (!ux500_channel->dma_chan) ux500_channel->dma_chan = dma_request_channel(mask, - data->dma_filter, + data ? + data->dma_filter : + NULL, param_array[ch_num]); if (!ux500_channel->dma_chan) { -- cgit v1.1