[PATCH 2/2] usb: gadget: atmel_usba_udc: remove release function

2014-11-19 Thread Bo Shen
As the driver call usb_add_gadget_udc -- usb_add_gadget_udc_release
with NULL as release parameter, so it will use usb_udc_no_release.
So, the release in driver won't used, remove it.

And at the same time, in the usb_add_gadget_udc_release will set the
gadget name, so remove it also in driver.

Signed-off-by: Bo Shen voice.s...@atmel.com
---
 drivers/usb/gadget/udc/atmel_usba_udc.c | 9 -
 1 file changed, 9 deletions(-)

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c 
b/drivers/usb/gadget/udc/atmel_usba_udc.c
index 1529926..8c29d09 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -1007,19 +1007,10 @@ static struct usb_endpoint_descriptor usba_ep0_desc = {
.bInterval = 1,
 };
 
-static void nop_release(struct device *dev)
-{
-
-}
-
 static struct usb_gadget usba_gadget_template = {
.ops= usba_udc_ops,
.max_speed  = USB_SPEED_HIGH,
.name   = atmel_usba_udc,
-   .dev= {
-   .init_name  = gadget,
-   .release= nop_release,
-   },
 };
 
 /*
-- 
2.1.0.24.g4109c28

--
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: gadget: at91_udc: remove unused release function

2014-11-19 Thread Bo Shen
As the driver call usb_add_gadget_udc -- usb_add_gadget_udc_release
with NULL as release parameter, so it will use usb_udc_no_release.
So, the release in driver won't used, remove it.

And at the same time, in the usb_add_gadget_udc_release will set the
gadget name, so remove it also in driver.

Signed-off-by: Bo Shen voice.s...@atmel.com
---
 drivers/usb/gadget/udc/at91_udc.c | 9 -
 1 file changed, 9 deletions(-)

diff --git a/drivers/usb/gadget/udc/at91_udc.c 
b/drivers/usb/gadget/udc/at91_udc.c
index 9968f53..b179ab1 100644
--- a/drivers/usb/gadget/udc/at91_udc.c
+++ b/drivers/usb/gadget/udc/at91_udc.c
@@ -1512,20 +1512,11 @@ static irqreturn_t at91_udc_irq (int irq, void *_udc)
 
 /*-*/
 
-static void nop_release(struct device *dev)
-{
-   /* nothing to free */
-}
-
 static struct at91_udc controller = {
.gadget = {
.ops= at91_udc_ops,
.ep0= controller.ep[0].ep,
.name   = driver_name,
-   .dev= {
-   .init_name = gadget,
-   .release = nop_release,
-   }
},
.ep[0] = {
.ep = {
-- 
2.1.0.24.g4109c28

--
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: add PIDs for Matrix Orbital products

2014-11-19 Thread Johan Hovold
On Mon, Nov 17, 2014 at 02:33:17PM -0800, Troy Clark wrote:
 This is a patch to the ftdi_sio_ids.h and ftdi_sio.c files that adds PIDs for
 new Matrix Orbital GTT series products
 
 Signed-off-by: Troy Clark tcl...@matrixorbital.ca

Applied, 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 v3] qcserial: Add support for HP lt4112 LTE/HSPA+ Gobi 4G Modem

2014-11-19 Thread Johan Hovold
On Sun, Nov 16, 2014 at 09:17:30PM +0100, Martin Hauke wrote:
 Added new device layout DEVICE_HWI and also added the USB VID/PID for the
 HP lt4112 LTE/HSPA+ Gobi 4G Modem (Huawei me906e)
 
 Signed-off-by: Martin Hauke mar...@gmx.de

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


[PATCH 1/3] usb: phy: introduce usb_phy_set_event interface

2014-11-19 Thread Kiran Kumar Raparthy
From: Todd Poynor toddpoy...@google.com

usb: phy: introduce usb_phy_set_event interface

PHY drivers require a generic interface to handle per-PHY events.

usb_phy_set_event interface sets event to phy event.
PHY drivers call this interface for each phy event.

Cc: Felipe Balbi ba...@ti.com
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
Cc: linux-ker...@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: Android Kernel Team kernel-t...@android.com
Cc: John Stultz john.stu...@linaro.org
Cc: Sumit Semwal sumit.sem...@linaro.org
Cc: Arve Hj�nnev�g a...@android.com
Cc: Benoit Goby ben...@android.com
Signed-off-by: Todd Poynor toddpoy...@google.com
[kiran: Added context to commit message, squished build fixes
from Benoit Goby and Arve Hj�nnev�g, changed wakelocks usage
to wakeupsource, merged Todd's refactoring logic and simplified
the structures and code and addressed community feedback]
Signed-off-by: Kiran Raparthy kiran.ku...@linaro.org
---
 drivers/usb/phy/phy.c   | 12 
 include/linux/usb/phy.h |  5 +
 2 files changed, 17 insertions(+)

diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c
index 045cd30..2b1039e 100644
--- a/drivers/usb/phy/phy.c
+++ b/drivers/usb/phy/phy.c
@@ -444,3 +444,15 @@ int usb_bind_phy(const char *dev_name, u8 index,
return 0;
 }
 EXPORT_SYMBOL_GPL(usb_bind_phy);
+
+/**
+ * usb_phy_set_event - set event to phy event
+ * @x: the phy returned by usb_get_phy();
+ *
+ * This sets event to phy event
+ */
+void usb_phy_set_event(struct usb_phy *x, unsigned long event)
+{
+   x-last_event = event;
+}
+EXPORT_SYMBOL_GPL(usb_phy_set_event);
diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
index 353053a..3c713ff 100644
--- a/include/linux/usb/phy.h
+++ b/include/linux/usb/phy.h
@@ -210,6 +210,7 @@ extern void usb_put_phy(struct usb_phy *);
 extern void devm_usb_put_phy(struct device *dev, struct usb_phy *x);
 extern int usb_bind_phy(const char *dev_name, u8 index,
const char *phy_dev_name);
+extern void usb_phy_set_event(struct usb_phy *x, unsigned long event);
 #else
 static inline struct usb_phy *usb_get_phy(enum usb_phy_type type)
 {
@@ -251,6 +252,10 @@ static inline int usb_bind_phy(const char *dev_name, u8 
index,
 {
return -EOPNOTSUPP;
 }
+
+static inline void usb_phy_set_event(struct usb_phy *x, unsigned long event)
+{
+}
 #endif
 
 static inline int
-- 
1.8.2.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 2/3] usb: phy: Handle per-PHY event for connect and disconnect events

2014-11-19 Thread Kiran Kumar Raparthy
From: Todd Poynor toddpoy...@google.com

usb: phy: Handle per-PHY event for connnect and disconnect events

When usb is connected and enumerated in device mode or when usb is
disconnected,call usb_phy_set_event from phy drivers to handle per-PHY event.

Cc: Felipe Balbi ba...@ti.com
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
Cc: linux-ker...@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: Android Kernel Team kernel-t...@android.com
Cc: John Stultz john.stu...@linaro.org
Cc: Sumit Semwal sumit.sem...@linaro.org
Cc: Arve Hj�nnev�g a...@android.com
Cc: Benoit Goby ben...@android.com
Signed-off-by: Todd Poynor toddpoy...@google.com
[kiran: Added context to commit message, squished build fixes
from Benoit Goby and Arve Hj�nnev�g, changed wakelocks usage
to wakeupsource, merged Todd's refactoring logic and simplified
the structures and code and addressed community feedback]
Signed-off-by: Kiran Raparthy kiran.ku...@linaro.org
---
 drivers/usb/phy/phy-ab8500-usb.c| 15 +++
 drivers/usb/phy/phy-gpio-vbus-usb.c |  2 ++
 drivers/usb/phy/phy-mv-usb.c|  2 ++
 drivers/usb/phy/phy-tahvo.c |  2 ++
 4 files changed, 21 insertions(+)

diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c
index 11ab2c4..d79fa3e 100644
--- a/drivers/usb/phy/phy-ab8500-usb.c
+++ b/drivers/usb/phy/phy-ab8500-usb.c
@@ -447,6 +447,7 @@ static int ab9540_usb_link_status_update(struct ab8500_usb 
*ab,
event = UX500_MUSB_NONE;
/* Fallback to default B_IDLE as nothing is connected. */
ab-phy.state = OTG_STATE_B_IDLE;
+   usb_phy_set_event(ab-phy, USB_EVENT_NONE);
break;
 
case USB_LINK_ACA_RID_C_NM_9540:
@@ -461,12 +462,14 @@ static int ab9540_usb_link_status_update(struct 
ab8500_usb *ab,
ab8500_usb_peri_phy_en(ab);
atomic_notifier_call_chain(ab-phy.notifier,
UX500_MUSB_PREPARE, ab-vbus_draw);
+   usb_phy_set_event(ab-phy, USB_EVENT_ENUMERATED);
}
if (ab-mode == USB_IDLE) {
ab-mode = USB_PERIPHERAL;
ab8500_usb_peri_phy_en(ab);
atomic_notifier_call_chain(ab-phy.notifier,
UX500_MUSB_PREPARE, ab-vbus_draw);
+   usb_phy_set_event(ab-phy, USB_EVENT_ENUMERATED);
}
if (event != UX500_MUSB_RIDC)
event = UX500_MUSB_VBUS;
@@ -502,6 +505,7 @@ static int ab9540_usb_link_status_update(struct ab8500_usb 
*ab,
event = UX500_MUSB_CHARGER;
atomic_notifier_call_chain(ab-phy.notifier,
event, ab-vbus_draw);
+   usb_phy_set_event(ab-phy, USB_EVENT_CHARGER);
break;
 
case USB_LINK_PHYEN_NO_VBUS_NO_IDGND_9540:
@@ -526,6 +530,7 @@ static int ab9540_usb_link_status_update(struct ab8500_usb 
*ab,
ab-mode = USB_IDLE;
ab-phy.otg-default_a = false;
ab-vbus_draw = 0;
+   usb_phy_set_event(ab-phy, USB_EVENT_NONE);
}
}
break;
@@ -585,6 +590,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb 
*ab,
 * is connected
 */
ab-phy.state = OTG_STATE_B_IDLE;
+   usb_phy_set_event(ab-phy, USB_EVENT_NONE);
break;
 
case USB_LINK_ACA_RID_C_NM_8540:
@@ -598,6 +604,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb 
*ab,
ab8500_usb_peri_phy_en(ab);
atomic_notifier_call_chain(ab-phy.notifier,
UX500_MUSB_PREPARE, ab-vbus_draw);
+   usb_phy_set_event(ab-phy, USB_EVENT_ENUMERATED);
}
if (event != UX500_MUSB_RIDC)
event = UX500_MUSB_VBUS;
@@ -626,6 +633,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb 
*ab,
event = UX500_MUSB_CHARGER;
atomic_notifier_call_chain(ab-phy.notifier,
event, ab-vbus_draw);
+   usb_phy_set_event(ab-phy, USB_EVENT_CHARGER);
break;
 
case USB_LINK_PHYEN_NO_VBUS_NO_IDGND_8540:
@@ -648,6 +656,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb 
*ab,
ab-mode = USB_IDLE;
ab-phy.otg-default_a = false;
ab-vbus_draw = 0;
+   usb_phy_set_event(ab-phy, USB_EVENT_NONE);
}
break;
 
@@ -694,6 +703,7 @@ static int ab8505_usb_link_status_update(struct ab8500_usb 
*ab,
 * is connected
 */
   

[PATCH 3/3] usb: phy: hold wakeupsource when USB is enumerated in peripheral mode

2014-11-19 Thread Kiran Kumar Raparthy
From: Todd Poynor toddpoy...@google.com

usb: phy: hold wakeupsource when USB is enumerated in peripheral mode

Some systems require a mechanism to prevent system to enter into suspend
state when USB is connected and enumerated in peripheral mode.

This patch provides an interface to hold a wakeupsource to prevent suspend.
PHY drivers can use this interface when USB is connected and enumerated in
peripheral mode.

A timed wakeupsource is temporarily held on USB disconnect events, to allow
the rest of the system to react to the USB disconnection (dropping host
sessions, updating charger status, etc.) prior to re-allowing suspend.

Cc: Felipe Balbi ba...@ti.com
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
Cc: linux-ker...@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: Android Kernel Team kernel-t...@android.com
Cc: John Stultz john.stu...@linaro.org
Cc: Sumit Semwal sumit.sem...@linaro.org
Cc: Arve Hj�nnev�g a...@android.com
Cc: Benoit Goby ben...@android.com
Signed-off-by: Todd Poynor toddpoy...@google.com
[kiran: Added context to commit message, squished build fixes
from Benoit Goby and Arve Hj�nnev�g, changed wakelocks usage
to wakeupsource, merged Todd's refactoring logic and simplified
the structures and code and addressed community feedback]
Signed-off-by: Kiran Raparthy kiran.ku...@linaro.org
---
 drivers/usb/phy/phy.c   | 29 +++--
 include/linux/usb/phy.h |  5 +
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c
index 2b1039e..b8a2d56 100644
--- a/drivers/usb/phy/phy.c
+++ b/drivers/usb/phy/phy.c
@@ -329,6 +329,7 @@ int usb_add_phy(struct usb_phy *x, enum usb_phy_type type)
int ret = 0;
unsigned long   flags;
struct usb_phy  *phy;
+   char wsource_name[40];
 
if (x-type != USB_PHY_TYPE_UNDEFINED) {
dev_err(x-dev, not accepting initialized PHY %s\n, x-label);
@@ -351,6 +352,10 @@ int usb_add_phy(struct usb_phy *x, enum usb_phy_type type)
x-type = type;
list_add_tail(x-head, phy_list);
 
+   snprintf(wsource_name, sizeof(wsource_name), vbus-%s,
+   dev_name(x-dev));
+   wakeup_source_init(x-wsource, wsource_name);
+
 out:
spin_unlock_irqrestore(phy_lock, flags);
return ret;
@@ -402,6 +407,7 @@ void usb_remove_phy(struct usb_phy *x)
 
spin_lock_irqsave(phy_lock, flags);
if (x) {
+   wakeup_source_trash(x-wsource);
list_for_each_entry(phy_bind, phy_bind_list, list)
if (phy_bind-phy == x)
phy_bind-phy = NULL;
@@ -446,13 +452,32 @@ int usb_bind_phy(const char *dev_name, u8 index,
 EXPORT_SYMBOL_GPL(usb_bind_phy);
 
 /**
- * usb_phy_set_event - set event to phy event
+ * usb_phy_set_event - set event to phy event and
+ * hold/temporarily hold wakeupsource
  * @x: the phy returned by usb_get_phy();
  *
- * This sets event to phy event
+ * This holds per-PHY wakeupsource/timed wakeupsource
  */
 void usb_phy_set_event(struct usb_phy *x, unsigned long event)
 {
+
x-last_event = event;
+
+   switch (event) {
+   case USB_EVENT_ENUMERATED:
+   __pm_stay_awake(x-wsource);
+   break;
+
+   case USB_EVENT_NONE:
+   case USB_EVENT_ID:
+   case USB_EVENT_VBUS:
+   case USB_EVENT_CHARGER:
+   __pm_wakeup_event(x-wsource,
+ USB_PHY_DEFAULT_WAKEUP_SRC_TIMEOUT);
+   break;
+
+   default:
+   break;
+   }
 }
 EXPORT_SYMBOL_GPL(usb_phy_set_event);
diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
index 3c713ff..c593fc6 100644
--- a/include/linux/usb/phy.h
+++ b/include/linux/usb/phy.h
@@ -12,6 +12,8 @@
 #include linux/notifier.h
 #include linux/usb.h
 
+#define USB_PHY_DEFAULT_WAKEUP_SRC_TIMEOUT msecs_to_jiffies(2000)
+
 enum usb_phy_interface {
USBPHY_INTERFACE_MODE_UNKNOWN,
USBPHY_INTERFACE_MODE_UTMI,
@@ -89,6 +91,9 @@ struct usb_phy {
/* for notification of usb_phy_events */
struct atomic_notifier_head notifier;
 
+   /* wakeup source */
+   struct wakeup_sourcewsource;
+
/* to pass extra port status to the root hub */
u16 port_status;
u16 port_change;
-- 
1.8.2.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: USB OTG doesn't work in HOST mode on OMAP3 processor on 3.18-rc5

2014-11-19 Thread Enric Balletbo Serra
Hi Tony,

2014-11-18 16:42 GMT+01:00 Tony Lindgren t...@atomide.com:
 * Enric Balletbo Serra eballe...@gmail.com [141118 01:04]:
 Hi Tony,

 2014-11-17 19:04 GMT+01:00 Tony Lindgren t...@atomide.com:
 
  Just tested v3.18-rc5 with beagleboard xm, and the host mode
  enumerates the devices, then may fail with insufficient bus power
  at least for the WLAN device I tried with.
 

 Is this with following options ?

 CONFIG_USB_MUSB_DUAL_ROLE=y
 # CONFIG_USB_MUSB_HOST is not set
 # CONFIG_USB_MUSB_GADGET is not set

 Because with these options doesn't work for me. It only works if I
 don't use dual role mode

 CONFIG_USB_MUSB_HOST=y
 CONFIG_USB_MUSB_DUAL_ROLE is not set

 Weird. Yes I have CONFIG_USB_MUSB_DUAL_ROLE. AFAIK there's actually
 no way to disable the role switching in MUSB hardware, the hardware
 tries to do things on it's own anyways. So it's probably best to always
 set it to CONFIG_USB_MUSB_DUAL_ROLE=y unless size of the code is an
 issue.

  I noticed that this only works with CONFIG_USB_MUSB_HDRC and
  CONFIG_TWL4030_USB built into the kernel. No luck so far with them
  as loadable modules for some reason. Looks like also USB gadgets
  fail with MUSB as modules.

 I found the core issue with loadable modules, we currently need to
 have just one platform glue layer module compiled in. I have a
 fix coming up for that..

 It's weird, for me fails in both cases, built-in and with loadable
 modules. Connecting the OTG Cable Adapter with a pendrive reports

 [   51.462432] twl4030_usb 4807.i2c:twl@48:twl4030-usb:
 HW_CONDITIONS 0x54/84; link 1
 [   51.470916] twl4030_usb 4807.i2c:twl@48:twl4030-usb:
 twl4030_usb_runtime_resume
 [   51.487274] musb-hdrc musb-hdrc.0.auto: ID GND
 [   52.480712] twl4030_usb 4807.i2c:twl@48:twl4030-usb:
 HW_CONDITIONS 0x54/84; link 1
 [   53.489044] twl4030_usb 4807.i2c:twl@48:twl4030-usb:
 HW_CONDITIONS 0x54/84; link 1

 And then polls until I disconnect the OTG Cable Adapter with the pendrive.

 [   71.488983] twl4030_usb 4807.i2c:twl@48:twl4030-usb:
 HW_CONDITIONS 0x54/84; link 1
 [   71.778930] twl4030_usb 4807.i2c:twl@48:twl4030-usb:
 HW_CONDITIONS 0x50/80; link 4
 [   71.787536] musb-hdrc musb-hdrc.0.auto: VBUS Disconnect
 [   72.489044] twl4030_usb 4807.i2c:twl@48:twl4030-usb:
 HW_CONDITIONS 0x50/80; link 4
 [   74.088714] twl4030_usb 4807.i2c:twl@48:twl4030-usb:
 twl4030_usb_runtime_suspend

 Looks like the twl4030-usb is producing interrupts alright. Maybe
 check your MUSB configuration one more time. See the attached
 patch, but note you need to only select the glue layer for the
 CONFIG_USB_MUSB_OMAP2PLUS option and disable other glue layer
 module options.


Checked again, and no luck. It's very weird because from the OTG point
of view, OTG is exactly the same between Beagleboard-XM and IGEPv2.

Can you confirm that you're using kernel 3.18-rc5 without other
patches applied ? At this moment, I don't have a Beagleboard-XM to
test, I'll try to get one because at this moment I'm a bit stuck with
this problem.

 Also, you may want to monitor the VBUS line in host mode. If the
 VBUS does not come up fast enough, MUSB hardware will give up as
 it's again trying to do things on its own.

  And on the 37xx EVM, I've never had any luck getting any twl4030_usb
  interrupts for some reason.

 Turns out the 37xx EVM is using an isp1507 phy instead of the
 twl4030 phy. The proper fix for that will be to start using the
 usb-nop-xceiv or phy-ulpi when we have drivers/phy/ driver for
 it. Right now trying to use it seems to fail with the following
 error:

 HS USB OTG: no PHY configured

 Regards,

 Tony


Thanks,
  Enric

 8 -
 From: Tony Lindgren t...@atomide.com
 Date: Mon, 17 Nov 2014 07:53:59 -0800
 Subject: [PATCH] ARM: omap2plus_defconfig: Enable USB as loadable modules

 NOTE: Currently only one MUSB glue layer can be selected
 below because of the ifdefs, I'll do a fix for that.

 --- a/arch/arm/configs/omap2plus_defconfig
 +++ b/arch/arm/configs/omap2plus_defconfig
 @@ -270,17 +270,92 @@ CONFIG_SND_OMAP_SOC_OMAP_ABE_TWL6040=m
  CONFIG_SND_OMAP_SOC_OMAP3_PANDORA=m
  CONFIG_USB=y
  CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
 +CONFIG_USB_DYNAMIC_MINORS=y
 +CONFIG_USB_OTG=y
  CONFIG_USB_MON=y
  CONFIG_USB_WDM=y
  CONFIG_USB_STORAGE=y
 +CONFIG_USB_MUSB_HDRC=m
 +CONFIG_USB_MUSB_TUSB6010=m
 +CONFIG_USB_MUSB_OMAP2PLUS=m
 +CONFIG_USB_MUSB_AM35X=m
 +CONFIG_USB_MUSB_DSPS=m
  CONFIG_USB_DWC3=m
 -CONFIG_USB_TEST=y
 -CONFIG_AM335X_PHY_USB=y
 +CONFIG_USB_SERIAL=m
 +CONFIG_USB_SERIAL_GENERIC=y
 +CONFIG_USB_SERIAL_SIMPLE=m
 +CONFIG_USB_SERIAL_FTDI_SIO=m
 +CONFIG_USB_SERIAL_PL2303=m
 +CONFIG_USB_EMI62=m
 +CONFIG_USB_EMI26=m
 +CONFIG_USB_ADUTUX=m
 +CONFIG_USB_SEVSEG=m
 +CONFIG_USB_RIO500=m
 +CONFIG_USB_LEGOTOWER=m
 +CONFIG_USB_LCD=m
 +CONFIG_USB_LED=m
 +CONFIG_USB_CYPRESS_CY7C63=m
 +CONFIG_USB_CYTHERM=m
 +CONFIG_USB_IDMOUSE=m
 +CONFIG_USB_FTDI_ELAN=m
 +CONFIG_USB_APPLEDISPLAY=m
 +CONFIG_USB_SISUSBVGA=m
 +CONFIG_USB_SISUSBVGA_CON=y
 

Re: [PATCH] usb: ehci-orion: enable big-endian support

2014-11-19 Thread Thomas Petazzoni
Dear Marcin Wojtas,

On Thu, 13 Nov 2014 00:49:50 +0100, Marcin Wojtas wrote:
 This commit fixes ehci-orion operation in big-endian mode by enabling byteswap
 when accessing registers using 'rdl' and 'wrl' macros.
 
 Signed-off-by: Grzegorz Jaszczyk j...@semihalf.com
 Signed-off-by: Marcin Wojtas m...@semihalf.com
 Reviewed-by: Gregory CLEMENT gregory.clem...@free-electrons.com

Tested-by: Thomas Petazzoni thomas.petazz...@free-electrons.com

Indeed, on Armada XP GP, without this patch, no USB devices are
detected when the kernel runs in big endian mode. With this patch
applied, a USB key is properly detected and I can mount/access it.

Moreover, using {readl,writel}_relaxed() is safe here: even though
those I/O accessors are not yet available on all architectures, the
ehci-orion driver has a depends on PLAT_ORION, so it can only be
enabled on ARM, which has those accessors available.

Greg, Alan, could you apply Marcin's patch?

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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


Your 200,000.00 Gbp

2014-11-19 Thread -
Hi!

You're among Families that will receive 200,000.00Gbp Grant from UN Approved 
Funds for Less Privileges, Tsunami, Earthquake and Flood victims.

Send your family Grant Number: UN/GRANT/VIC2014 to Andrej Mahecic on 
+443303501130 / un@inbox.com for your Transfer.

Yours Sincerely,

Vannina Maestracci
On Behalf of UN Secretary-General Ban Ki-Moon
--
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 net-next v2 1/2] r8152: adjust r8152_submit_rx

2014-11-19 Thread Sergei Shtylyov

Hello.

On 11/19/2014 8:20 AM, Hayes Wang wrote:


The behavior of handling the returned status from r8152_submit_rx()
is almost same, so let r8152_submit_rx() deal with the error
directly. This could avoid the duplicate code.



Signed-off-by: Hayes Wang hayesw...@realtek.com
---
  drivers/net/usb/r8152.c | 41 +
  1 file changed, 21 insertions(+), 20 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 0a30fd3..df0868b 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c

[...]

@@ -1806,11 +1789,29 @@ static void bottom_half(unsigned long data)
  static
  int r8152_submit_rx(struct r8152 *tp, struct rx_agg *agg, gfp_t mem_flags)
  {
+   int ret = 0;


   Initialization not needed.


+
usb_fill_bulk_urb(agg-urb, tp-udev, usb_rcvbulkpipe(tp-udev, 1),
  agg-head, agg_buf_sz,
  (usb_complete_t)read_bulk_callback, agg);

-   return usb_submit_urb(agg-urb, mem_flags);
+   ret = usb_submit_urb(agg-urb, mem_flags);
+


   Empty line not needed here either.


+   if (ret == -ENODEV) {
+   set_bit(RTL8152_UNPLUG, tp-flags);
+   netif_device_detach(tp-netdev);
+   } else if (ret) {
+   struct urb *urb = agg-urb;
+   unsigned long flags;
+
+   urb-actual_length = 0;
+   spin_lock_irqsave(tp-rx_lock, flags);
+   list_add_tail(agg-list, tp-rx_done);
+   spin_unlock_irqrestore(tp-rx_lock, flags);
+   tasklet_schedule(tp-tl);
+   }
+
+   return ret;
  }

[...]

WBR, Sergei

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


[PATCH] usb: dwc2: Fix build warning when CONFIG_PM_SLEEP=n

2014-11-19 Thread Fabio Estevam
Building with bcm2835_defconfig, which has CONFIG_PM_SLEEP=n causes the 
following build warning:

drivers/usb/dwc2/platform.c:227:12: warning: 'dwc2_suspend' defined but not 
used [-Wunused-function]
drivers/usb/dwc2/platform.c:237:12: warning: 'dwc2_resume' defined but not used 
[-Wunused-function]

Annotate these functions with '__maybe_unused' to prevent the warnings.

Reported-by: Olof's autobuilder bu...@lixom.net
Signed-off-by: Fabio Estevam fabio.este...@freescale.com
---
 drivers/usb/dwc2/platform.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 57eb8a3..ff0ed0b 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -224,7 +224,7 @@ static int dwc2_driver_probe(struct platform_device *dev)
return retval;
 }
 
-static int dwc2_suspend(struct device *dev)
+static int __maybe_unused dwc2_suspend(struct device *dev)
 {
struct dwc2_hsotg *dwc2 = dev_get_drvdata(dev);
int ret = 0;
@@ -234,7 +234,7 @@ static int dwc2_suspend(struct device *dev)
return ret;
 }
 
-static int dwc2_resume(struct device *dev)
+static int __maybe_unused dwc2_resume(struct device *dev)
 {
struct dwc2_hsotg *dwc2 = dev_get_drvdata(dev);
int ret = 0;
-- 
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] HID: yet another buggy ELAN touchscreen

2014-11-19 Thread Jiri Kosina

[ Greg and linux-usb@ added to CC ]

On Mon, 17 Nov 2014, Oliver Neukum wrote:

 The touchscreen needs the same quirk as the other models.
 
 Signed-off-by: Oliver Neukum oneu...@suse.de
 Reported-by: Bryan Poling poli0...@umn.edu
 CC: sta...@vger.kernel.org
 ---
  drivers/hid/hid-ids.h   | 1 +
  drivers/hid/usbhid/hid-quirks.c | 1 +
  drivers/usb/core/quirks.c   | 3 +++

Greg, are you OK with me taking the whole lot through hid.git in one 
commit? (USB quirks and HID quirks for Elan devices have been merged 
independently for previous 3 devices, but I don't think it's worth the 
hassle splitting it).

Thanks.

  3 files changed, 5 insertions(+)
 
 diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
 index e23ab8b..282ffbe 100644
 --- a/drivers/hid/hid-ids.h
 +++ b/drivers/hid/hid-ids.h
 @@ -299,6 +299,7 @@
  #define USB_VENDOR_ID_ELAN   0x04f3
  #define USB_DEVICE_ID_ELAN_TOUCHSCREEN   0x0089
  #define USB_DEVICE_ID_ELAN_TOUCHSCREEN_009B  0x009b
 +#define USB_DEVICE_ID_ELAN_TOUCHSCREEN_010c  0x010c
  #define USB_DEVICE_ID_ELAN_TOUCHSCREEN_016F  0x016f
  
  #define USB_VENDOR_ID_ELECOM 0x056e
 diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
 index 5014bb5..08b9626 100644
 --- a/drivers/hid/usbhid/hid-quirks.c
 +++ b/drivers/hid/usbhid/hid-quirks.c
 @@ -72,6 +72,7 @@ static const struct hid_blacklist {
   { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET },
   { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN, 
 HID_QUIRK_ALWAYS_POLL },
   { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN_009B, 
 HID_QUIRK_ALWAYS_POLL },
 + { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN_010c, 
 HID_QUIRK_ALWAYS_POLL },
   { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN_016F, 
 HID_QUIRK_ALWAYS_POLL },
   { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET },
   { USB_VENDOR_ID_FORMOSA, USB_DEVICE_ID_FORMOSA_IR_RECEIVER, 
 HID_QUIRK_NO_INIT_REPORTS },
 diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
 index 39b4081..8e8bc4f 100644
 --- a/drivers/usb/core/quirks.c
 +++ b/drivers/usb/core/quirks.c
 @@ -100,6 +100,9 @@ static const struct usb_device_id usb_quirk_list[] = {
   { USB_DEVICE(0x04f3, 0x009b), .driver_info =
   USB_QUIRK_DEVICE_QUALIFIER },
  
 + { USB_DEVICE(0x04f3, 0x010c), .driver_info =
 + USB_QUIRK_DEVICE_QUALIFIER },
 +
   { USB_DEVICE(0x04f3, 0x016f), .driver_info =
   USB_QUIRK_DEVICE_QUALIFIER },
  
 -- 
 1.8.4.5
 

-- 
Jiri Kosina
SUSE Labs
--
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: dwc2: Fix build warning when CONFIG_PM_SLEEP=n

2014-11-19 Thread Felipe Balbi
HI,

On Wed, Nov 19, 2014 at 12:37:53PM -0200, Fabio Estevam wrote:
 Building with bcm2835_defconfig, which has CONFIG_PM_SLEEP=n causes the 
 following build warning:
 
 drivers/usb/dwc2/platform.c:227:12: warning: 'dwc2_suspend' defined but not 
 used [-Wunused-function]
 drivers/usb/dwc2/platform.c:237:12: warning: 'dwc2_resume' defined but not 
 used [-Wunused-function]
 
 Annotate these functions with '__maybe_unused' to prevent the warnings.
 
 Reported-by: Olof's autobuilder bu...@lixom.net
 Signed-off-by: Fabio Estevam fabio.este...@freescale.com
 ---
  drivers/usb/dwc2/platform.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
 index 57eb8a3..ff0ed0b 100644
 --- a/drivers/usb/dwc2/platform.c
 +++ b/drivers/usb/dwc2/platform.c
 @@ -224,7 +224,7 @@ static int dwc2_driver_probe(struct platform_device *dev)
   return retval;
  }
  
 -static int dwc2_suspend(struct device *dev)
 +static int __maybe_unused dwc2_suspend(struct device *dev)

that SET_SYSTEM_SLEEP_PM_OPS again.

Rafael, do you mind taking a patch like below:

diff --git a/include/linux/pm.h b/include/linux/pm.h
index 383fd68..928e295 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -318,7 +318,6 @@ struct dev_pm_ops {
int (*runtime_idle)(struct device *dev);
 };
 
-#ifdef CONFIG_PM_SLEEP
 #define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
.suspend = suspend_fn, \
.resume = resume_fn, \
@@ -326,11 +325,7 @@ struct dev_pm_ops {
.thaw = resume_fn, \
.poweroff = suspend_fn, \
.restore = resume_fn,
-#else
-#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
-#endif
 
-#ifdef CONFIG_PM_SLEEP
 #define SET_LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
.suspend_late = suspend_fn, \
.resume_early = resume_fn, \
@@ -338,27 +333,16 @@ struct dev_pm_ops {
.thaw_early = resume_fn, \
.poweroff_late = suspend_fn, \
.restore_early = resume_fn,
-#else
-#define SET_LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
-#endif
 
-#ifdef CONFIG_PM_RUNTIME
 #define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
.runtime_suspend = suspend_fn, \
.runtime_resume = resume_fn, \
.runtime_idle = idle_fn,
-#else
-#define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn)
-#endif
 
-#ifdef CONFIG_PM
 #define SET_PM_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
.runtime_suspend = suspend_fn, \
.runtime_resume = resume_fn, \
.runtime_idle = idle_fn,
-#else
-#define SET_PM_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn)
-#endif
 
 /*
  * Use this if you want to use the same suspend and resume callbacks for 
suspend

nobody will ever build a kernel without CONFIG_PM or any of its friends
anyway and all that ifdeferry or __maybe_unused just to silence
compilers warnings are very annoying.

-- 
balbi


signature.asc
Description: Digital signature


Re: USB devices disappering on resume on pantherpoint chipset with dock

2014-11-19 Thread Mathias Nyman
Hi

On 19.11.2014 01:03, Brian Campbell wrote:
 Hi,
 
 I'm having trouble with USB devices connected to a Thinkpad X230's dock
 disappearing after a few suspend/resume cycles.  Devices connected directly to
 the laptop rather than the dock are not affected.  The main symptom in the
 logs is a complaint about bandwidth, and comes from the bandwidth checking
 code in the xhci driver that is only used for Intel Pantherpoint chipsets, as
 far as I can tell.
 
 To give a controlled example, I booted the laptop running 3.17.1 with extra
 xhci logging, filled up the USB sockets on the dock with a flash drive, a
 keyboard and a couple of mice, then suspended and resumed it until the
 keyboard stopped working.  Through the first two suspends everything works,
 but the reported bandwidth changes:
 
 [  205.933357] xhci_hcd :00:14.0: Recalculating BW for rootport 3
 [  205.933360] xhci_hcd :00:14.0: Final bandwidth: 27, Limit: 1607, 
 Reserved: 322, Available: 78 percent
 
 [  409.192473] xhci_hcd :00:14.0: Recalculating BW for rootport 3
 [  409.192475] xhci_hcd :00:14.0: Final bandwidth: 402, Limit: 1607, 
 Reserved: 322, Available: 54 percent
 
 [  447.874989] xhci_hcd :00:14.0: Recalculating BW for rootport 3
 [  447.874991] xhci_hcd :00:14.0: Final bandwidth: 777, Limit: 1607, 
 Reserved: 322, Available: 31 percent
 
 (It also reports bandwidth for some individual ports, but these don't change.)
 On the third resume it changes again, then later complains about the mice:
 
 [  467.998687] xhci_hcd :00:14.0: Recalculating BW for rootport 3
 [  467.998689] xhci_hcd :00:14.0: Final bandwidth: 1152, Limit: 1607, 
 Reserved: 322, Available: 8 percent
 ...
 [  469.592653] xhci_hcd :00:14.0: Adding 1 ep ctxs, 11 now active.
 [  469.592655] xhci_hcd :00:14.0: Recalculating BW for rootport 3
 [  469.592656] xhci_hcd :00:14.0: Not enough bandwidth on HS bus for 
 newly activated TT.
 [  469.592657] xhci_hcd :00:14.0: Removing 1 failed ep ctxs, 10 now 
 active.
 [  469.592658] xhci_hcd :00:14.0: Not enough bandwidth
 [  469.592659] xhci_hcd :00:14.0: xhci_reset_bandwidth called for udev 
 880210693800
 [  469.592661] usb 3-3.4: Busted HC?  Not enough HCD resources for old 
 configuration.
 
 There are similar messages for another attempt at this mouse, and another pair
 for the other mouse.  Then on the fourth resume the bandwidth is exhausted:
 
 [  492.742794] xhci_hcd :00:14.0: Recalculating BW for rootport 3
 [  492.742796] xhci_hcd :00:14.0: Final bandwidth: 1277, Limit: 1607, 
 Reserved: 322, Available: 0 percent
 
 And then the keyboard fails too.
 
 I originally had the problem with Ubuntu 14.04's stock kernel, so it's been
 around for a while, perhaps always.  A bug filed with Ubuntu suggests that it
 also happens with some Dell machines, too
 (https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1116525).  I put more
 logs and system details up at http://www.z273.org.uk/tmp/2014-x230-usb-dock/
 in case they're useful to someone.
 
 

Thanks for the detailed logs, and the analysis so far. 
Looks like we end up with old used bandwidth values after suspend/resume, and 
then
add new bandwidth reserved values on top.

I tried to reproduce it myself with a headset and keyboard connected via a usb2 
hub
to a usb3 port. but wasn't able to reproduce it 

The logs also show several cases of:

[  470.110821] xhci_hcd :00:14.0:Setup ERROR: setup context command for 
slot 5.
[  470.110822] usb 3-3.1: hub failed to enable device, error -22
[  470.370725] xhci_hcd :00:14.0: Resetting device with slot ID 5
[  470.370728] xhci_hcd :00:14.0: // Ding dong!
[  470.370739] xhci_hcd :00:14.0: Completed reset device command.
[  470.370744] xhci_hcd :00:14.0: Can't reset device (slot ID 5) in default 
state
[  470.370745] xhci_hcd :00:14.0: Not freeing device rings.

One theory would be that when we fail to reset the device because it's already 
in the
default state (state after reset) we end up not freeing the rings, and won't 
free the 
reserved bandwith either.

If you wan't you could try this hack, just to check the theory. 
It will free the reserved bandwith event if resetting the device fails.

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 2a5d45b..e655459 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -3520,7 +3520,7 @@ int xhci_discover_or_reset_device(struct usb_hcd *hcd, 
struct usb_device *udev)
xhci_dbg(xhci, Not freeing device rings.\n);
/* Don't treat this as an error.  May change my mind later. */
ret = 0;
-   goto command_cleanup;
+   break;
case COMP_SUCCESS:
xhci_dbg(xhci, Successful reset device command.\n);
break;


-Mathias


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

[PATCHv5 5/7] phy: remove the old lookup method

2014-11-19 Thread Heikki Krogerus
The users of the old method are now converted to the new one.

Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
---
 drivers/phy/phy-bcm-kona-usb2.c  |  2 +-
 drivers/phy/phy-berlin-sata.c|  2 +-
 drivers/phy/phy-core.c   | 49 +++-
 drivers/phy/phy-exynos-dp-video.c|  2 +-
 drivers/phy/phy-exynos-mipi-video.c  |  2 +-
 drivers/phy/phy-exynos5-usbdrd.c |  3 +--
 drivers/phy/phy-exynos5250-sata.c|  2 +-
 drivers/phy/phy-hix5hd2-sata.c   |  2 +-
 drivers/phy/phy-miphy365x.c  |  2 +-
 drivers/phy/phy-mvebu-sata.c |  2 +-
 drivers/phy/phy-omap-usb2.c  |  2 +-
 drivers/phy/phy-qcom-apq8064-sata.c  |  3 +--
 drivers/phy/phy-qcom-ipq806x-sata.c  |  3 +--
 drivers/phy/phy-rcar-gen2.c  |  2 +-
 drivers/phy/phy-samsung-usb2.c   |  3 +--
 drivers/phy/phy-spear1310-miphy.c|  2 +-
 drivers/phy/phy-spear1340-miphy.c|  2 +-
 drivers/phy/phy-stih407-usb.c|  2 +-
 drivers/phy/phy-stih41x-usb.c|  2 +-
 drivers/phy/phy-sun4i-usb.c  |  2 +-
 drivers/phy/phy-ti-pipe3.c   |  2 +-
 drivers/phy/phy-twl4030-usb.c|  2 +-
 drivers/phy/phy-xgene.c  |  2 +-
 drivers/pinctrl/pinctrl-tegra-xusb.c |  4 +--
 include/linux/phy/phy.h  | 38 +++-
 25 files changed, 32 insertions(+), 107 deletions(-)

diff --git a/drivers/phy/phy-bcm-kona-usb2.c b/drivers/phy/phy-bcm-kona-usb2.c
index c1e0ca3..ef2dc1a 100644
--- a/drivers/phy/phy-bcm-kona-usb2.c
+++ b/drivers/phy/phy-bcm-kona-usb2.c
@@ -117,7 +117,7 @@ static int bcm_kona_usb2_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, phy);
 
-   gphy = devm_phy_create(dev, NULL, ops, NULL);
+   gphy = devm_phy_create(dev, NULL, ops);
if (IS_ERR(gphy))
return PTR_ERR(gphy);
 
diff --git a/drivers/phy/phy-berlin-sata.c b/drivers/phy/phy-berlin-sata.c
index 69ced52..99bbf91 100644
--- a/drivers/phy/phy-berlin-sata.c
+++ b/drivers/phy/phy-berlin-sata.c
@@ -239,7 +239,7 @@ static int phy_berlin_sata_probe(struct platform_device 
*pdev)
if (!phy_desc)
return -ENOMEM;
 
-   phy = devm_phy_create(dev, NULL, phy_berlin_sata_ops, NULL);
+   phy = devm_phy_create(dev, NULL, phy_berlin_sata_ops);
if (IS_ERR(phy)) {
dev_err(dev, failed to create PHY %d\n, phy_id);
return PTR_ERR(phy);
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 9c3f0dc..e7d93f2 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -55,36 +55,6 @@ static int devm_phy_match(struct device *dev, void *res, 
void *match_data)
return res == match_data;
 }
 
-static struct phy *phy_lookup(struct device *device, const char *port)
-{
-   unsigned int count;
-   struct phy *phy;
-   struct device *dev;
-   struct phy_consumer *consumers;
-   struct class_dev_iter iter;
-
-   class_dev_iter_init(iter, phy_class, NULL, NULL);
-   while ((dev = class_dev_iter_next(iter))) {
-   phy = to_phy(dev);
-
-   if (!phy-init_data)
-   continue;
-   count = phy-init_data-num_consumers;
-   consumers = phy-init_data-consumers;
-   while (count--) {
-   if (!strcmp(consumers-dev_name, dev_name(device)) 
-   !strcmp(consumers-port, port)) {
-   class_dev_iter_exit(iter);
-   return phy;
-   }
-   consumers++;
-   }
-   }
-
-   class_dev_iter_exit(iter);
-   return ERR_PTR(-ENODEV);
-}
-
 /**
  * phy_create_lookup() - allocate and register PHY/device association
  * @phy: the phy of the association
@@ -148,7 +118,6 @@ static struct phy *phy_find(struct device *dev, const char 
*con_id)
 {
const char *dev_id = dev_name(dev);
struct phy_lookup *p, *pl = NULL;
-   struct phy *phy;
 
mutex_lock(phy_provider_mutex);
list_for_each_entry(p, phys, node)
@@ -158,12 +127,7 @@ static struct phy *phy_find(struct device *dev, const char 
*con_id)
}
mutex_unlock(phy_provider_mutex);
 
-   phy = pl ? pl-phy : ERR_PTR(-ENODEV);
-
-   /* fall-back to the old lookup method for now */
-   if (IS_ERR(phy))
-   phy = phy_lookup(dev, con_id);
-   return phy;
+   return pl ? pl-phy : ERR_PTR(-ENODEV);
 }
 
 static struct phy_provider *of_phy_provider_lookup(struct device_node *node)
@@ -670,13 +634,11 @@ EXPORT_SYMBOL_GPL(devm_of_phy_get);
  * @dev: device that is creating the new phy
  * @node: device node of the phy
  * @ops: function pointers for performing phy operations
- * @init_data: contains the list of PHY consumers or NULL
  *
  * Called to create a phy using phy framework.
  */
 

[PATCHv5 6/7] base: platform: name the device already during allocation

2014-11-19 Thread Heikki Krogerus
The device name is usually required when assigning resources
like clocks to platform devices. The problem is that the
device name is not know before platform_device_add is called
and that can be too late as the drivers may have already
requested the resources when the function returns. By naming
the device already in platform_device_alloc, the resources
can be assigned before platform_device_add is called.

This change allows different kinds of probe drivers to pass
forward their resources to the actual driver. The first
place where we need it is dwc3 controllers host glue code
(drivers/usb/dwc3/host.c) to pass the phy's to xhci.

Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/base/platform.c | 69 +
 1 file changed, 41 insertions(+), 28 deletions(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index cdb6c07..d2217f3 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -195,11 +195,41 @@ void platform_device_put(struct platform_device *pdev)
 }
 EXPORT_SYMBOL_GPL(platform_device_put);
 
+static int pdev_set_name(struct platform_device *pdev)
+{
+   int ret;
+
+   switch (pdev-id) {
+   default:
+   return dev_set_name(pdev-dev, %s.%d, pdev-name,  pdev-id);
+   case PLATFORM_DEVID_NONE:
+   return dev_set_name(pdev-dev, %s, pdev-name);
+   case PLATFORM_DEVID_AUTO:
+   /*
+* Automatically allocated device ID. We mark it as such so
+* that we remember it must be freed, and we append a suffix
+* to avoid namespace collision with explicit IDs.
+*/
+   ret = ida_simple_get(platform_devid_ida, 0, 0, GFP_KERNEL);
+   if (ret  0)
+   return ret;
+   pdev-id = ret;
+   pdev-id_auto = true;
+   return dev_set_name(pdev-dev, %s.%d.auto, pdev-name,
+   pdev-id);
+   }
+
+   return 0;
+}
+
 static void platform_device_release(struct device *dev)
 {
struct platform_object *pa = container_of(dev, struct platform_object,
  pdev.dev);
 
+   if (pa-pdev.id_auto)
+   ida_simple_remove(platform_devid_ida, pa-pdev.id);
+
of_device_node_put(pa-pdev.dev);
kfree(pa-pdev.dev.platform_data);
kfree(pa-pdev.mfd_cell);
@@ -228,6 +258,10 @@ struct platform_device *platform_device_alloc(const char 
*name, int id)
device_initialize(pa-pdev.dev);
pa-pdev.dev.release = platform_device_release;
arch_setup_pdev_archdata(pa-pdev);
+   if (pdev_set_name(pa-pdev)) {
+   kfree(pa);
+   return NULL;
+   }
}
 
return pa ? pa-pdev : NULL;
@@ -308,28 +342,6 @@ int platform_device_add(struct platform_device *pdev)
 
pdev-dev.bus = platform_bus_type;
 
-   switch (pdev-id) {
-   default:
-   dev_set_name(pdev-dev, %s.%d, pdev-name,  pdev-id);
-   break;
-   case PLATFORM_DEVID_NONE:
-   dev_set_name(pdev-dev, %s, pdev-name);
-   break;
-   case PLATFORM_DEVID_AUTO:
-   /*
-* Automatically allocated device ID. We mark it as such so
-* that we remember it must be freed, and we append a suffix
-* to avoid namespace collision with explicit IDs.
-*/
-   ret = ida_simple_get(platform_devid_ida, 0, 0, GFP_KERNEL);
-   if (ret  0)
-   goto err_out;
-   pdev-id = ret;
-   pdev-id_auto = true;
-   dev_set_name(pdev-dev, %s.%d.auto, pdev-name, pdev-id);
-   break;
-   }
-
for (i = 0; i  pdev-num_resources; i++) {
struct resource *p, *r = pdev-resource[i];
 
@@ -372,7 +384,6 @@ int platform_device_add(struct platform_device *pdev)
release_resource(r);
}
 
- err_out:
return ret;
 }
 EXPORT_SYMBOL_GPL(platform_device_add);
@@ -392,11 +403,6 @@ void platform_device_del(struct platform_device *pdev)
if (pdev) {
device_del(pdev-dev);
 
-   if (pdev-id_auto) {
-   ida_simple_remove(platform_devid_ida, pdev-id);
-   pdev-id = PLATFORM_DEVID_AUTO;
-   }
-
for (i = 0; i  pdev-num_resources; i++) {
struct resource *r = pdev-resource[i];
unsigned long type = resource_type(r);
@@ -414,8 +420,15 @@ EXPORT_SYMBOL_GPL(platform_device_del);
  */
 int platform_device_register(struct platform_device *pdev)
 {
+   int ret;
+
device_initialize(pdev-dev);
arch_setup_pdev_archdata(pdev);
+
+   

[PATCHv5 7/7] usb: dwc3: host: convey the PHYs to xhci

2014-11-19 Thread Heikki Krogerus
On some platforms a PHY may need to be handled also in the
host controller driver. Exynos5420 SoC requires some PHY
tuning based on the USB speed. This patch delivers dwc3's
PHYs to the xhci platform device when it's created.

Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
Tested-by: Vivek Gautam gautam.vi...@samsung.com
Acked-by: Felipe Balbi ba...@ti.com
---
 drivers/usb/dwc3/host.c | 22 --
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
index dcb8ca0..12bfd3c 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -29,8 +29,7 @@ int dwc3_host_init(struct dwc3 *dwc)
xhci = platform_device_alloc(xhci-hcd, PLATFORM_DEVID_AUTO);
if (!xhci) {
dev_err(dwc-dev, couldn't allocate xHCI device\n);
-   ret = -ENOMEM;
-   goto err0;
+   return -ENOMEM;
}
 
dma_set_coherent_mask(xhci-dev, dwc-dev-coherent_dma_mask);
@@ -60,22 +59,33 @@ int dwc3_host_init(struct dwc3 *dwc)
goto err1;
}
 
+   phy_create_lookup(dwc-usb2_generic_phy, usb2-phy,
+ dev_name(xhci-dev));
+   phy_create_lookup(dwc-usb3_generic_phy, usb3-phy,
+ dev_name(xhci-dev));
+
ret = platform_device_add(xhci);
if (ret) {
dev_err(dwc-dev, failed to register xHCI device\n);
-   goto err1;
+   goto err2;
}
 
return 0;
-
+err2:
+   phy_remove_lookup(dwc-usb2_generic_phy, usb2-phy,
+ dev_name(xhci-dev));
+   phy_remove_lookup(dwc-usb3_generic_phy, usb3-phy,
+ dev_name(xhci-dev));
 err1:
platform_device_put(xhci);
-
-err0:
return ret;
 }
 
 void dwc3_host_exit(struct dwc3 *dwc)
 {
+   phy_remove_lookup(dwc-usb2_generic_phy, usb2-phy,
+ dev_name(dwc-xhci-dev));
+   phy_remove_lookup(dwc-usb3_generic_phy, usb3-phy,
+ dev_name(dwc-xhci-dev));
platform_device_unregister(dwc-xhci);
 }
-- 
2.1.3

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


[PATCHv5 2/7] phy: improved lookup method

2014-11-19 Thread Heikki Krogerus
Separates registration of the phy and the lookup. The method
is copied from clkdev.c,

Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
---
 Documentation/phy.txt   | 60 ++-
 drivers/phy/phy-core.c  | 84 -
 include/linux/phy/phy.h | 16 ++
 3 files changed, 115 insertions(+), 45 deletions(-)

diff --git a/Documentation/phy.txt b/Documentation/phy.txt
index c6594af..371361c 100644
--- a/Documentation/phy.txt
+++ b/Documentation/phy.txt
@@ -54,18 +54,14 @@ The PHY driver should create the PHY in order for other 
peripheral controllers
 to make use of it. The PHY framework provides 2 APIs to create the PHY.
 
 struct phy *phy_create(struct device *dev, struct device_node *node,
-  const struct phy_ops *ops,
-  struct phy_init_data *init_data);
+  const struct phy_ops *ops);
 struct phy *devm_phy_create(struct device *dev, struct device_node *node,
-   const struct phy_ops *ops,
-   struct phy_init_data *init_data);
+   const struct phy_ops *ops);
 
 The PHY drivers can use one of the above 2 APIs to create the PHY by passing
-the device pointer, phy ops and init_data.
+the device pointer and phy ops.
 phy_ops is a set of function pointers for performing PHY operations such as
-init, exit, power_on and power_off. *init_data* is mandatory to get a reference
-to the PHY in the case of non-dt boot. See section *Board File Initialization*
-on how init_data should be used.
+init, exit, power_on and power_off.
 
 Inorder to dereference the private data (in phy_ops), the phy provider driver
 can use phy_set_drvdata() after creating the PHY and use phy_get_drvdata() in
@@ -137,42 +133,18 @@ There are exported APIs like phy_pm_runtime_get, 
phy_pm_runtime_get_sync,
 phy_pm_runtime_put, phy_pm_runtime_put_sync, phy_pm_runtime_allow and
 phy_pm_runtime_forbid for performing PM operations.
 
-8. Board File Initialization
-
-Certain board file initialization is necessary in order to get a reference
-to the PHY in the case of non-dt boot.
-Say we have a single device that implements 3 PHYs that of USB, SATA and PCIe,
-then in the board file the following initialization should be done.
-
-struct phy_consumer consumers[] = {
-   PHY_CONSUMER(dwc3.0, usb),
-   PHY_CONSUMER(pcie.0, pcie),
-   PHY_CONSUMER(sata.0, sata),
-};
-PHY_CONSUMER takes 2 parameters, first is the device name of the controller
-(PHY consumer) and second is the port name.
-
-struct phy_init_data init_data = {
-   .consumers = consumers,
-   .num_consumers = ARRAY_SIZE(consumers),
-};
-
-static const struct platform_device pipe3_phy_dev = {
-   .name = pipe3-phy,
-   .id = -1,
-   .dev = {
-   .platform_data = {
-   .init_data = init_data,
-   },
-   },
-};
-
-then, while doing phy_create, the PHY driver should pass this init_data
-   phy_create(dev, ops, pdata-init_data);
-
-and the controller driver (phy consumer) should pass the port name along with
-the device to get a reference to the PHY
-   phy_get(dev, pcie);
+8. PHY Mappings
+
+In order to get reference to a PHY without help from DeviceTree, the framework
+offers lookups which can be compared to clkdev that allow clk structures to be
+bound to devices. A lookup can be made be made during runtime when a handle to
+the struct phy already exists.
+
+The framework offers the following API for registering and unregistering the
+lookups.
+
+int phy_create_lookup(struct phy *phy, const char *con_id, const char *dev_id);
+void phy_remove_lookup(struct phy *phy, const char *con_id, const char 
*dev_id);
 
 9. DeviceTree Binding
 
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index ff5eec5..9c3f0dc 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -26,6 +26,7 @@
 static struct class *phy_class;
 static DEFINE_MUTEX(phy_provider_mutex);
 static LIST_HEAD(phy_provider_list);
+static LIST_HEAD(phys);
 static DEFINE_IDA(phy_ida);
 
 static void devm_phy_release(struct device *dev, void *res)
@@ -84,6 +85,87 @@ static struct phy *phy_lookup(struct device *device, const 
char *port)
return ERR_PTR(-ENODEV);
 }
 
+/**
+ * phy_create_lookup() - allocate and register PHY/device association
+ * @phy: the phy of the association
+ * @con_id: connection ID string on device
+ * @dev_id: the device of the association
+ *
+ * Creates and registers phy_lookup entry.
+ */
+int phy_create_lookup(struct phy *phy, const char *con_id, const char *dev_id)
+{
+   struct phy_lookup *pl;
+
+   if (!phy || !dev_id || !con_id)
+   return -EINVAL;
+
+   pl = kzalloc(sizeof(*pl), GFP_KERNEL);
+   if (!pl)
+   return -ENOMEM;
+
+   pl-dev_id = dev_id;
+   pl-con_id = con_id;
+   pl-phy = phy;
+
+   

[PATCHv5 3/7] phy: twl4030: use the new lookup method

2014-11-19 Thread Heikki Krogerus
Creates the lookup separately. Hard coding the consumer as
it can't be anything else except musb.

Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
---
 drivers/phy/phy-twl4030-usb.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
index e2698d29..0d20fe0 100644
--- a/drivers/phy/phy-twl4030-usb.c
+++ b/drivers/phy/phy-twl4030-usb.c
@@ -644,7 +644,6 @@ static int twl4030_usb_probe(struct platform_device *pdev)
struct usb_otg  *otg;
struct device_node  *np = pdev-dev.of_node;
struct phy_provider *phy_provider;
-   struct phy_init_data*init_data = NULL;
 
twl = devm_kzalloc(pdev-dev, sizeof(*twl), GFP_KERNEL);
if (!twl)
@@ -655,7 +654,6 @@ static int twl4030_usb_probe(struct platform_device *pdev)
(enum twl4030_usb_mode *)twl-usb_mode);
else if (pdata) {
twl-usb_mode = pdata-usb_mode;
-   init_data = pdata-init_data;
} else {
dev_err(pdev-dev, twl4030 initialized without pdata\n);
return -EINVAL;
@@ -680,7 +678,7 @@ static int twl4030_usb_probe(struct platform_device *pdev)
otg-set_host   = twl4030_set_host;
otg-set_peripheral = twl4030_set_peripheral;
 
-   phy = devm_phy_create(twl-dev, NULL, ops, init_data);
+   phy = devm_phy_create(twl-dev, NULL, ops, NULL);
if (IS_ERR(phy)) {
dev_dbg(pdev-dev, Failed to create PHY\n);
return PTR_ERR(phy);
@@ -733,6 +731,11 @@ static int twl4030_usb_probe(struct platform_device *pdev)
return status;
}
 
+   if (pdata)
+   err = phy_create_lookup(phy, usb, musb-hdrc.0);
+   if (err)
+   return err;
+
pm_runtime_mark_last_busy(pdev-dev);
pm_runtime_put_autosuspend(twl-dev);
 
-- 
2.1.3

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


[PATCHv5 4/7] arm: omap3: twl: remove usb phy init data

2014-11-19 Thread Heikki Krogerus
The driver does no use it any more.

Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
---
 arch/arm/mach-omap2/twl-common.c | 12 +---
 include/linux/i2c/twl.h  |  2 --
 2 files changed, 1 insertion(+), 13 deletions(-)

diff --git a/arch/arm/mach-omap2/twl-common.c b/arch/arm/mach-omap2/twl-common.c
index b0d54da..4457e73 100644
--- a/arch/arm/mach-omap2/twl-common.c
+++ b/arch/arm/mach-omap2/twl-common.c
@@ -91,18 +91,8 @@ void __init omap_pmic_late_init(void)
 }
 
 #if defined(CONFIG_ARCH_OMAP3)
-struct phy_consumer consumers[] = {
-   PHY_CONSUMER(musb-hdrc.0, usb),
-};
-
-struct phy_init_data init_data = {
-   .consumers = consumers,
-   .num_consumers = ARRAY_SIZE(consumers),
-};
-
 static struct twl4030_usb_data omap3_usb_pdata = {
-   .usb_mode   = T2_USB_MODE_ULPI,
-   .init_data  = init_data,
+   .usb_mode = T2_USB_MODE_ULPI,
 };
 
 static int omap3_batt_table[] = {
diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
index 8cfb50f..0bc03f1 100644
--- a/include/linux/i2c/twl.h
+++ b/include/linux/i2c/twl.h
@@ -26,7 +26,6 @@
 #define __TWL_H_
 
 #include linux/types.h
-#include linux/phy/phy.h
 #include linux/input/matrix_keypad.h
 
 /*
@@ -634,7 +633,6 @@ enum twl4030_usb_mode {
 struct twl4030_usb_data {
enum twl4030_usb_mode   usb_mode;
unsigned long   features;
-   struct phy_init_data*init_data;
 
int (*phy_init)(struct device *dev);
int (*phy_exit)(struct device *dev);
-- 
2.1.3

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


[PATCHv5 0/7] phy: simplified phy lookup

2014-11-19 Thread Heikki Krogerus
This set will in practice just separate the creation of a phy and
binding of it to the consumer. Mapping phys to consumers can be now
done with lookups similarly how clocks can be mapped in clkdev.c.

Vivek needs to handle the phys of dwc3 also in xhci driver on
Exynos5420 SoC, so I'm resending these now.

Changes since v4:
- Support for static lookups is dropped. The lookups can be now only
  be created with phy_create_lookup()

Changes since v3:
- We can't rely on the order in which the phys are registered, so
  using the name of the parent of the phy instance for matching
  instead of the phy itself. The parent device is always the actual
  physical device.
- Using PHY_LOOKUP macro in twl-common.c as suggested by Kishon.

Changes since v2:
- Calling ida_simple_remove in release function as pointed out by Greg


Heikki Krogerus (7):
  phy: safer to_phy() macro
  phy: improved lookup method
  phy: twl4030: use the new lookup method
  arm: omap3: twl: remove usb phy init data
  phy: remove the old lookup method
  base: platform: name the device already during allocation
  usb: dwc3: host: convey the PHYs to xhci

 Documentation/phy.txt|  60 ++--
 arch/arm/mach-omap2/twl-common.c |  12 +---
 drivers/base/platform.c  |  69 +--
 drivers/phy/phy-bcm-kona-usb2.c  |   2 +-
 drivers/phy/phy-berlin-sata.c|   2 +-
 drivers/phy/phy-core.c   | 105 ---
 drivers/phy/phy-exynos-dp-video.c|   2 +-
 drivers/phy/phy-exynos-mipi-video.c  |   2 +-
 drivers/phy/phy-exynos5-usbdrd.c |   3 +-
 drivers/phy/phy-exynos5250-sata.c|   2 +-
 drivers/phy/phy-hix5hd2-sata.c   |   2 +-
 drivers/phy/phy-miphy365x.c  |   2 +-
 drivers/phy/phy-mvebu-sata.c |   2 +-
 drivers/phy/phy-omap-usb2.c  |   2 +-
 drivers/phy/phy-qcom-apq8064-sata.c  |   3 +-
 drivers/phy/phy-qcom-ipq806x-sata.c  |   3 +-
 drivers/phy/phy-rcar-gen2.c  |   2 +-
 drivers/phy/phy-samsung-usb2.c   |   3 +-
 drivers/phy/phy-spear1310-miphy.c|   2 +-
 drivers/phy/phy-spear1340-miphy.c|   2 +-
 drivers/phy/phy-stih407-usb.c|   2 +-
 drivers/phy/phy-stih41x-usb.c|   2 +-
 drivers/phy/phy-sun4i-usb.c  |   2 +-
 drivers/phy/phy-ti-pipe3.c   |   2 +-
 drivers/phy/phy-twl4030-usb.c|   9 ++-
 drivers/phy/phy-xgene.c  |   2 +-
 drivers/pinctrl/pinctrl-tegra-xusb.c |   4 +-
 drivers/usb/dwc3/host.c  |  22 ++--
 include/linux/i2c/twl.h  |   2 -
 include/linux/phy/phy.h  |  52 +++--
 30 files changed, 195 insertions(+), 186 deletions(-)

-- 
2.1.3

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


[PATCHv5 1/7] phy: safer to_phy() macro

2014-11-19 Thread Heikki Krogerus
This makes to_phy() macro work with other variable names
besides dev.

Signed-off-by: Heikki Krogerus heikki.kroge...@linux.intel.com
Tested-by: Vivek Gautam gautam.vi...@samsung.com
Acked-by: Felipe Balbi ba...@ti.com
---
 include/linux/phy/phy.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 8cb6f81..9fda683 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -110,7 +110,7 @@ struct phy_init_data {
.port   = _port,\
 }
 
-#defineto_phy(dev) (container_of((dev), struct phy, dev))
+#defineto_phy(a)   (container_of((a), struct phy, dev))
 
 #defineof_phy_provider_register(dev, xlate)\
__of_phy_provider_register((dev), THIS_MODULE, (xlate))
-- 
2.1.3

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


[RESEND PATCH] usb: gadget: at91_udc: move prepare clk into process context

2014-11-19 Thread Nicolas Ferre
From: Ronald Wahl ronald.w...@raritan.com

Commit 7628083227b6bc4a7e33d7c381d7a4e558424b6b (usb: gadget: at91_udc:
prepare clk before calling enable) added clock preparation in interrupt
context. This is not allowed as it might sleep. Also setting the clock
rate is unsafe to call from there for the same reason. Move clock
preparation and setting clock rate into process context (at91udc_probe).

Signed-off-by: Ronald Wahl ronald.w...@raritan.com
Acked-by: Alexandre Belloni alexandre.bell...@free-electrons.com
Acked-by: Boris Brezillon boris.brezil...@free-electrons.com
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com
Cc: Felipe Balbi ba...@ti.com
Cc: sta...@vger.kernel.org # v3.17+
---
Hi Felipe,

I forgot to answer you on this patch. So I resend it now with the proper
stable tag. You can also queue it during this -rc phase if you feel it is
still possible.

Thanks, bye.

 drivers/usb/gadget/udc/at91_udc.c | 44 ---
 1 file changed, 32 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/gadget/udc/at91_udc.c 
b/drivers/usb/gadget/udc/at91_udc.c
index 9968f5331fe4..0716c1994e28 100644
--- a/drivers/usb/gadget/udc/at91_udc.c
+++ b/drivers/usb/gadget/udc/at91_udc.c
@@ -870,12 +870,10 @@ static void clk_on(struct at91_udc *udc)
return;
udc-clocked = 1;
 
-   if (IS_ENABLED(CONFIG_COMMON_CLK)) {
-   clk_set_rate(udc-uclk, 4800);
-   clk_prepare_enable(udc-uclk);
-   }
-   clk_prepare_enable(udc-iclk);
-   clk_prepare_enable(udc-fclk);
+   if (IS_ENABLED(CONFIG_COMMON_CLK))
+   clk_enable(udc-uclk);
+   clk_enable(udc-iclk);
+   clk_enable(udc-fclk);
 }
 
 static void clk_off(struct at91_udc *udc)
@@ -884,10 +882,10 @@ static void clk_off(struct at91_udc *udc)
return;
udc-clocked = 0;
udc-gadget.speed = USB_SPEED_UNKNOWN;
-   clk_disable_unprepare(udc-fclk);
-   clk_disable_unprepare(udc-iclk);
+   clk_disable(udc-fclk);
+   clk_disable(udc-iclk);
if (IS_ENABLED(CONFIG_COMMON_CLK))
-   clk_disable_unprepare(udc-uclk);
+   clk_disable(udc-uclk);
 }
 
 /*
@@ -1780,14 +1778,24 @@ static int at91udc_probe(struct platform_device *pdev)
}
 
/* don't do anything until we have both gadget driver and VBUS */
+   if (IS_ENABLED(CONFIG_COMMON_CLK)) {
+   clk_set_rate(udc-uclk, 4800);
+   retval = clk_prepare(udc-uclk);
+   if (retval)
+   goto fail1;
+   }
+   retval = clk_prepare(udc-fclk);
+   if (retval)
+   goto fail1a;
+
retval = clk_prepare_enable(udc-iclk);
if (retval)
-   goto fail1;
+   goto fail1b;
at91_udp_write(udc, AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS);
at91_udp_write(udc, AT91_UDP_IDR, 0x);
/* Clear all pending interrupts - UDP may be used by bootloader. */
at91_udp_write(udc, AT91_UDP_ICR, 0x);
-   clk_disable_unprepare(udc-iclk);
+   clk_disable(udc-iclk);
 
/* request UDC and maybe VBUS irqs */
udc-udp_irq = platform_get_irq(pdev, 0);
@@ -1795,7 +1803,7 @@ static int at91udc_probe(struct platform_device *pdev)
0, driver_name, udc);
if (retval  0) {
DBG(request irq %d failed\n, udc-udp_irq);
-   goto fail1;
+   goto fail1c;
}
if (gpio_is_valid(udc-board.vbus_pin)) {
retval = gpio_request(udc-board.vbus_pin, udc_vbus);
@@ -1848,6 +1856,13 @@ fail3:
gpio_free(udc-board.vbus_pin);
 fail2:
free_irq(udc-udp_irq, udc);
+fail1c:
+   clk_unprepare(udc-iclk);
+fail1b:
+   clk_unprepare(udc-fclk);
+fail1a:
+   if (IS_ENABLED(CONFIG_COMMON_CLK))
+   clk_unprepare(udc-uclk);
 fail1:
if (IS_ENABLED(CONFIG_COMMON_CLK)  !IS_ERR(udc-uclk))
clk_put(udc-uclk);
@@ -1896,6 +1911,11 @@ static int __exit at91udc_remove(struct platform_device 
*pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
release_mem_region(res-start, resource_size(res));
 
+   if (IS_ENABLED(CONFIG_COMMON_CLK))
+   clk_unprepare(udc-uclk);
+   clk_unprepare(udc-fclk);
+   clk_unprepare(udc-iclk);
+
clk_put(udc-iclk);
clk_put(udc-fclk);
if (IS_ENABLED(CONFIG_COMMON_CLK))
-- 
2.1.3

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


Re: [PATCH v2] usb: dwc2: resume root hub when device detect with suspend state

2014-11-19 Thread Alan Stern
On Tue, 18 Nov 2014, Julius Werner wrote:

  You should be aware that it's not safe to use hcd-state for anything
  in a host controller driver.  That field is owned by usbcore, not by
  the HCD, and it is not protected by any locks.
 
  Thus, for example, hcd-state does not get set to HC_STATE_SUSPENDED
  until some time after the bus_suspend routine has returned.  A
  port-change interrupt might occur during that time interval.
 
 Looks like there is explicit code in hcd_bus_suspend() to check for
 that race condition right after setting hcd-state, or do I
 misinterpret that (the Did we race with a root-hub wakeup event?
 part)?

That code doesn't quite do what you think.  For example:

CPU 1   CPU 2
-   -
hcd_bus_suspend():
call hcd-bus_suspend():
root hub gets suspended

Wakeup IRQ arrives and is
  ignored because hcd-state
  is still HC_STATE_QUIESCING

set hcd-state to HC_STATE_SUSPENDED
Did we race with a wakeup event?
  No because usb_hcd_resume_root_hub()
  wasn't called.

Result: the wakeup event is lost.

 Also, it seems xhci_bus_suspend() explicitly sets 'hcd-state =
 HC_STATE_SUSPENDED' before giving up the spinlock for some
 undocumented reason, maybe to avoid exactly this problem. We could
 just copy that trick if the hcd.c solution isn't enough (although the
 DWC2 bus_suspend/bus_resume in the other patch don't grab that
 spinlock right now, where I'm also not so sure if that's a good
 idea...).

It's better for HCDs to avoid testing hcd-state at all.  They should 
set it to appropriate values at the right times, because usbcore checks 
it, but they should not test it.  This is why ehci-hcd, ohci-hcd, and 
uhci-hcd all have a private rh_state variable, and they use it while 
holding their respective private spinlocks.

Alan Stern

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


Re: [PATCH v2] usb: dwc2: resume root hub when device detect with suspend state

2014-11-19 Thread Mathias Nyman
On 18.11.2014 18:41, Felipe Balbi wrote:
 On Tue, Nov 18, 2014 at 11:07:34AM -0500, Alan Stern wrote:
 On Tue, 18 Nov 2014, Kever Yang wrote:

 After we implement the bus_suspend/resume, auto suspend id enabled.
 The root hub will be auto suspend if there is no device connected,
 we need to resume the root hub when a device connect detect.

 This patch tested on rk3288.

 Signed-off-by: Roy Li roy...@rock-chips.com
 Signed-off-by: Kever Yang kever.y...@rock-chips.com
 ---

 Changes in v2:
 - add definition for hcd structure
 - remove check for bus-root_hub

  drivers/usb/dwc2/hcd_intr.c | 5 +
  1 file changed, 5 insertions(+)

 diff --git a/drivers/usb/dwc2/hcd_intr.c b/drivers/usb/dwc2/hcd_intr.c
 index 551ba87..680206f 100644
 --- a/drivers/usb/dwc2/hcd_intr.c
 +++ b/drivers/usb/dwc2/hcd_intr.c
 @@ -329,6 +329,7 @@ static void dwc2_port_intr(struct dwc2_hsotg *hsotg)
  {
 u32 hprt0;
 u32 hprt0_modify;
 +   struct usb_hcd *hcd = (struct usb_hcd *)hsotg-priv;
  
 dev_vdbg(hsotg-dev, --Port Interrupt--\n);
  
 @@ -354,6 +355,10 @@ static void dwc2_port_intr(struct dwc2_hsotg *hsotg)
 hsotg-flags.b.port_connect_status = 1;
 hprt0_modify |= HPRT0_CONNDET;
  
 +   /* resume root hub? */
 +   if (hcd-state == HC_STATE_SUSPENDED)
 +   usb_hcd_resume_root_hub(hcd);

 You should be aware that it's not safe to use hcd-state for anything 
 in a host controller driver.  That field is owned by usbcore, not by 
 the HCD, and it is not protected by any locks.

 Thus, for example, hcd-state does not get set to HC_STATE_SUSPENDED
 until some time after the bus_suspend routine has returned.  A
 port-change interrupt might occur during that time interval.
 
 In that case, XHCI has a bug :-) Mathias, care to add it to your TODO
 list ?
 

I guess I'll need to check it out, thanks for pointing it out.

-Mathias
--
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] HID: yet another buggy ELAN touchscreen

2014-11-19 Thread Greg Kroah-Hartman
On Wed, Nov 19, 2014 at 03:52:29PM +0100, Jiri Kosina wrote:
 
 [ Greg and linux-usb@ added to CC ]
 
 On Mon, 17 Nov 2014, Oliver Neukum wrote:
 
  The touchscreen needs the same quirk as the other models.
  
  Signed-off-by: Oliver Neukum oneu...@suse.de
  Reported-by: Bryan Poling poli0...@umn.edu
  CC: sta...@vger.kernel.org
  ---
   drivers/hid/hid-ids.h   | 1 +
   drivers/hid/usbhid/hid-quirks.c | 1 +
   drivers/usb/core/quirks.c   | 3 +++
 
 Greg, are you OK with me taking the whole lot through hid.git in one 
 commit? (USB quirks and HID quirks for Elan devices have been merged 
 independently for previous 3 devices, but I don't think it's worth the 
 hassle splitting it).

Yes, no objection from me:

Acked-by: Greg Kroah-Hartman gre...@linuxfoundation.org

--
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] usb: phy: introduce usb_phy_set_event interface

2014-11-19 Thread Todd Poynor
On Wed, Nov 19, 2014 at 2:43 AM, Kiran Kumar Raparthy
kiran.ku...@linaro.org wrote:
 From: Todd Poynor toddpoy...@google.com

 usb: phy: introduce usb_phy_set_event interface

Hi Kiran, this is new stuff that is all your own work and you deserve
the credit.

Thanks for working to get this feature in shape for mainline!


Todd
--
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] HID: yet another buggy ELAN touchscreen

2014-11-19 Thread Jiri Kosina
On Wed, 19 Nov 2014, Greg Kroah-Hartman wrote:

  On Mon, 17 Nov 2014, Oliver Neukum wrote:
  
   The touchscreen needs the same quirk as the other models.
   
   Signed-off-by: Oliver Neukum oneu...@suse.de
   Reported-by: Bryan Poling poli0...@umn.edu
   CC: sta...@vger.kernel.org
   ---
drivers/hid/hid-ids.h   | 1 +
drivers/hid/usbhid/hid-quirks.c | 1 +
drivers/usb/core/quirks.c   | 3 +++
  
  Greg, are you OK with me taking the whole lot through hid.git in one 
  commit? (USB quirks and HID quirks for Elan devices have been merged 
  independently for previous 3 devices, but I don't think it's worth the 
  hassle splitting it).
 
 Yes, no objection from me:
 
 Acked-by: Greg Kroah-Hartman gre...@linuxfoundation.org

Thanks, now applied.

-- 
Jiri Kosina
SUSE Labs
--
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: Error in queuecommand_lck: us-srb from usb_stor_control_thread

2014-11-19 Thread Alan Stern
On Wed, 19 Nov 2014, Андрей Аладьев wrote:

 I've tested with 3.18-rc5. It looks the same.

I was able to duplicate the problem in 3.18-rc5.  Give me some time to 
investigate it, and I'll get back to you.

Alan Stern

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


Re: USB OTG doesn't work in HOST mode on OMAP3 processor on 3.18-rc5

2014-11-19 Thread Tony Lindgren
* Enric Balletbo Serra eballe...@gmail.com [141119 03:14]:
 2014-11-18 16:42 GMT+01:00 Tony Lindgren t...@atomide.com:
 
 Checked again, and no luck. It's very weird because from the OTG point
 of view, OTG is exactly the same between Beagleboard-XM and IGEPv2.
 
 Can you confirm that you're using kernel 3.18-rc5 without other
 patches applied ? At this moment, I don't have a Beagleboard-XM to
 test, I'll try to get one because at this moment I'm a bit stuck with
 this problem.

Yes it was with v3.18-rc5 and the defconfig patch I posted except
I had to disable all the other MUSB platforms. Also tested it with
built in modules.

Maybe you need to check the .dts pinctrl entries for hsusb0_* lines?

Regards,

Tony
--
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: Re: [PATCH v2] usb: dwc2: resume root hub when device detect with suspend state

2014-11-19 Thread Julius Werner
On Wed, Nov 19, 2014 at 1:47 AM, 李云志 l...@rock-chips.com wrote:
 hi Julius  Alan

 Shall we use dwc2's private status hsotg-lx_state here instesd of
 hcd-state for checking root hub is in suspend state ?
 I see the EHCI driver do something like this(ehci-rh_state ==
 EHCI_RH_SUSPENDED) before resume the root hub.

It's not this simple, because lx_state only relates to the status of
the one port on the DWC2. That may be suspended even though the root
hub is not.

The USB core differentiates between suspending individual ports, and
suspending the whole root hub (which should automatically suspend all
ports in a host-controller-specific manner). This distinction may seem
silly on DWC2 because there is only one port to suspend, but you still
need to make it so that the USB core doesn't get confused. So the
different things you need to keep track of are:

 * is the one port individually suspended (through the
hub_control(SetPortFeature(PORT_SUSPEND)) method)
 * is the root hub suspended (through calling bus_suspend())
 * if the root hub gets suspended (through bus_suspend()), had the
port already been suspended before that (through a earlier
hub_control())... this is the thing I mentioned in your other patch

You can decide whether you want to bake that all into one variable
somehow or make it three, but we need to be able to tell all of these
things apart. The third bullet point will also require you to prevent
races of hub_control() with bus_suspend() (not sure if the kernel
already guarantees that or not), so I think we may have to rethink the
way the spinlock works (because it currently doesn't cover that).
--
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] usbnet: rtl8150: remove unused variable

2014-11-19 Thread David Miller
From: Sudip Mukherjee sudipm.mukher...@gmail.com
Date: Tue, 18 Nov 2014 21:55:21 +0530

 remove unused variable
 
 Signed-off-by: Sudip Mukherjee su...@vectorindia.org
 ---
 
 change in v2: changed the commit message

Applied, thank you.
--
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 3/5] usb: gadget: pxa25x_udc: prepare/unprepare clocks in pxa-ssp

2014-11-19 Thread Robert Jarzmik
Dmitry Eremin-Solenikov dbarysh...@gmail.com writes:

 I have sketched a compile-tested only PHY for the Lubbock platform. Could you
 please take a look and test.
   git://git.infradead.org/users/dbaryshkov/zaurus.git lubbock

Okay, now my ADSL line is repaired, thank you Mr farmer I drive a tractor but I
don't care about telephone posts, I'll fetch your changes and make a
test. Let's say I schedule this for saturday.

Cheers.

--
Robert
--
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 devices disappering on resume on pantherpoint chipset with dock

2014-11-19 Thread Brian Campbell
Hi,

On Wed, Nov 19, 2014 at 05:04:27PM +0200, Mathias Nyman wrote:
 
 One theory would be that when we fail to reset the device because it's 
 already in the
 default state (state after reset) we end up not freeing the rings, and won't 
 free the 
 reserved bandwith either.
 
 If you wan't you could try this hack, just to check the theory. 
 It will free the reserved bandwith event if resetting the device fails.

Unfortunately it doesn't seem to make any difference, the bandwidth drops at
the roughly the same rate.  (I've put the logs at
http://www.z273.org.uk/tmp/2014-11-19+hack/)

  Brian

--
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 3/5] usb: gadget: pxa25x_udc: prepare/unprepare clocks in pxa-ssp

2014-11-19 Thread Dmitry Eremin-Solenikov
2014-11-19 23:29 GMT+03:00 Robert Jarzmik robert.jarz...@free.fr:
 Dmitry Eremin-Solenikov dbarysh...@gmail.com writes:

 I have sketched a compile-tested only PHY for the Lubbock platform. Could you
 please take a look and test.
   git://git.infradead.org/users/dbaryshkov/zaurus.git lubbock

 Okay, now my ADSL line is repaired, thank you Mr farmer I drive a tractor 
 but I
 don't care about telephone posts, I'll fetch your changes and make a
 test. Let's say I schedule this for saturday.

Fine with me, thank you.

-- 
With best wishes
Dmitry
--
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: Error in queuecommand_lck: us-srb from usb_stor_control_thread

2014-11-19 Thread Alan Stern
On Wed, 19 Nov 2014, Alan Stern wrote:

 On Wed, 19 Nov 2014, Андрей Аладьев wrote:
 
  I've tested with 3.18-rc5. It looks the same.
 
 I was able to duplicate the problem in 3.18-rc5.  Give me some time to 
 investigate it, and I'll get back to you.

The patch below fixed the problem on my machine.  Does it prevent all 
those errors on your system?  It corrects a bug that was introduced by 
commit ac61d1955934.

Alan Stern



Index: 3.18-rc5/drivers/scsi/scsi_error.c
===
--- 3.18-rc5.orig/drivers/scsi/scsi_error.c
+++ 3.18-rc5/drivers/scsi/scsi_error.c
@@ -1027,7 +1027,7 @@ retry:
}
/* signal not to enter either branch of the if () below */
timeleft = 0;
-   rtn = NEEDS_RETRY;
+   rtn = FAILED;
} else {
timeleft = wait_for_completion_timeout(done, timeout);
rtn = SUCCESS;
@@ -1067,7 +1067,7 @@ retry:
rtn = FAILED;
break;
}
-   } else if (!rtn) {
+   } else if (rtn != FAILED) {
scsi_abort_eh_cmnd(scmd);
rtn = FAILED;
}

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


Possible memory leak in acm_probe not freeing (acm-country_codes) on error path

2014-11-19 Thread Ahmed Tamrawi
Bug Report Filed: https://bugzilla.kernel.org/show_bug.cgi?id=88521
Linux Version [3.17-rc1]
Configuration: Default configuration for x86

Function Source:
http://lxr.free-electrons.com/source/drivers/usb/class/cdc-acm.c#L1404

In function (acm_probe) in file (drivers/usb/class/cdc-acm.c):

Pointer (acm-country_codes) gets allocated in line (1404) and freed
in lines (1414, 1424) if the call to function (device_create_file)
fails (i  0). However, if the conditions at (1413 and 1422) evaluates
to false, the function (acm_probe) exists without freeing the pointer
(acm-country_codes). Thus, causing a memory leak.


Thanks,
Ahmed
--
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: Possible memory leak in acm_probe not freeing (acm-country_codes) on error path

2014-11-19 Thread Greg KH
On Wed, Nov 19, 2014 at 07:22:06PM -0600, Ahmed Tamrawi wrote:
 Bug Report Filed: https://bugzilla.kernel.org/show_bug.cgi?id=88521
 Linux Version [3.17-rc1]
 Configuration: Default configuration for x86
 
 Function Source:
 http://lxr.free-electrons.com/source/drivers/usb/class/cdc-acm.c#L1404
 
 In function (acm_probe) in file (drivers/usb/class/cdc-acm.c):
 
 Pointer (acm-country_codes) gets allocated in line (1404) and freed
 in lines (1414, 1424) if the call to function (device_create_file)
 fails (i  0). However, if the conditions at (1413 and 1422) evaluates
 to false, the function (acm_probe) exists without freeing the pointer
 (acm-country_codes). Thus, causing a memory leak.

Care to write up a patch for this fixing the problem and sending it in
the format described in Documentation/SubmittingPatches so we can apply
it?

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


[PATCH net-next v3 1/2] r8152: adjust r8152_submit_rx

2014-11-19 Thread Hayes Wang
The behavior of handling the returned status from r8152_submit_rx()
is almost same, so let r8152_submit_rx() deal with the error
directly. This could avoid the duplicate code.

Signed-off-by: Hayes Wang hayesw...@realtek.com
---
 drivers/net/usb/r8152.c | 40 
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 0a30fd3..3b89229 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -1032,7 +1032,6 @@ static void read_bulk_callback(struct urb *urb)
int status = urb-status;
struct rx_agg *agg;
struct r8152 *tp;
-   int result;
 
agg = urb-context;
if (!agg)
@@ -1083,16 +1082,7 @@ static void read_bulk_callback(struct urb *urb)
break;
}
 
-   result = r8152_submit_rx(tp, agg, GFP_ATOMIC);
-   if (result == -ENODEV) {
-   set_bit(RTL8152_UNPLUG, tp-flags);
-   netif_device_detach(tp-netdev);
-   } else if (result) {
-   spin_lock(tp-rx_lock);
-   list_add_tail(agg-list, tp-rx_done);
-   spin_unlock(tp-rx_lock);
-   tasklet_schedule(tp-tl);
-   }
+   r8152_submit_rx(tp, agg, GFP_ATOMIC);
 }
 
 static void write_bulk_callback(struct urb *urb)
@@ -1680,7 +1670,6 @@ static void rx_bottom(struct r8152 *tp)
int len_used = 0;
struct urb *urb;
u8 *rx_data;
-   int ret;
 
list_del_init(cursor);
 
@@ -1733,13 +1722,7 @@ find_next_rx:
}
 
 submit:
-   ret = r8152_submit_rx(tp, agg, GFP_ATOMIC);
-   if (ret  ret != -ENODEV) {
-   spin_lock_irqsave(tp-rx_lock, flags);
-   list_add_tail(agg-list, tp-rx_done);
-   spin_unlock_irqrestore(tp-rx_lock, flags);
-   tasklet_schedule(tp-tl);
-   }
+   r8152_submit_rx(tp, agg, GFP_ATOMIC);
}
 }
 
@@ -1806,11 +1789,28 @@ static void bottom_half(unsigned long data)
 static
 int r8152_submit_rx(struct r8152 *tp, struct rx_agg *agg, gfp_t mem_flags)
 {
+   int ret;
+
usb_fill_bulk_urb(agg-urb, tp-udev, usb_rcvbulkpipe(tp-udev, 1),
  agg-head, agg_buf_sz,
  (usb_complete_t)read_bulk_callback, agg);
 
-   return usb_submit_urb(agg-urb, mem_flags);
+   ret = usb_submit_urb(agg-urb, mem_flags);
+   if (ret == -ENODEV) {
+   set_bit(RTL8152_UNPLUG, tp-flags);
+   netif_device_detach(tp-netdev);
+   } else if (ret) {
+   struct urb *urb = agg-urb;
+   unsigned long flags;
+
+   urb-actual_length = 0;
+   spin_lock_irqsave(tp-rx_lock, flags);
+   list_add_tail(agg-list, tp-rx_done);
+   spin_unlock_irqrestore(tp-rx_lock, flags);
+   tasklet_schedule(tp-tl);
+   }
+
+   return ret;
 }
 
 static void rtl_drop_queued_tx(struct r8152 *tp)
-- 
1.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 net-next v3 2/2] r8152: adjust rtl_start_rx

2014-11-19 Thread Hayes Wang
If there is a error for r8152_submit_rx(), add the remaining rx
buffers to the list. Then the remaining rx buffers could be
submitted later.

Signed-off-by: Hayes Wang hayesw...@realtek.com
---
 drivers/net/usb/r8152.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 3b89229..4a9ece0 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -2001,6 +2001,25 @@ static int rtl_start_rx(struct r8152 *tp)
break;
}
 
+   if (ret  ++i  RTL8152_MAX_RX) {
+   struct list_head rx_queue;
+   unsigned long flags;
+
+   INIT_LIST_HEAD(rx_queue);
+
+   do {
+   struct rx_agg *agg = tp-rx_info[i++];
+   struct urb *urb = agg-urb;
+
+   urb-actual_length = 0;
+   list_add_tail(agg-list, rx_queue);
+   } while (i  RTL8152_MAX_RX);
+
+   spin_lock_irqsave(tp-rx_lock, flags);
+   list_splice_tail(rx_queue, tp-rx_done);
+   spin_unlock_irqrestore(tp-rx_lock, flags);
+   }
+
return ret;
 }
 
-- 
1.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 net-next v3 0/2] r8152: adjust rx functions

2014-11-19 Thread Hayes Wang
v3:
For patch #1, remove unnecessary initialization for ret and
unnecessary blank line in r8152_submit_rx().

v2:
For patch #1, set actual_length to 0 before adding the rx to the
list, when a error occurs.

For patch #2, change the flow. Stop submitting the rx if a error
occurs, and add the remaining rx to the list for submitting later.

v1:
Adjust some flows and codes which are relative to r8152_submit_rx()
and rtl_start_rx().

Hayes Wang (2):
  r8152: adjust r8152_submit_rx
  r8152: adjust rtl_start_rx

 drivers/net/usb/r8152.c | 60 -
 1 file changed, 40 insertions(+), 20 deletions(-)

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