Re: USB to serial(ttyUSB) port crash in debian. task khubd:369 blocked for more than 120 seconds

2015-12-10 Thread Greg KH
On Wed, Dec 09, 2015 at 02:45:37PM -0600, SaRaVanAn wrote:
> Our device went for reset. So it starts loading and unloading the
> serial USB port.

Not good.

> Here the serious concern is kernel lock. Once it happens the system
> is unusable and hard reboot is the only way of recovering it.
> 
> Kernel version is 3.12.0

3.12.0 is very old and unsupported, can you try to see if 4.3 solves
this issue?  Lots of tty and USB changes have gone into the kernel in
the years since 3.12 was released.

thanks,

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


Re: [PATCHv2] usb: gadget: f_tcm: ignore return value of queue_work

2015-12-10 Thread Felipe Balbi

Hi,

Andrzej Pietrasiewicz  writes:
> queue_work() has never returned anything less than zero.
>
> Signed-off-by: Andrzej Pietrasiewicz 

I don't have f_tcm.c anywhere. Where did you base this commit ?

-- 
balbi


signature.asc
Description: PGP signature


Re: [patch] usb: gadget: f_tcm: memory leak on error in tcm_alloc_inst()

2015-12-10 Thread Felipe Balbi
Dan Carpenter  writes:
> We need to kfree(opts) on error.  Also it's nicer to allocate opts
> before taking the lock.
>
> Signed-off-by: Dan Carpenter 

what's the base for this commit ? I don't have f_tcm.c anywhere.

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH v7 0/4] usb/gadget: independent registration of gadgets and gadget drivers

2015-12-10 Thread Felipe Balbi

Hi,

Marek Szyprowski  writes:
> Hello,
>
> This is a resurrection of the patches initially submitted by Ruslan
> Bilovol in the following thread: https://lkml.org/lkml/2015/6/22/554
>
> The changes since the original submission (v5) includes rebase onto
> latest linux-next branch, simplification of the code requested by Alan
> Stern and Felipe Balbi, removal of a patch, which deleted __init/__exit
> attributes (this change has been already merged) and fixes of the
> checkpatch issues.
>
> This feature is urgently needed, because it is not longer possible to
> use workaround to avoid deferred probe in UDC drivers due to
> not-yet-probed i2c regulator drivers (for more information see
> https://lkml.org/lkml/2015/10/30/374 ).
>
> This patchset has been successfully tested on Odroid XU3 boards with
> DWC3 UDC driver being deferred by missing regulator drivers.

there is one problem with this patchset. If I try to statically link
gadget drivers, only one can be chosen, even though I can enable both
dwc3 and dummy_hcd just fine. And, actually, this brings another
problem. How do we handle systems which have 2 USB peripheral
controllers (say, 2 instances of dwc3) and choose which gadget driver
will bind to which controller ?

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH v7 0/4] usb/gadget: independent registration of gadgets and gadget drivers

2015-12-10 Thread Felipe Balbi

Hi,

Felipe Balbi  writes:
> Felipe Balbi  writes:
>> Marek Szyprowski  writes:
>>> Hello,
>>>
>>> This is a resurrection of the patches initially submitted by Ruslan
>>> Bilovol in the following thread: https://lkml.org/lkml/2015/6/22/554
>>>
>>> The changes since the original submission (v5) includes rebase onto
>>> latest linux-next branch, simplification of the code requested by Alan
>>> Stern and Felipe Balbi, removal of a patch, which deleted __init/__exit
>>> attributes (this change has been already merged) and fixes of the
>>> checkpatch issues.
>>>
>>> This feature is urgently needed, because it is not longer possible to
>>> use workaround to avoid deferred probe in UDC drivers due to
>>> not-yet-probed i2c regulator drivers (for more information see
>>> https://lkml.org/lkml/2015/10/30/374 ).
>>>
>>> This patchset has been successfully tested on Odroid XU3 boards with
>>> DWC3 UDC driver being deferred by missing regulator drivers.
>>
>> there is one problem with this patchset. If I try to statically link
>> gadget drivers, only one can be chosen, even though I can enable both
>> dwc3 and dummy_hcd just fine. And, actually, this brings another
>> problem. How do we handle systems which have 2 USB peripheral
>> controllers (say, 2 instances of dwc3) and choose which gadget driver
>> will bind to which controller ?
>
> We also seem to have issues with Kconfig. If I try to make gadget driver
> built-in, when compiling I'll get asked again if I want gadget drivers
> built-in.
>
> Another one: I just tried dummy_hcd built-in, g_zero built-in, dwc3 as a
> module. I can never load anything to dwc3 ;-)

In all fairness, none of these are regressions. Can we agree to look at
these during v4.5-rc so maybe v4.6 has a final solution ?

cheers

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH 1/2] usb: dwc2: add ep enabled flag to avoid double enable/disable

2015-12-10 Thread Felipe Balbi

Hi,

changbin...@intel.com writes:
> From: "Du, Changbin" 
>
> Enabling a already enabled ep is illegal, because the ep may has trbs
> running. Reprogram the ep may break running transfer. So udc driver
> must avoid this happening by return an error -EBUSY. Gadget function
> driver also should avoid such things, but that is out of udc driver.
>
> Similarly, disable a disabled ep makes no sense, but no need return
> an error here.
>
> Signed-off-by: Du, Changbin 
> ---
>  drivers/usb/dwc2/core.h   |  1 +
>  drivers/usb/dwc2/gadget.c | 20 +++-
>  2 files changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
> index a66d3cb..cf7eccd 100644
> --- a/drivers/usb/dwc2/core.h
> +++ b/drivers/usb/dwc2/core.h
> @@ -162,6 +162,7 @@ struct dwc2_hsotg_ep {
>   unsigned char   mc;
>   unsigned char   interval;
>  
> + unsigned intenabled:1;
>   unsigned inthalted:1;
>   unsigned intperiodic:1;
>   unsigned intisochronous:1;
> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
> index 0abf73c..586bbcd 100644
> --- a/drivers/usb/dwc2/gadget.c
> +++ b/drivers/usb/dwc2/gadget.c
> @@ -2423,6 +2423,7 @@ void dwc2_hsotg_core_init_disconnected(struct 
> dwc2_hsotg *hsotg,
>   /* enable, but don't activate EP0in */
>   dwc2_writel(dwc2_hsotg_ep0_mps(hsotg->eps_out[0]->ep.maxpacket) |
>  DXEPCTL_USBACTEP, hsotg->regs + DIEPCTL0);
> + hsotg->eps_out[0]->enabled = 1;
>  
>   dwc2_hsotg_enqueue_setup(hsotg);
>  
> @@ -2680,6 +2681,14 @@ static int dwc2_hsotg_ep_enable(struct usb_ep *ep,
>   return -EINVAL;
>   }
>  
> + spin_lock_irqsave(>lock, flags);
> + if (hs_ep->enabled) {
> + dev_warn(hsotg->dev, "%s: ep %s already enabled\n",
> + __func__, hs_ep->name);

this is a rather serious condition. I'd rather use dev_WARN_ONCE():

if (dev_WARN_ONCE(hsotg->dev, hs_ep->enabled,
"ep %s already enabled\n", hs_ep->name)) {

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH 4/9v2] usb: host: ehci.h: fix single statement macros

2015-12-10 Thread Sergei Shtylyov

On 12/10/2015 05:56 PM, Geyslan G. Bem wrote:


Don't use the 'do {} while (0)' wrapper in a single statement macro.

Caught by checkpatch: "WARNING: Single statement macros should not
use a do {} while (0) loop"

Signed-off-by: Geyslan G. Bem 
---
drivers/usb/host/ehci.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index cfeebd8..945000a 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -244,9 +244,9 @@ struct ehci_hcd {   /* one per
controller */
  /* irq statistics */
#ifdef EHCI_STATS
  struct ehci_stats   stats;
-#  define COUNT(x) do { (x)++; } while (0)
+#  define COUNT(x) ((x)++)
#else
-#  define COUNT(x) do {} while (0)
+#  define COUNT(x) ((void) 0)




 Why not just empty #define?



Indeed. I'll change it.
Tks Sergei.



Since COUNT is not used to return the empty #define is ok. Another way
is to use #define COUNT(x) (0) to get a 0 when necessary to read
returns.



Just 0, no parens please.



Ok, no parens, since there's no evaluation.


   It's because the literals don't need parens at all.


Then my change is:

-#  define COUNT(x) do { (x)++; } while (0)
+#  define COUNT(x) (++(x))
  #else
-#  define COUNT(x) do {} while (0)
+#  define COUNT(x) 0

Pre-increment allowing to return the updated x.


   Why if there was a post-increment before?

   Anyway, this talk is quite pointless since the macro didn't return any 
value anyway.


MBR, 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: dwc3: gadget: pass a condition to dev_WARN_ONCE()

2015-12-10 Thread Felipe Balbi
instead of using:

if (condition) {
dev_WARN_ONCE(dev, true, "foo");
return -EINVAL;
}

let's use:

if (dev_WARN_ONCE(dev, condition, "foo"))
return -EINVAL;

Signed-off-by: Felipe Balbi 
---
 drivers/usb/dwc3/gadget.c | 14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 3063c5ba5563..96cc1d756d99 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -661,11 +661,10 @@ static int dwc3_gadget_ep_enable(struct usb_ep *ep,
dep = to_dwc3_ep(ep);
dwc = dep->dwc;
 
-   if (dep->flags & DWC3_EP_ENABLED) {
-   dev_WARN_ONCE(dwc->dev, true, "%s is already enabled\n",
-   dep->name);
+   if (dev_WARN_ONCE(dwc->dev, dep->flags & DWC3_EP_ENABLED,
+   "%s is already enabled\n",
+   dep->name))
return 0;
-   }
 
spin_lock_irqsave(>lock, flags);
ret = __dwc3_gadget_ep_enable(dep, desc, ep->comp_desc, false, false);
@@ -689,11 +688,10 @@ static int dwc3_gadget_ep_disable(struct usb_ep *ep)
dep = to_dwc3_ep(ep);
dwc = dep->dwc;
 
-   if (!(dep->flags & DWC3_EP_ENABLED)) {
-   dev_WARN_ONCE(dwc->dev, true, "%s is already disabled\n",
-   dep->name);
+   if (dev_WARN_ONCE(dwc->dev, !(dep->flags & DWC3_EP_ENABLED)
+   "%s is already disabled\n",
+   dep->name))
return 0;
-   }
 
spin_lock_irqsave(>lock, flags);
ret = __dwc3_gadget_ep_disable(dep);
-- 
2.6.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] usb: dwc3: gadget: pass a condition to dev_WARN_ONCE()

2015-12-10 Thread kbuild test robot
Hi Felipe,

[auto build test ERROR on balbi-usb/next]
[also build test ERROR on v4.4-rc4 next-20151210]

url:
https://github.com/0day-ci/linux/commits/Felipe-Balbi/usb-dwc3-gadget-pass-a-condition-to-dev_WARN_ONCE/20151211-031232
base:   https://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git next
config: x86_64-randconfig-x015-12102221 (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/linkage.h:4:0,
from include/linux/kernel.h:6,
from drivers/usb/dwc3/gadget.c:19:
   drivers/usb/dwc3/gadget.c: In function 'dwc3_gadget_ep_disable':
>> drivers/usb/dwc3/gadget.c:695:6: error: expected ')' before string constant
 "%s is already disabled\n",
 ^
   include/linux/compiler.h:147:28: note: in definition of macro '__trace_if'
 if (__builtin_constant_p((cond)) ? !!(cond) :   \
   ^
>> drivers/usb/dwc3/gadget.c:694:2: note: in expansion of macro 'if'
 if (dev_WARN_ONCE(dwc->dev, !(dep->flags & DWC3_EP_ENABLED)
 ^
>> include/linux/device.h:1295:2: note: in expansion of macro 'WARN_ONCE'
 WARN_ONCE(condition, "%s %s: " format, \
 ^
>> drivers/usb/dwc3/gadget.c:694:6: note: in expansion of macro 'dev_WARN_ONCE'
 if (dev_WARN_ONCE(dwc->dev, !(dep->flags & DWC3_EP_ENABLED)
 ^
>> drivers/usb/dwc3/gadget.c:696:6: error: expected ')' before 'dep'
 dep->name))
 ^
   include/linux/compiler.h:147:28: note: in definition of macro '__trace_if'
 if (__builtin_constant_p((cond)) ? !!(cond) :   \
   ^
>> drivers/usb/dwc3/gadget.c:694:2: note: in expansion of macro 'if'
 if (dev_WARN_ONCE(dwc->dev, !(dep->flags & DWC3_EP_ENABLED)
 ^
   include/linux/compiler.h:145:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
  ^
   include/asm-generic/bug.h:124:3: note: in expansion of macro 'if'
  if (WARN(!__warned, format))\
  ^
   include/asm-generic/bug.h:97:3: note: in expansion of macro '__WARN_printf'
  __WARN_printf(format); \
  ^
   include/asm-generic/bug.h:124:7: note: in expansion of macro 'WARN'
  if (WARN(!__warned, format))\
  ^
>> include/linux/device.h:1295:2: note: in expansion of macro 'WARN_ONCE'
 WARN_ONCE(condition, "%s %s: " format, \
 ^
>> drivers/usb/dwc3/gadget.c:694:6: note: in expansion of macro 'dev_WARN_ONCE'
 if (dev_WARN_ONCE(dwc->dev, !(dep->flags & DWC3_EP_ENABLED)
 ^
>> include/linux/device.h:1295:23: warning: format '%s' expects a matching 
>> 'char *' argument [-Wformat=]
 WARN_ONCE(condition, "%s %s: " format, \
  ^
   include/linux/compiler.h:147:28: note: in definition of macro '__trace_if'
 if (__builtin_constant_p((cond)) ? !!(cond) :   \
   ^
>> drivers/usb/dwc3/gadget.c:694:2: note: in expansion of macro 'if'
 if (dev_WARN_ONCE(dwc->dev, !(dep->flags & DWC3_EP_ENABLED)
 ^
   include/linux/compiler.h:145:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
  ^
   include/asm-generic/bug.h:124:3: note: in expansion of macro 'if'
  if (WARN(!__warned, format))\
  ^
   include/asm-generic/bug.h:97:3: note: in expansion of macro '__WARN_printf'
  __WARN_printf(format); \
  ^
   include/asm-generic/bug.h:124:7: note: in expansion of macro 'WARN'
  if (WARN(!__warned, format))\
  ^
>> include/linux/device.h:1295:2: note: in expansion of macro 'WARN_ONCE'
 WARN_ONCE(condition, "%s %s: " format, \
 ^
>> drivers/usb/dwc3/gadget.c:694:6: note: in expansion of macro 'dev_WARN_ONCE'
 if (dev_WARN_ONCE(dwc->dev, !(dep->flags & DWC3_EP_ENABLED)
 ^
>> include/linux/device.h:1295:23: warning: format '%s' expects a matching 
>> 'char *' argument [-Wformat=]
 WARN_ONCE(condition, "%s %s: " format, \
  ^
   include/linux/compiler.h:147:28: note: in definition of macro '__trace_if'
 if (__builtin_constant_p((cond)) ? !!(cond) :   \
   ^
>> drivers/usb/dwc3/gadget.c:694:2: note: in expansion of macro 'if'
 if (dev_WARN_ONCE(dwc->dev, !(dep->flags & DWC3_EP_ENABLED)
 ^
   include/linux/compiler.h:145:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
  ^
   include/asm-generic/bug.h:124:3: note: in expansion of macro 'if'
  if (WARN(!__warned, format))

Re: [PATCH v2 2/2] usb: renesas_usbhs: add device tree support for r8a779[23]

2015-12-10 Thread Geert Uytterhoeven
Hi Simon,

On Thu, Dec 10, 2015 at 6:40 AM, Simon Horman
 wrote:
> Simply document new compatibility string.
> As a previous patch adds a generic R-Car Gen2 compatibility string
> there appears to be no need for a driver updates.
>
> Signed-off-by: Simon Horman 
> Acked-by: Rob Herring 
> ---
>  Documentation/devicetree/bindings/usb/renesas_usbhs.txt | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/usb/renesas_usbhs.txt 
> b/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
> index b959059826cd..efb3199a2a80 100644
> --- a/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
> +++ b/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
> @@ -5,6 +5,8 @@ Required properties:
>
> - "renesas,usbhs-r8a7790" for r8a7790 (R-Car H2) compatible device
> - "renesas,usbhs-r8a7791" for r8a7791 (R-Car M2-W) compatible device
> +   - "renesas,usbhs-r8a7792" for r8a7792 (R-Car V2H) compatible device
> +   - "renesas,usbhs-r8a7793" for r8a7793 (R-Car M2-N) compatible device
> - "renesas,usbhs-r8a7794" for r8a7794 (R-Car E2) compatible device
> - "renesas,usbhs-r8a7795" for r8a7795 (R-Car H3) compatible device
> - "renesas,rcar-gen2-usbhs" for R-Car Gen2 compatibile device

I see a possible issue here:

Old r8a7791 dtsi just has "renesas,usbhs-r8a7791", so it works with the current
driver, as the driver matches against "renesas,usbhs-r8a7791".

Existing (out-of-tree) r8a7792 dtsi may have followed existing practices,
and just have "renesas,usbhs-r8a7792".
This won't work with the new driver, as the driver doesn't match again
"renesas,usbhs-r8a7792". The same applies to r8a7793.

Do we care about this
  - in upstream? Probably not.
  - in the BSP? It seems to have r8a7790/r8a7791 usbhs only, though.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/9v2] usb: host: ehci.h: remove space before function open parenthesis

2015-12-10 Thread Peter Senna Tschudin
On Wed, Dec 09, 2015 at 07:32:31PM -0300, Geyslan G. Bem wrote:
> Get rid of space between function name and open parenthesis.
> 
> Caught by checkpatch: "WARNING: space prohibited between function name
> and open parenthesis '('"
> 
> Signed-off-by: Geyslan G. Bem 
> ---
As with previous, missing the changelog here, but other than that the patch
looks good to me.

Acked-by: Peter Senna Tschudin 
>  drivers/usb/host/ehci.h | 22 +++---
>  1 file changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
> index 6a36ef4..46982df 100644
> --- a/drivers/usb/host/ehci.h
> +++ b/drivers/usb/host/ehci.h
> @@ -268,13 +268,13 @@ struct ehci_hcd {   /* one per 
> controller */
>  };
>  
>  /* convert between an HCD pointer and the corresponding EHCI_HCD */
> -static inline struct ehci_hcd *hcd_to_ehci (struct usb_hcd *hcd)
> +static inline struct ehci_hcd *hcd_to_ehci(struct usb_hcd *hcd)
>  {
>   return (struct ehci_hcd *) (hcd->hcd_priv);
>  }
> -static inline struct usb_hcd *ehci_to_hcd (struct ehci_hcd *ehci)
> +static inline struct usb_hcd *ehci_to_hcd(struct ehci_hcd *ehci)
>  {
> - return container_of ((void *) ehci, struct usb_hcd, hcd_priv);
> + return container_of((void *) ehci, struct usb_hcd, hcd_priv);
>  }
>  
>  /*-*/
> @@ -327,9 +327,9 @@ struct ehci_qtd {
>  } __attribute__ ((aligned (32)));
>  
>  /* mask NakCnt+T in qh->hw_alt_next */
> -#define QTD_MASK(ehci)   cpu_to_hc32 (ehci, ~0x1f)
> +#define QTD_MASK(ehci)   cpu_to_hc32(ehci, ~0x1f)
>  
> -#define IS_SHORT_READ(token) (QTD_LENGTH (token) != 0 && QTD_PID (token) == 
> 1)
> +#define IS_SHORT_READ(token) (QTD_LENGTH(token) != 0 && QTD_PID(token) == 1)
>  
>  /*-*/
>  
> @@ -806,7 +806,7 @@ static inline void set_ohci_hcfs(struct ehci_hcd *ehci, 
> int operational)
>  #define ehci_big_endian_desc(e)  ((e)->big_endian_desc)
>  
>  /* cpu to ehci */
> -static inline __hc32 cpu_to_hc32 (const struct ehci_hcd *ehci, const u32 x)
> +static inline __hc32 cpu_to_hc32(const struct ehci_hcd *ehci, const u32 x)
>  {
>   return ehci_big_endian_desc(ehci)
>   ? (__force __hc32)cpu_to_be32(x)
> @@ -814,14 +814,14 @@ static inline __hc32 cpu_to_hc32 (const struct ehci_hcd 
> *ehci, const u32 x)
>  }
>  
>  /* ehci to cpu */
> -static inline u32 hc32_to_cpu (const struct ehci_hcd *ehci, const __hc32 x)
> +static inline u32 hc32_to_cpu(const struct ehci_hcd *ehci, const __hc32 x)
>  {
>   return ehci_big_endian_desc(ehci)
>   ? be32_to_cpu((__force __be32)x)
>   : le32_to_cpu((__force __le32)x);
>  }
>  
> -static inline u32 hc32_to_cpup (const struct ehci_hcd *ehci, const __hc32 *x)
> +static inline u32 hc32_to_cpup(const struct ehci_hcd *ehci, const __hc32 *x)
>  {
>   return ehci_big_endian_desc(ehci)
>   ? be32_to_cpup((__force __be32 *)x)
> @@ -831,18 +831,18 @@ static inline u32 hc32_to_cpup (const struct ehci_hcd 
> *ehci, const __hc32 *x)
>  #else
>  
>  /* cpu to ehci */
> -static inline __hc32 cpu_to_hc32 (const struct ehci_hcd *ehci, const u32 x)
> +static inline __hc32 cpu_to_hc32(const struct ehci_hcd *ehci, const u32 x)
>  {
>   return cpu_to_le32(x);
>  }
>  
>  /* ehci to cpu */
> -static inline u32 hc32_to_cpu (const struct ehci_hcd *ehci, const __hc32 x)
> +static inline u32 hc32_to_cpu(const struct ehci_hcd *ehci, const __hc32 x)
>  {
>   return le32_to_cpu(x);
>  }
>  
> -static inline u32 hc32_to_cpup (const struct ehci_hcd *ehci, const __hc32 *x)
> +static inline u32 hc32_to_cpup(const struct ehci_hcd *ehci, const __hc32 *x)
>  {
>   return le32_to_cpup(x);
>  }
> -- 
> 2.6.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 4/9v2] usb: host: ehci.h: fix single statement macros

2015-12-10 Thread Peter Senna Tschudin
On Wed, Dec 09, 2015 at 07:32:33PM -0300, Geyslan G. Bem wrote:
> Don't use the 'do {} while (0)' wrapper in a single statement macro.
> 
> Caught by checkpatch: "WARNING: Single statement macros should not
> use a do {} while (0) loop"
> 
> Signed-off-by: Geyslan G. Bem 
As with previous, missing the changelog, but other than that the patch
looks good to me.

Acked-by: Peter Senna Tschudin 
> ---
>  drivers/usb/host/ehci.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
> index cfeebd8..945000a 100644
> --- a/drivers/usb/host/ehci.h
> +++ b/drivers/usb/host/ehci.h
> @@ -244,9 +244,9 @@ struct ehci_hcd { /* one per controller */
>   /* irq statistics */
>  #ifdef EHCI_STATS
>   struct ehci_stats   stats;
> -#define COUNT(x) do { (x)++; } while (0)
> +#define COUNT(x) ((x)++)
>  #else
> -#define COUNT(x) do {} while (0)
> +#define COUNT(x) ((void) 0)
>  #endif
>  
>   /* debug files */
> -- 
> 2.6.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 3/9v2] usb: host: ehci.h: remove space before open square bracket

2015-12-10 Thread Peter Senna Tschudin
On Wed, Dec 09, 2015 at 07:32:32PM -0300, Geyslan G. Bem wrote:
> Get rid of space before open square bracket.
> 
> Caught by checkpatch: "ERROR: space prohibited before open square
> bracket '['"
> 
> Signed-off-by: Geyslan G. Bem 
As with previous, missing the changelog, but other than that the patch
looks good to me.

Acked-by: Peter Senna Tschudin 
> ---
>  drivers/usb/host/ehci.h | 20 ++--
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
> index 46982df..cfeebd8 100644
> --- a/drivers/usb/host/ehci.h
> +++ b/drivers/usb/host/ehci.h
> @@ -185,7 +185,7 @@ struct ehci_hcd { /* one per controller */
>   struct ehci_sitd*last_sitd_to_free;
>  
>   /* per root hub port */
> - unsigned long   reset_done [EHCI_MAX_ROOT_PORTS];
> + unsigned long   reset_done[EHCI_MAX_ROOT_PORTS];
>  
>   /* bit vectors (one bit per port) */
>   unsigned long   bus_suspended;  /* which ports were
> @@ -316,8 +316,8 @@ struct ehci_qtd {
>  #define HALT_BIT(ehci)   cpu_to_hc32(ehci, QTD_STS_HALT)
>  #define STATUS_BIT(ehci) cpu_to_hc32(ehci, QTD_STS_STS)
>  
> - __hc32  hw_buf [5];/* see EHCI 3.5.4 */
> - __hc32  hw_buf_hi [5];/* Appendix B */
> + __hc32  hw_buf[5];/* see EHCI 3.5.4 */
> + __hc32  hw_buf_hi[5];/* Appendix B */
>  
>   /* the rest is HCD-private */
>   dma_addr_t  qtd_dma;/* qtd address */
> @@ -405,8 +405,8 @@ struct ehci_qh_hw {
>   __hc32  hw_qtd_next;
>   __hc32  hw_alt_next;
>   __hc32  hw_token;
> - __hc32  hw_buf [5];
> - __hc32  hw_buf_hi [5];
> + __hc32  hw_buf[5];
> + __hc32  hw_buf_hi[5];
>  } __attribute__ ((aligned(32)));
>  
>  struct ehci_qh {
> @@ -510,7 +510,7 @@ struct ehci_iso_stream {
>  struct ehci_itd {
>   /* first part defined by EHCI spec */
>   __hc32  hw_next;   /* see EHCI 3.3.1 */
> - __hc32  hw_transaction [8]; /* see EHCI 3.3.2 */
> + __hc32  hw_transaction[8]; /* see EHCI 3.3.2 */
>  #define EHCI_ISOC_ACTIVE(1<<31)/* activate transfer this 
> slot */
>  #define EHCI_ISOC_BUF_ERR   (1<<30)/* Data buffer error */
>  #define EHCI_ISOC_BABBLE(1<<29)/* babble detected */
> @@ -520,8 +520,8 @@ struct ehci_itd {
>  
>  #define ITD_ACTIVE(ehci) cpu_to_hc32(ehci, EHCI_ISOC_ACTIVE)
>  
> - __hc32  hw_bufp [7];/* see EHCI 3.3.3 */
> - __hc32  hw_bufp_hi [7]; /* Appendix B */
> + __hc32  hw_bufp[7]; /* see EHCI 3.3.3 */
> + __hc32  hw_bufp_hi[7];  /* Appendix B */
>  
>   /* the rest is HCD-private */
>   dma_addr_t  itd_dma;/* for this itd */
> @@ -565,9 +565,9 @@ struct ehci_sitd {
>  
>  #define SITD_ACTIVE(ehci)cpu_to_hc32(ehci, SITD_STS_ACTIVE)
>  
> - __hc32  hw_buf [2]; /* EHCI table 3-12 */
> + __hc32  hw_buf[2];  /* EHCI table 3-12 */
>   __hc32  hw_backpointer; /* EHCI table 3-13 */
> - __hc32  hw_buf_hi [2];  /* Appendix B */
> + __hc32  hw_buf_hi[2];   /* Appendix B */
>  
>   /* the rest is HCD-private */
>   dma_addr_t  sitd_dma;
> -- 
> 2.6.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 5/9v2] usb: host: ehci.h: remove direct use of __attribute__ keyword

2015-12-10 Thread Peter Senna Tschudin
On Wed, Dec 09, 2015 at 07:32:34PM -0300, Geyslan G. Bem wrote:
> Prefer to use __aligned(size) macro instead of
> __attribute__((aligned(size))).
> 
> Caught by checkpatch: "WARNING"
Not sure about the WARNING here, maybe just remove this line?

> 
> Signed-off-by: Geyslan G. Bem 
As with previous, missing the changelog, but other than that the patch
looks good to me.

Acked-by: Peter Senna Tschudin 
> ---
>  drivers/usb/host/ehci.h | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
> index 945000a..7b2b213 100644
> --- a/drivers/usb/host/ehci.h
> +++ b/drivers/usb/host/ehci.h
> @@ -324,7 +324,7 @@ struct ehci_qtd {
>   struct list_headqtd_list;   /* sw qtd list */
>   struct urb  *urb;   /* qtd's urb */
>   size_t  length; /* length of buffer */
> -} __attribute__ ((aligned (32)));
> +} __aligned(32);
>  
>  /* mask NakCnt+T in qh->hw_alt_next */
>  #define QTD_MASK(ehci)   cpu_to_hc32(ehci, ~0x1f)
> @@ -407,7 +407,7 @@ struct ehci_qh_hw {
>   __hc32  hw_token;
>   __hc32  hw_buf[5];
>   __hc32  hw_buf_hi[5];
> -} __attribute__ ((aligned(32)));
> +} __aligned(32);
>  
>  struct ehci_qh {
>   struct ehci_qh_hw   *hw;/* Must come first */
> @@ -535,7 +535,7 @@ struct ehci_itd {
>   unsignedframe;  /* where scheduled */
>   unsignedpg;
>   unsignedindex[8];   /* in urb->iso_frame_desc */
> -} __attribute__ ((aligned (32)));
> +} __aligned(32);
>  
>  /*-*/
>  
> @@ -578,7 +578,7 @@ struct ehci_sitd {
>   struct list_headsitd_list;  /* list of stream's sitds */
>   unsignedframe;
>   unsignedindex;
> -} __attribute__ ((aligned (32)));
> +} __aligned(32);
>  
>  /*-*/
>  
> @@ -598,7 +598,7 @@ struct ehci_fstn {
>   /* the rest is HCD-private */
>   dma_addr_t  fstn_dma;
>   union ehci_shadow   fstn_next;  /* ptr to periodic q entry */
> -} __attribute__ ((aligned (32)));
> +} __aligned(32);
>  
>  /*-*/
>  
> -- 
> 2.6.3
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/9v2] usb: host: ehci.h: remove space before comma

2015-12-10 Thread Peter Senna Tschudin
On Wed, Dec 09, 2015 at 07:32:30PM -0300, Geyslan G. Bem wrote:
> Get rid of spaces before comma.
> 
> Caught by checkpatch: "ERROR: space prohibited before that ','"
> 
> Signed-off-by: Geyslan G. Bem 
> ---
It is a good idea to include here (after the ---) what changed from V1.
Other than that:
Acked-by: Peter Senna Tschudin 

Not related to this patch, I did not receive patch 9/9v2.

>  drivers/usb/host/ehci.h | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
> index ec61aed..6a36ef4 100644
> --- a/drivers/usb/host/ehci.h
> +++ b/drivers/usb/host/ehci.h
> @@ -852,13 +852,13 @@ static inline u32 hc32_to_cpup (const struct ehci_hcd 
> *ehci, const __hc32 *x)
>  /*-*/
>  
>  #define ehci_dbg(ehci, fmt, args...) \
> - dev_dbg(ehci_to_hcd(ehci)->self.controller , fmt , ## args)
> + dev_dbg(ehci_to_hcd(ehci)->self.controller, fmt, ## args)
>  #define ehci_err(ehci, fmt, args...) \
> - dev_err(ehci_to_hcd(ehci)->self.controller , fmt , ## args)
> + dev_err(ehci_to_hcd(ehci)->self.controller, fmt, ## args)
>  #define ehci_info(ehci, fmt, args...) \
> - dev_info(ehci_to_hcd(ehci)->self.controller , fmt , ## args)
> + dev_info(ehci_to_hcd(ehci)->self.controller, fmt, ## args)
>  #define ehci_warn(ehci, fmt, args...) \
> - dev_warn(ehci_to_hcd(ehci)->self.controller , fmt , ## args)
> + dev_warn(ehci_to_hcd(ehci)->self.controller, fmt, ## args)
>  
>  
>  #ifndef CONFIG_DYNAMIC_DEBUG
> -- 
> 2.6.3
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/4] usb: gadget: remove redundant condition

2015-12-10 Thread Geyslan G. Bem
This patch removes redundant condition.

 (!A || (A && B)) is the same as (!A || B).

Tested by compilation only.
Caught by cppcheck.

Signed-off-by: Geyslan G. Bem 
---
 drivers/usb/gadget/udc/s3c-hsudc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/s3c-hsudc.c 
b/drivers/usb/gadget/udc/s3c-hsudc.c
index e9def42..82a9e2a 100644
--- a/drivers/usb/gadget/udc/s3c-hsudc.c
+++ b/drivers/usb/gadget/udc/s3c-hsudc.c
@@ -569,7 +569,7 @@ static int s3c_hsudc_handle_reqfeat(struct s3c_hsudc *hsudc,
hsep = >ep[ep_num];
switch (le16_to_cpu(ctrl->wValue)) {
case USB_ENDPOINT_HALT:
-   if (set || (!set && !hsep->wedge))
+   if (set || !hsep->wedge)
s3c_hsudc_set_halt(>ep, set);
return 0;
}
-- 
2.6.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] usb: dwc3: gadget: pass a condition to dev_WARN_ONCE()

2015-12-10 Thread Felipe Balbi

Hi,

kbuild test robot <l...@intel.com> writes:
> Hi Felipe,
>
> [auto build test ERROR on balbi-usb/next]
> [also build test ERROR on v4.4-rc4 next-20151210]
>
> url:
> https://github.com/0day-ci/linux/commits/Felipe-Balbi/usb-dwc3-gadget-pass-a-condition-to-dev_WARN_ONCE/20151211-031232
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git next
> config: x86_64-randconfig-x015-12102221 (attached as .config)
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=x86_64 
>
> All error/warnings (new ones prefixed by >>):
>
>In file included from include/linux/linkage.h:4:0,
> from include/linux/kernel.h:6,
> from drivers/usb/dwc3/gadget.c:19:
>drivers/usb/dwc3/gadget.c: In function 'dwc3_gadget_ep_disable':
>>> drivers/usb/dwc3/gadget.c:695:6: error: expected ')' before string constant
>  "%s is already disabled\n",
>  ^
>include/linux/compiler.h:147:28: note: in definition of macro '__trace_if'
>  if (__builtin_constant_p((cond)) ? !!(cond) :   \
>^
>>> drivers/usb/dwc3/gadget.c:694:2: note: in expansion of macro 'if'
>  if (dev_WARN_ONCE(dwc->dev, !(dep->flags & DWC3_EP_ENABLED)
>  ^
>>> include/linux/device.h:1295:2: note: in expansion of macro 'WARN_ONCE'
>  WARN_ONCE(condition, "%s %s: " format, \
>  n^
>>> drivers/usb/dwc3/gadget.c:694:6: note: in expansion of macro 'dev_WARN_ONCE'
>  if (dev_WARN_ONCE(dwc->dev, !(dep->flags & DWC3_EP_ENABLED)
>  ^
>>> drivers/usb/dwc3/gadget.c:696:6: error: expected ')' before 'dep'
>  dep->name))
>  ^
>include/linux/compiler.h:147:28: note: in definition of macro '__trace_if'
>  if (__builtin_constant_p((cond)) ? !!(cond) :   \
>^
>>> drivers/usb/dwc3/gadget.c:694:2: note: in expansion of macro 'if'
>  if (dev_WARN_ONCE(dwc->dev, !(dep->flags & DWC3_EP_ENABLED)
>  ^
>include/linux/compiler.h:145:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
>   ^
>include/asm-generic/bug.h:124:3: note: in expansion of macro 'if'
>   if (WARN(!__warned, format))\
>   ^
>include/asm-generic/bug.h:97:3: note: in expansion of macro '__WARN_printf'
>   __WARN_printf(format); \
>   ^
>include/asm-generic/bug.h:124:7: note: in expansion of macro 'WARN'
>   if (WARN(!__warned, format))\
>   ^
>>> include/linux/device.h:1295:2: note: in expansion of macro 'WARN_ONCE'
>  WARN_ONCE(condition, "%s %s: " format, \
>  ^
>>> drivers/usb/dwc3/gadget.c:694:6: note: in expansion of macro 'dev_WARN_ONCE'
>  if (dev_WARN_ONCE(dwc->dev, !(dep->flags & DWC3_EP_ENABLED)
>  ^
>>> include/linux/device.h:1295:23: warning: format '%s' expects a matching 
>>> 'char *' argument [-Wformat=]
>  WARN_ONCE(condition, "%s %s: " format, \
>   ^
>include/linux/compiler.h:147:28: note: in definition of macro '__trace_if'
>  if (__builtin_constant_p((cond)) ? !!(cond) :   \
>^
>>> drivers/usb/dwc3/gadget.c:694:2: note: in expansion of macro 'if'
>  if (dev_WARN_ONCE(dwc->dev, !(dep->flags & DWC3_EP_ENABLED)
>  ^
>include/linux/compiler.h:145:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
>   ^
>include/asm-generic/bug.h:124:3: note: in expansion of macro 'if'
>   if (WARN(!__warned, format))\
>   ^
>include/asm-generic/bug.h:97:3: note: in expansion of macro '__WARN_printf'
>   __WARN_printf(format); \
>   ^
>include/asm-generic/bug.h:124:7: note: in expansion of macro 'WARN'
>   if (WARN(!__warned, format))\
>   ^
>>> include/linux/device.h:1295:2: note: in expansion of macro 'WARN_ONCE'
>  WARN_ONCE(condition, "%s %s: " format, \
>  ^
>>> drivers/usb/dwc3/gadget.c:694:6: note: in expansion of macro 'dev_WARN_ONCE'
>  if (dev_WARN_ONCE(dwc->dev, !(dep->flags & DWC3_EP_ENABLED)
>  ^
>>> include/linux/device.h:1295:23: warning: format '%s' expects a matching 
>>> 'char *' argument [-Wformat=]
>  WARN_ONCE(condition, "%s %s: " format, \
>   ^
>include/linux/compiler.h:147:28: note: in definition of macro '__trace_if'
>  i

[PATCH 4/4] usb: musb: remove redundant condition

2015-12-10 Thread Geyslan G. Bem
This patch removes redundant condition.

 (!A || (A && B)) is the same as (!A || B).

Fixes indentation too.

Tested by: compilation only
Caught by: cppcheck

Signed-off-by: Geyslan G. Bem 
---
 drivers/usb/musb/musb_gadget.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 67ad630..87bd578 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -353,9 +353,8 @@ static void txstate(struct musb *musb, struct musb_request 
*req)
 *  1   >0  Yes(FS bulk)
 */
if (!musb_ep->hb_mult ||
-   (musb_ep->hb_mult &&
-can_bulk_split(musb,
-   musb_ep->type)))
+   can_bulk_split(musb,
+  musb_ep->type))
csr |= MUSB_TXCSR_AUTOSET;
}
csr &= ~MUSB_TXCSR_P_UNDERRUN;
-- 
2.6.3

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


[PATCH 1/4] usb: serial: remove redundant conditions

2015-12-10 Thread Geyslan G. Bem
This patch removes redundant conditions.

 (!A || (A && B)) is the same as (!A || B).
 (length && length > 5) can be reduced to a single evaluation.

Tested by compilation only.
Caught by cppcheck.

Signed-off-by: Geyslan G. Bem 
---
 drivers/usb/serial/io_edgeport.c | 35 ++-
 drivers/usb/serial/mos7840.c |  2 +-
 2 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index c086697..f49327d 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -1046,9 +1046,8 @@ static void edge_close(struct usb_serial_port *port)
 
edge_port->closePending = true;
 
-   if ((!edge_serial->is_epic) ||
-   ((edge_serial->is_epic) &&
-(edge_serial->epic_descriptor.Supports.IOSPChase))) {
+   if (!edge_serial->is_epic ||
+   edge_serial->epic_descriptor.Supports.IOSPChase) {
/* flush and chase */
edge_port->chaseResponsePending = true;
 
@@ -1061,9 +1060,8 @@ static void edge_close(struct usb_serial_port *port)
edge_port->chaseResponsePending = false;
}
 
-   if ((!edge_serial->is_epic) ||
-   ((edge_serial->is_epic) &&
-(edge_serial->epic_descriptor.Supports.IOSPClose))) {
+   if (!edge_serial->is_epic ||
+   edge_serial->epic_descriptor.Supports.IOSPClose) {
   /* close the port */
dev_dbg(>dev, "%s - Sending IOSP_CMD_CLOSE_PORT\n", 
__func__);
send_iosp_ext_cmd(edge_port, IOSP_CMD_CLOSE_PORT, 0);
@@ -1612,9 +1610,8 @@ static void edge_break(struct tty_struct *tty, int 
break_state)
struct edgeport_serial *edge_serial = usb_get_serial_data(port->serial);
int status;
 
-   if ((!edge_serial->is_epic) ||
-   ((edge_serial->is_epic) &&
-(edge_serial->epic_descriptor.Supports.IOSPChase))) {
+   if (!edge_serial->is_epic ||
+   edge_serial->epic_descriptor.Supports.IOSPChase) {
/* flush and chase */
edge_port->chaseResponsePending = true;
 
@@ -1628,9 +1625,8 @@ static void edge_break(struct tty_struct *tty, int 
break_state)
}
}
 
-   if ((!edge_serial->is_epic) ||
-   ((edge_serial->is_epic) &&
-(edge_serial->epic_descriptor.Supports.IOSPSetClrBreak))) {
+   if (!edge_serial->is_epic ||
+   edge_serial->epic_descriptor.Supports.IOSPSetClrBreak) {
if (break_state == -1) {
dev_dbg(>dev, "%s - Sending 
IOSP_CMD_SET_BREAK\n", __func__);
status = send_iosp_ext_cmd(edge_port,
@@ -2465,9 +2461,8 @@ static void change_port_settings(struct tty_struct *tty,
unsigned char stop_char  = STOP_CHAR(tty);
unsigned char start_char = START_CHAR(tty);
 
-   if ((!edge_serial->is_epic) ||
-   ((edge_serial->is_epic) &&
-(edge_serial->epic_descriptor.Supports.IOSPSetXChar))) {
+   if (!edge_serial->is_epic ||
+   edge_serial->epic_descriptor.Supports.IOSPSetXChar) {
send_iosp_ext_cmd(edge_port,
IOSP_CMD_SET_XON_CHAR, start_char);
send_iosp_ext_cmd(edge_port,
@@ -2494,13 +2489,11 @@ static void change_port_settings(struct tty_struct *tty,
}
 
/* Set flow control to the configured value */
-   if ((!edge_serial->is_epic) ||
-   ((edge_serial->is_epic) &&
-(edge_serial->epic_descriptor.Supports.IOSPSetRxFlow)))
+   if (!edge_serial->is_epic ||
+   edge_serial->epic_descriptor.Supports.IOSPSetRxFlow)
send_iosp_ext_cmd(edge_port, IOSP_CMD_SET_RX_FLOW, rxFlow);
-   if ((!edge_serial->is_epic) ||
-   ((edge_serial->is_epic) &&
-(edge_serial->epic_descriptor.Supports.IOSPSetTxFlow)))
+   if (!edge_serial->is_epic ||
+   edge_serial->epic_descriptor.Supports.IOSPSetTxFlow)
send_iosp_ext_cmd(edge_port, IOSP_CMD_SET_TX_FLOW, txFlow);
 
 
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 8ac9b55..2c69bfc 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -635,7 +635,7 @@ static void mos7840_interrupt_callback(struct urb *urb)
 * Byte 4 IIR Port 4 (port.number is 3)
 * Byte 5 FIFO status for both */
 
-   if (length && length > 5) {
+   if (length > 5) {
dev_dbg(>dev->dev, "%s", "Wrong data !!!\n");
return;
}
-- 
2.6.3

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


[PATCH 3/4] usb: host: remove redundant condition

2015-12-10 Thread Geyslan G. Bem
This patch removes redundant condition.

 (!A || (A && B)) is the same as (!A || B).

Tested by compilation only.
Caught by cppcheck.

Signed-off-by: Geyslan G. Bem 
---
 drivers/usb/host/fhci-sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/fhci-sched.c b/drivers/usb/host/fhci-sched.c
index 95ca598..23ecac5 100644
--- a/drivers/usb/host/fhci-sched.c
+++ b/drivers/usb/host/fhci-sched.c
@@ -288,7 +288,7 @@ static int scan_ed_list(struct fhci_usb *usb,
list_for_each_entry(ed, list, node) {
td = ed->td_head;
 
-   if (!td || (td && td->status == USB_TD_INPROGRESS))
+   if (!td || (td->status == USB_TD_INPROGRESS))
continue;
 
if (ed->state != FHCI_ED_OPER) {
-- 
2.6.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 18/18] usb: dwc2: Reduce delay when forcing mode in reset

2015-12-10 Thread John Youn
On 12/9/2015 8:45 PM, Doug Anderson wrote:
> John,
> 
> On Wed, Dec 2, 2015 at 11:15 AM, John Youn  wrote:
>> The delay for force mode is only 25ms according to the databook.
>>
>> Signed-off-by: John Youn 
>> ---
>>  drivers/usb/dwc2/core.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
>> index 91d63a8..a6fddbf 100644
>> --- a/drivers/usb/dwc2/core.c
>> +++ b/drivers/usb/dwc2/core.c
>> @@ -552,7 +552,7 @@ int dwc2_core_reset_and_force_mode(struct dwc2_hsotg 
>> *hsotg)
>>  * NOTE: This long sleep is _very_ important, otherwise the core will
>>  * not stay in host mode after a connector ID change!
>>  */
>> -   usleep_range(15, 16);
>> +   usleep_range(25000, 5);
> 
> This seems to work for me.  At least I've done reboots and not noticed
> any problems.  :-P
> 
> Personally I'd suggest tightening the range to something like (25000,
> 3) or even replacing with "msleep(25)".  From past experience I've
> found that usleep_range() nearly always picks the largest value you
> gave it.  That's supposed to be for power savings for things you do
> all the time.  For a rare thing like a reset it's just a waste of
> time.

I'm not sure why it was usleep_range or why the delay was so large. I
was being conservative in the change but I think I'll change it as you
suggest to msleep(25) and if issues come it we can deal with them.

Regards,
John
--
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 2/2] usb: xhci: add Broadcom specific fake doorbell

2015-12-10 Thread Hauke Mehrtens
On 12/08/2015 03:31 PM, Sergei Shtylyov wrote:
> Hello.
> 
> On 12/08/2015 01:31 AM, Hauke Mehrtens wrote:
> 
>> From: Rafał Miłecki 
>>
>> This fixes problem with controller seeing devices only in some small
>> percentage of cold boots.
>> This quirk is also added to the platform data so we can activate it
>> when we register our platform driver.
>>
>> Signed-off-by: Rafał Miłecki 
>> Signed-off-by: Hauke Mehrtens 
> 
> [...]
>> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
>> index 643d312..d49be9b 100644
>> --- a/drivers/usb/host/xhci.c
>> +++ b/drivers/usb/host/xhci.c
>> @@ -122,6 +122,39 @@ int xhci_halt(struct xhci_hcd *xhci)
>>   return ret;
>>   }
>>
>> +static int xhci_fake_doorbell(struct xhci_hcd *xhci, int slot_id)
>> +{
>> +u32 temp;
>> +
>> +/* alloc a virt device for slot */
>> +if (!xhci_alloc_virt_device(xhci, slot_id, NULL, GFP_NOIO)) {
>> +xhci_warn(xhci, "Could not allocate xHCI USB device data
>> structures\n");
>> +return -ENOMEM;
>> +}
>> +
>> +/* ring fake doorbell for slot_id ep 0 */
>> +xhci_ring_ep_doorbell(xhci, slot_id, 0, 0);
>> +usleep_range(1000, 1500);
>> +
>> +/* read the status register to check if HSE is set or not? */
>> +temp = readl(>op_regs->status);
>> +
>> +/* clear HSE if set */
>> +if (temp & STS_FATAL) {
>> +xhci_dbg(xhci, "HSE problem detected, status: 0x%x\n", temp);
>> +temp &= ~(0x1fff);
> 
>Parens around the literal not needed at all...

I will remove them

> 
> [...]
>> @@ -568,10 +601,25 @@ int xhci_init(struct usb_hcd *hcd)
>>
>>   static int xhci_run_finished(struct xhci_hcd *xhci)
>>   {
>> -if (xhci_start(xhci)) {
>> -xhci_halt(xhci);
>> -return -ENODEV;
>> +int err;
>> +
>> +err = xhci_start(xhci);
>> +if (err) {
>> +err = -ENODEV;
>> +goto out_err;
>> +}
>> +if (xhci->quirks & XHCI_FAKE_DOORBELL) {
>> +err = xhci_fake_doorbell(xhci, 1);
>> +if (err)
>> +goto out_err;
>> +
>> +err = xhci_start(xhci);
>> +if (err) {
>> +err = -ENODEV;
>> +goto out_err;
>> +}
> 
>Is it really necessary to call xhci_start() twice?

at least in my test it was necessary. I will look into this again.

Hauke
--
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: add quirk for devices with broken LPM

2015-12-10 Thread Alan Stern
Some USB device / host controller combinations seem to have problems
with Link Power Management.  For example, Steinar found that his xHCI
controller wouldn't handle bandwidth calculations correctly for two
video cards simultaneously when LPM was enabled, even though the bus
had plenty of bandwidth available.

This patch introduces a new quirk flag for devices that should remain
disabled for LPM, and creates quirk entries for Steinar's devices.

Signed-off-by: Alan Stern 
Reported-by: Steinar H. Gunderson 


---


[as1786]


 drivers/usb/core/hub.c |7 ++-
 drivers/usb/core/quirks.c  |6 ++
 include/linux/usb/quirks.h |3 +++
 3 files changed, 15 insertions(+), 1 deletion(-)

Index: usb-4.3/include/linux/usb/quirks.h
===
--- usb-4.3.orig/include/linux/usb/quirks.h
+++ usb-4.3/include/linux/usb/quirks.h
@@ -47,4 +47,7 @@
 /* device generates spurious wakeup, ignore remote wakeup capability */
 #define USB_QUIRK_IGNORE_REMOTE_WAKEUP BIT(9)
 
+/* device can't handle Link Power Management */
+#define USB_QUIRK_NO_LPM   BIT(10)
+
 #endif /* __LINUX_USB_QUIRKS_H */
Index: usb-4.3/drivers/usb/core/hub.c
===
--- usb-4.3.orig/drivers/usb/core/hub.c
+++ usb-4.3/drivers/usb/core/hub.c
@@ -124,6 +124,10 @@ struct usb_hub *usb_hub_to_struct_hub(st
 
 int usb_device_supports_lpm(struct usb_device *udev)
 {
+   /* Some devices have trouble with LPM */
+   if (udev->quirks & USB_QUIRK_NO_LPM)
+   return 0;
+
/* USB 2.1 (and greater) devices indicate LPM support through
 * their USB 2.0 Extended Capabilities BOS descriptor.
 */
@@ -4503,6 +4507,8 @@ hub_port_init (struct usb_hub *hub, stru
goto fail;
}
 
+   usb_detect_quirks(udev);
+
if (udev->wusb == 0 && le16_to_cpu(udev->descriptor.bcdUSB) >= 0x0201) {
retval = usb_get_bos_descriptor(udev);
if (!retval) {
@@ -4701,7 +4707,6 @@ static void hub_port_connect(struct usb_
if (status < 0)
goto loop;
 
-   usb_detect_quirks(udev);
if (udev->quirks & USB_QUIRK_DELAY_INIT)
msleep(1000);
 
Index: usb-4.3/drivers/usb/core/quirks.c
===
--- usb-4.3.orig/drivers/usb/core/quirks.c
+++ usb-4.3/drivers/usb/core/quirks.c
@@ -186,6 +186,12 @@ static const struct usb_device_id usb_qu
{ USB_DEVICE(0x1a0a, 0x0200), .driver_info =
USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL },
 
+   /* Blackmagic Design Intensity Shuttle */
+   { USB_DEVICE(0x1edb, 0xbd3b), .driver_info = USB_QUIRK_NO_LPM },
+
+   /* Blackmagic Design UltraStudio SDI */
+   { USB_DEVICE(0x1edb, 0xbd4f), .driver_info = USB_QUIRK_NO_LPM },
+
{ }  /* terminating entry must be last */
 };
 

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


Re: [PATCH] usb: dwc3: gadget: pass a condition to dev_WARN_ONCE()

2015-12-10 Thread David Cohen
Hi Felipe,

On Thu, Dec 10, 2015 at 01:09:58PM -0600, Felipe Balbi wrote:
> instead of using:
> 
>   if (condition) {
>   dev_WARN_ONCE(dev, true, "foo");
>   return -EINVAL;
>   }
> 
> let's use:
> 
>   if (dev_WARN_ONCE(dev, condition, "foo"))
>   return -EINVAL;
> 
> Signed-off-by: Felipe Balbi 
> ---
>  drivers/usb/dwc3/gadget.c | 14 ++
>  1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 3063c5ba5563..96cc1d756d99 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -661,11 +661,10 @@ static int dwc3_gadget_ep_enable(struct usb_ep *ep,
>   dep = to_dwc3_ep(ep);
>   dwc = dep->dwc;
>  
> - if (dep->flags & DWC3_EP_ENABLED) {
> - dev_WARN_ONCE(dwc->dev, true, "%s is already enabled\n",
> - dep->name);
> + if (dev_WARN_ONCE(dwc->dev, dep->flags & DWC3_EP_ENABLED,
> + "%s is already enabled\n",
> + dep->name))
>   return 0;
> - }
>  
>   spin_lock_irqsave(>lock, flags);
>   ret = __dwc3_gadget_ep_enable(dep, desc, ep->comp_desc, false, false);
> @@ -689,11 +688,10 @@ static int dwc3_gadget_ep_disable(struct usb_ep *ep)
>   dep = to_dwc3_ep(ep);
>   dwc = dep->dwc;
>  
> - if (!(dep->flags & DWC3_EP_ENABLED)) {
> - dev_WARN_ONCE(dwc->dev, true, "%s is already disabled\n",
> - dep->name);
> + if (dev_WARN_ONCE(dwc->dev, !(dep->flags & DWC3_EP_ENABLED)

You missed a , after the condition.

Br, David

> + "%s is already disabled\n",
> + dep->name))
>   return 0;
> - }
>  
>   spin_lock_irqsave(>lock, flags);
>   ret = __dwc3_gadget_ep_disable(dep);
> -- 
> 2.6.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
--
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 15/18] usb: dwc2: Improve handling of host and device hwparams

2015-12-10 Thread John Youn
On 12/9/2015 8:45 PM, Doug Anderson wrote:
> John,
> 
> On Wed, Dec 2, 2015 at 11:15 AM, John Youn  wrote:
>> This commit adds separate functions for getting the host and device
>> specific hardware params. These functions check whether the parameters
>> need to be read at all, depending on dr_mode, and they force the mode
>> only if necessary. This saves some delays during probe.
>>
>> Signed-off-by: John Youn 
>> ---
>>  drivers/usb/dwc2/core.c | 93 
>> +
>>  drivers/usb/dwc2/core.h |  1 +
>>  2 files changed, 71 insertions(+), 23 deletions(-)
>>
>> diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
>> index caaff42..91d63a8 100644
>> --- a/drivers/usb/dwc2/core.c
>> +++ b/drivers/usb/dwc2/core.c
>> @@ -3159,17 +3159,76 @@ static void dwc2_clear_force_mode(struct dwc2_hsotg 
>> *hsotg)
>> usleep_range(25000, 5);
>>  }
>>
>> +/*
>> + * Gets host hardware parameters. Forces host mode if not currently in
>> + * host mode. Should be called immediately after a core soft reset in
>> + * order to get the reset values.
>> + */
>> +static void dwc2_get_host_hwparams(struct dwc2_hsotg *hsotg)
>> +{
>> +   struct dwc2_hw_params *hw = >hw_params;
>> +   u32 gnptxfsiz;
>> +   u32 hptxfsiz;
>> +   bool forced;
>> +
>> +   if (hsotg->dr_mode == USB_DR_MODE_PERIPHERAL)
>> +   return;
>> +
>> +   forced = dwc2_force_host_if_needed(hsotg);
>> +
>> +   gnptxfsiz = dwc2_readl(hsotg->regs + GNPTXFSIZ);
>> +   hptxfsiz = dwc2_readl(hsotg->regs + HPTXFSIZ);
>> +   dev_dbg(hsotg->dev, "gnptxfsiz=%08x\n", gnptxfsiz);
>> +   dev_dbg(hsotg->dev, "hptxfsiz=%08x\n", hptxfsiz);
>> +
>> +   if (forced)
>> +   dwc2_clear_force_mode(hsotg);
>> +
>> +   hw->host_nperio_tx_fifo_size = (gnptxfsiz & FIFOSIZE_DEPTH_MASK) >>
>> +  FIFOSIZE_DEPTH_SHIFT;
>> +   hw->host_perio_tx_fifo_size = (hptxfsiz & FIFOSIZE_DEPTH_MASK) >>
>> + FIFOSIZE_DEPTH_SHIFT;
>> +}
>> +
>> +/*
>> + * Gets device hardware parameters. Forces device mode if not
>> + * currently in device mode. Should be called immediately after a core
>> + * soft reset in order to get the reset values.
>> + */
>> +static void dwc2_get_dev_hwparams(struct dwc2_hsotg *hsotg)
>> +{
>> +   struct dwc2_hw_params *hw = >hw_params;
>> +   bool forced;
>> +   u32 gnptxfsiz;
>> +
>> +   if (hsotg->dr_mode == USB_DR_MODE_HOST)
>> +   return;
>> +
>> +   forced = dwc2_force_device_if_needed(hsotg);
> 
> Interesting.  You're getting a new parameter that's never been needed
> in the code before and (as far as I can tell) isn't used anywhere in
> your series.  I presume this is in prep for a future patch that uses
> this?
> 
> At the moment you're burning a decent delay to read this unused
> parameter (potentially up to 100ms), so hopefully there's a good use
> for it eventually...

I'll remove this from this series. It will be used by the gadget but
those changes aren't ready to be submitted yet.


> 
> 
>> +
>> +   gnptxfsiz = dwc2_readl(hsotg->regs + GNPTXFSIZ);
>> +   dev_dbg(hsotg->dev, "gnptxfsiz=%08x\n", gnptxfsiz);
>> +
>> +   if (forced)
>> +   dwc2_clear_force_mode(hsotg);
>> +
>> +   hw->dev_nperio_tx_fifo_size = (gnptxfsiz & FIFOSIZE_DEPTH_MASK) >>
>> +  FIFOSIZE_DEPTH_SHIFT;
>> +}
>> +
>>  /**
>>   * During device initialization, read various hardware configuration
>>   * registers and interpret the contents.
>> + *
>> + * This should be called during driver probe. It will perform a core
>> + * soft reset in order to get the reset values of the parameters.
>>   */
>>  int dwc2_get_hwparams(struct dwc2_hsotg *hsotg)
>>  {
>> struct dwc2_hw_params *hw = >hw_params;
>> unsigned width;
>> u32 hwcfg1, hwcfg2, hwcfg3, hwcfg4;
>> -   u32 hptxfsiz, grxfsiz, gnptxfsiz;
>> -   u32 gusbcfg = 0;
>> +   u32 grxfsiz;
>> int retval;
>>
>> /*
>> @@ -3206,23 +3265,6 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg)
>> dev_dbg(hsotg->dev, "hwcfg4=%08x\n", hwcfg4);
>> dev_dbg(hsotg->dev, "grxfsiz=%08x\n", grxfsiz);
>>
>> -   /* Force host mode to get HPTXFSIZ / GNPTXFSIZ exact power on value 
>> */
>> -   if (hsotg->dr_mode != USB_DR_MODE_HOST) {
>> -   gusbcfg = dwc2_readl(hsotg->regs + GUSBCFG);
>> -   dwc2_writel(gusbcfg | GUSBCFG_FORCEHOSTMODE,
>> -   hsotg->regs + GUSBCFG);
>> -   usleep_range(25000, 5);
>> -   }
>> -
>> -   gnptxfsiz = dwc2_readl(hsotg->regs + GNPTXFSIZ);
>> -   hptxfsiz = dwc2_readl(hsotg->regs + HPTXFSIZ);
>> -   dev_dbg(hsotg->dev, "gnptxfsiz=%08x\n", gnptxfsiz);
>> -   dev_dbg(hsotg->dev, "hptxfsiz=%08x\n", hptxfsiz);
>> -   if (hsotg->dr_mode != 

Re: [PATCH] usb: dwc3: gadget: pass a condition to dev_WARN_ONCE()

2015-12-10 Thread Felipe Balbi

Hi,

David Cohen  writes:
> Hi Felipe,
>
> On Thu, Dec 10, 2015 at 01:09:58PM -0600, Felipe Balbi wrote:
>> instead of using:
>> 
>>  if (condition) {
>>  dev_WARN_ONCE(dev, true, "foo");
>>  return -EINVAL;
>>  }
>> 
>> let's use:
>> 
>>  if (dev_WARN_ONCE(dev, condition, "foo"))
>>  return -EINVAL;
>> 
>> Signed-off-by: Felipe Balbi 
>> ---
>>  drivers/usb/dwc3/gadget.c | 14 ++
>>  1 file changed, 6 insertions(+), 8 deletions(-)
>> 
>> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
>> index 3063c5ba5563..96cc1d756d99 100644
>> --- a/drivers/usb/dwc3/gadget.c
>> +++ b/drivers/usb/dwc3/gadget.c
>> @@ -661,11 +661,10 @@ static int dwc3_gadget_ep_enable(struct usb_ep *ep,
>>  dep = to_dwc3_ep(ep);
>>  dwc = dep->dwc;
>>  
>> -if (dep->flags & DWC3_EP_ENABLED) {
>> -dev_WARN_ONCE(dwc->dev, true, "%s is already enabled\n",
>> -dep->name);
>> +if (dev_WARN_ONCE(dwc->dev, dep->flags & DWC3_EP_ENABLED,
>> +"%s is already enabled\n",
>> +dep->name))
>>  return 0;
>> -}
>>  
>>  spin_lock_irqsave(>lock, flags);
>>  ret = __dwc3_gadget_ep_enable(dep, desc, ep->comp_desc, false, false);
>> @@ -689,11 +688,10 @@ static int dwc3_gadget_ep_disable(struct usb_ep *ep)
>>  dep = to_dwc3_ep(ep);
>>  dwc = dep->dwc;
>>  
>> -if (!(dep->flags & DWC3_EP_ENABLED)) {
>> -dev_WARN_ONCE(dwc->dev, true, "%s is already disabled\n",
>> -dep->name);
>> +if (dev_WARN_ONCE(dwc->dev, !(dep->flags & DWC3_EP_ENABLED)
>
> You missed a , after the condition.

yup, already fixed.

8<---
commit 4b2ec826d09cd0307b8250fa21795b718cdb7d37
Author: Felipe Balbi 
Date:   Thu Dec 10 13:08:20 2015 -0600

usb: dwc3: gadget: pass a condition to dev_WARN_ONCE()

instead of using:

if (condition) {
dev_WARN_ONCE(dev, true, "foo");
return -EINVAL;
}

let's use:

if (dev_WARN_ONCE(dev, condition, "foo"))
return -EINVAL;

Signed-off-by: Felipe Balbi 

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 3063c5ba5563..1212ae4a3c2f 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -661,11 +661,10 @@ static int dwc3_gadget_ep_enable(struct usb_ep *ep,
dep = to_dwc3_ep(ep);
dwc = dep->dwc;
 
-   if (dep->flags & DWC3_EP_ENABLED) {
-   dev_WARN_ONCE(dwc->dev, true, "%s is already enabled\n",
-   dep->name);
+   if (dev_WARN_ONCE(dwc->dev, dep->flags & DWC3_EP_ENABLED,
+   "%s is already enabled\n",
+   dep->name))
return 0;
-   }
 
spin_lock_irqsave(>lock, flags);
ret = __dwc3_gadget_ep_enable(dep, desc, ep->comp_desc, false, false);
@@ -689,11 +688,10 @@ static int dwc3_gadget_ep_disable(struct usb_ep *ep)
dep = to_dwc3_ep(ep);
dwc = dep->dwc;
 
-   if (!(dep->flags & DWC3_EP_ENABLED)) {
-   dev_WARN_ONCE(dwc->dev, true, "%s is already disabled\n",
-   dep->name);
+   if (dev_WARN_ONCE(dwc->dev, !(dep->flags & DWC3_EP_ENABLED),
+   "%s is already disabled\n",
+   dep->name))
return 0;
-   }
 
spin_lock_irqsave(>lock, flags);
ret = __dwc3_gadget_ep_disable(dep);


-- 
balbi


signature.asc
Description: PGP signature


[PATCH 4/5] [v2] usb: host: ehci-msm: Fix register initialization

2015-12-10 Thread Timur Tabi
From: Jack Pham 

The default value for the 'transceiver select' field of
the PORTSC register may not always be correct. Previously
the phy-msm-usb driver would do this for us, but since
ehci-msm can now be instantiated standalone without any PHY
driver, the register needs to be explicitly initialized to
ULPI mode to properly communicate with the PHY.

This is not readily apparent, as firmware or bootloader code
also happen to pre-initialize this for us. However, it can
manifest when performing a driver unbind/rebind as follows:

 cd /sys/bus/platform/drivers/msm_hsusb_host
 echo QCOM8040:00 > unbind
 echo QCOM8040:00 > bind

The EHCI core executes a controller reset as part of this,
and as a result the register in question would revert to
its default state and must be re-initialized properly.
Furthermore this may be useful in the future when adding
PM suspend/resume support.

Signed-off-by: Jack Pham 
Signed-off-by: Timur Tabi 
---
 drivers/usb/host/ehci-msm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c
index 102837e..b71947d 100644
--- a/drivers/usb/host/ehci-msm.c
+++ b/drivers/usb/host/ehci-msm.c
@@ -56,6 +56,8 @@ static int ehci_msm_reset(struct usb_hcd *hcd)
if (retval)
return retval;
 
+   /* select ULPI phy and clear other status/control bits in PORTSC */
+   writel(PORTSC_PTS_ULPI, USB_PORTSC);
/* bursts of unspecified length. */
writel(0, USB_AHBBURST);
/* Use the AHB transactor, allow posted data writes */
-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project.

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


[PATCH 2/5] [v2] usb: host: ehci-msm: Remove dependency on OTG PHY

2015-12-10 Thread Timur Tabi
From: Jack Pham 

Currently the EHCI MSM driver has a hard dependency to be created
by an OTG layer, namely the phy-msm-usb driver. In some cases or
board configurations we want to allow the EHCI host to be
instantiated without OTG capability. Instead, relax the dependency
on having an OTG PHY being present and call usb_add_hcd() directly.

Signed-off-by: Jack Pham 
Signed-off-by: Timur Tabi 
---
 drivers/usb/host/ehci-msm.c | 53 ++---
 1 file changed, 31 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c
index aed499d..e1004bc 100644
--- a/drivers/usb/host/ehci-msm.c
+++ b/drivers/usb/host/ehci-msm.c
@@ -106,9 +106,9 @@ static int ehci_msm_probe(struct platform_device *pdev)
}
 
/*
-* OTG driver takes care of PHY initialization, clock management,
-* powering up VBUS, mapping of registers address space and power
-* management.
+* If there is an OTG driver, let it take care of PHY initialization,
+* clock management, powering up VBUS, mapping of registers address
+* space and power management.
 */
if (pdev->dev.of_node)
phy = devm_usb_get_phy_by_phandle(>dev, "usb-phy", 0);
@@ -116,27 +116,35 @@ static int ehci_msm_probe(struct platform_device *pdev)
phy = devm_usb_get_phy(>dev, USB_PHY_TYPE_USB2);
 
if (IS_ERR(phy)) {
-   dev_err(>dev, "unable to find transceiver\n");
-   ret = -EPROBE_DEFER;
-   goto put_hcd;
-   }
-
-   ret = otg_set_host(phy->otg, >self);
-   if (ret < 0) {
-   dev_err(>dev, "unable to register with transceiver\n");
-   goto put_hcd;
+   if (PTR_ERR(phy) == -EPROBE_DEFER) {
+   dev_err(>dev, "unable to find transceiver\n");
+   ret = -EPROBE_DEFER;
+   goto put_hcd;
+   }
+   phy = NULL;
}
 
hcd->usb_phy = phy;
device_init_wakeup(>dev, 1);
-   /*
-* OTG device parent of HCD takes care of putting
-* hardware into low power mode.
-*/
-   pm_runtime_no_callbacks(>dev);
-   pm_runtime_enable(>dev);
 
-   /* FIXME: need to call usb_add_hcd() here? */
+   if (phy && phy->otg) {
+   /*
+* MSM OTG driver takes care of adding the HCD and
+* placing hardware into low power mode via runtime PM.
+*/
+   ret = otg_set_host(phy->otg, >self);
+   if (ret < 0) {
+   dev_err(>dev, "unable to register with 
transceiver\n");
+   goto put_hcd;
+   }
+
+   pm_runtime_no_callbacks(>dev);
+   pm_runtime_enable(>dev);
+   } else {
+   ret = usb_add_hcd(hcd, hcd->irq, IRQF_SHARED);
+   if (ret)
+   goto put_hcd;
+   }
 
return 0;
 
@@ -154,9 +162,10 @@ static int ehci_msm_remove(struct platform_device *pdev)
pm_runtime_disable(>dev);
pm_runtime_set_suspended(>dev);
 
-   otg_set_host(hcd->usb_phy->otg, NULL);
-
-   /* FIXME: need to call usb_remove_hcd() here? */
+   if (hcd->usb_phy && hcd->usb_phy->otg)
+   otg_set_host(hcd->usb_phy->otg, NULL);
+   else
+   usb_remove_hcd(hcd);
 
usb_put_hcd(hcd);
 
-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project.

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


[PATCH 3/5] [v2] usb: host: ehci-msm: Add support for ACPI probing

2015-12-10 Thread Timur Tabi
From: Jack Pham 

Allow the EHCI MSM driver to probe against an ACPI enumerated
device with ID QCOM8040.

Signed-off-by: Jack Pham 
Signed-off-by: Timur Tabi 
---
 drivers/usb/host/ehci-msm.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c
index e1004bc..102837e 100644
--- a/drivers/usb/host/ehci-msm.c
+++ b/drivers/usb/host/ehci-msm.c
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "ehci.h"
 
@@ -202,6 +203,12 @@ static const struct dev_pm_ops ehci_msm_dev_pm_ops = {
.resume  = ehci_msm_pm_resume,
 };
 
+static const struct acpi_device_id msm_ehci_acpi_ids[] = {
+   { "QCOM8040", 0 },
+   { }
+};
+MODULE_DEVICE_TABLE(acpi, msm_ehci_acpi_ids);
+
 static const struct of_device_id msm_ehci_dt_match[] = {
{ .compatible = "qcom,ehci-host", },
{}
@@ -215,6 +222,7 @@ static struct platform_driver ehci_msm_driver = {
   .name = "msm_hsusb_host",
   .pm = _msm_dev_pm_ops,
   .of_match_table = msm_ehci_dt_match,
+  .acpi_match_table = ACPI_PTR(msm_ehci_acpi_ids),
},
 };
 
-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project.

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


[PATCH 1/5] [v2] usb: host: ehci-msm: Allow LS devices to work

2015-12-10 Thread Timur Tabi
From: Jack Pham 

Disable the silicon quirk which is normally enabled for HSIC
host mode. This would otherwise prevent low speed devices
from enumerating properly.

Signed-off-by: Jack Pham 
Signed-off-by: Timur Tabi 
---
 drivers/usb/host/ehci-msm.c  | 2 ++
 include/linux/usb/msm_hsusb_hw.h | 1 +
 2 files changed, 3 insertions(+)

diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c
index c23e285..aed499d 100644
--- a/drivers/usb/host/ehci-msm.c
+++ b/drivers/usb/host/ehci-msm.c
@@ -61,6 +61,8 @@ static int ehci_msm_reset(struct usb_hcd *hcd)
writel(0x8, USB_AHBMODE);
/* Disable streaming mode and select host mode */
writel(0x13, USB_USBMODE);
+   /* Disable ULPI_TX_PKT_EN_CLR_FIX which is valid only for HSIC */
+   writel(readl(USB_GENCONFIG_2) & ~ULPI_TX_PKT_EN_CLR_FIX, 
USB_GENCONFIG_2);
 
return 0;
 }
diff --git a/include/linux/usb/msm_hsusb_hw.h b/include/linux/usb/msm_hsusb_hw.h
index e159b39..974c379 100644
--- a/include/linux/usb/msm_hsusb_hw.h
+++ b/include/linux/usb/msm_hsusb_hw.h
@@ -22,6 +22,7 @@
 #define USB_AHBBURST (MSM_USB_BASE + 0x0090)
 #define USB_AHBMODE  (MSM_USB_BASE + 0x0098)
 #define USB_GENCONFIG_2  (MSM_USB_BASE + 0x00a0)
+#define ULPI_TX_PKT_EN_CLR_FIX BIT(19)
 
 #define USB_CAPLENGTH(MSM_USB_BASE + 0x0100) /* 8 bit */
 
-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project.

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


[PATCH] extcon-usb-gpio: add enable pin support

2015-12-10 Thread Sergei Shtylyov
Sometimes  there's a real  OTG chip behind the USB ID signal mapped to a GPIO
pin: in my case it's Maxim Integrated MAX3355E which  integrates Vbus charge
pump and comparators and passes  thru the ID  signal  from an OTG connector.
This chip also has the SHDN# pin which  should be  driven high for the normal
operation  and low to  save power;  it  is connected to a GPIO pin as well on,
hence  we'll have  to  teach the driver to parse the new optional device tree
property, "enable-gpio"...

Signed-off-by: Sergei Shtylyov 

---
The patch is against the 'extcon-next' branch of the 'extcon.git' repo.

 Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt |3 +++
 drivers/extcon/extcon-usb-gpio.c |5 +
 2 files changed, 8 insertions(+)

Index: extcon/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
===
--- extcon.orig/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
+++ extcon/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
@@ -7,6 +7,9 @@ Required properties:
 - compatible: Should be "linux,extcon-usb-gpio"
 - id-gpio: gpio for USB ID pin. See gpio binding.
 
+Optional properties:
+- enable-gpio: gpio for the enable pin. See gpio binding.
+
 Example: Examples of extcon-usb-gpio node in dra7-evm.dts as listed below:
extcon_usb1 {
compatible = "linux,extcon-usb-gpio";
Index: extcon/drivers/extcon/extcon-usb-gpio.c
===
--- extcon.orig/drivers/extcon/extcon-usb-gpio.c
+++ extcon/drivers/extcon/extcon-usb-gpio.c
@@ -33,6 +33,7 @@ struct usb_extcon_info {
struct device *dev;
struct extcon_dev *edev;
 
+   struct gpio_desc *enable_gpiod;
struct gpio_desc *id_gpiod;
int id_irq;
 
@@ -99,6 +100,8 @@ static int usb_extcon_probe(struct platf
return -ENOMEM;
 
info->dev = dev;
+   info->enable_gpiod = devm_gpiod_get_optional(>dev, "enable",
+GPIOD_OUT_HIGH);
info->id_gpiod = devm_gpiod_get(>dev, "id", GPIOD_IN);
if (IS_ERR(info->id_gpiod)) {
dev_err(dev, "failed to get ID GPIO\n");
@@ -155,6 +158,8 @@ static int usb_extcon_remove(struct plat
 
cancel_delayed_work_sync(>wq_detcable);
 
+   gpiod_set_value_cansleep(info->enable_gpiod, 0);
+
return 0;
 }
 

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


[PATCH 5/5] [v2] usb: host: ehci-msm: Register usb shutdown function

2015-12-10 Thread Timur Tabi
From: Azriel Samson 

Registering usb_hcd_platform_shutdown to be called during
shutdown. This is a generic function that performs the
generic host stack's shutdown. It ensures that USB
operations do not continue while kexec boots a new kernel.

Signed-off-by: Azriel Samson 
Signed-off-by: Timur Tabi 
---
 drivers/usb/host/ehci-msm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c
index b71947d..3e226ef 100644
--- a/drivers/usb/host/ehci-msm.c
+++ b/drivers/usb/host/ehci-msm.c
@@ -220,6 +220,7 @@ MODULE_DEVICE_TABLE(of, msm_ehci_dt_match);
 static struct platform_driver ehci_msm_driver = {
.probe  = ehci_msm_probe,
.remove = ehci_msm_remove,
+   .shutdown = usb_hcd_platform_shutdown,
.driver = {
   .name = "msm_hsusb_host",
   .pm = _msm_dev_pm_ops,
-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project.

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


[PATCH] usb: ehci: refactor scan_isoc function

2015-12-10 Thread Geyslan G. Bem
This patch removes an infinite for loop and makes use of the already
existing 'restart' tag, reducing one leading tab.

The comments were corrected conforming coding style.

Tested by compilation only.
Caught by checkpatch:
 WARNING: Too many leading tabs - consider code refactoring

Signed-off-by: Geyslan G. Bem 
---
 drivers/usb/host/ehci-sched.c | 203 ++
 1 file changed, 104 insertions(+), 99 deletions(-)

diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index f9a3327..c6e9731 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -2383,6 +2383,9 @@ static void scan_isoc(struct ehci_hcd *ehci)
unsignedfmask = ehci->periodic_size - 1;
boolmodified, live;
 
+   union ehci_shadow q, *q_p;
+   __hc32 type, *hw_p;
+
/*
 * When running, scan from last scan point up to "now"
 * else clean up by scanning everything that's left.
@@ -2399,119 +2402,121 @@ static void scan_isoc(struct ehci_hcd *ehci)
ehci->now_frame = now_frame;
 
frame = ehci->last_iso_frame;
-   for (;;) {
-   union ehci_shadow   q, *q_p;
-   __hc32  type, *hw_p;
 
 restart:
-   /* scan each element in frame's queue for completions */
-   q_p = >pshadow [frame];
-   hw_p = >periodic [frame];
-   q.ptr = q_p->ptr;
-   type = Q_NEXT_TYPE(ehci, *hw_p);
-   modified = false;
-
-   while (q.ptr != NULL) {
-   switch (hc32_to_cpu(ehci, type)) {
-   case Q_TYPE_ITD:
-   /* If this ITD is still active, leave it for
-* later processing ... check the next entry.
-* No need to check for activity unless the
-* frame is current.
-*/
-   if (frame == now_frame && live) {
-   rmb();
-   for (uf = 0; uf < 8; uf++) {
-   if (q.itd->hw_transaction[uf] &
-   ITD_ACTIVE(ehci))
-   break;
-   }
-   if (uf < 8) {
-   q_p = >itd_next;
-   hw_p = >hw_next;
-   type = Q_NEXT_TYPE(ehci,
-   q.itd->hw_next);
-   q = *q_p;
+   /* Scan each element in frame's queue for completions */
+   q_p = >pshadow [frame];
+   hw_p = >periodic [frame];
+   q.ptr = q_p->ptr;
+   type = Q_NEXT_TYPE(ehci, *hw_p);
+   modified = false;
+
+   while (q.ptr != NULL) {
+   switch (hc32_to_cpu(ehci, type)) {
+   case Q_TYPE_ITD:
+   /*
+* If this ITD is still active, leave it for
+* later processing ... check the next entry.
+* No need to check for activity unless the
+* frame is current.
+*/
+   if (frame == now_frame && live) {
+   rmb();
+   for (uf = 0; uf < 8; uf++) {
+   if (q.itd->hw_transaction[uf] &
+   ITD_ACTIVE(ehci))
break;
-   }
}
-
-   /* Take finished ITDs out of the schedule
-* and process them:  recycle, maybe report
-* URB completion.  HC won't cache the
-* pointer for much longer, if at all.
-*/
-   *q_p = q.itd->itd_next;
-   if (!ehci->use_dummy_qh ||
-   q.itd->hw_next != EHCI_LIST_END(ehci))
-   *hw_p = q.itd->hw_next;
-   else
-   *hw_p = cpu_to_hc32(ehci,
-   ehci->dummy->qh_dma);
-   type = Q_NEXT_TYPE(ehci, q.itd->hw_next);
-   wmb();
-   modified = itd_complete (ehci, q.itd);
-   q = *q_p;
-   break;
-   case 

[PATCH v3 1/2] usb: xhci: plat: fix adding usb3-lpm-capable quirk

2015-12-10 Thread Hauke Mehrtens
The xhci->quirks member is overwritten in xhci_gen_setup() with the
quirks given through the module load parameter. Without this patch the
usb3-lpm-capable quirk will be over written before it gets used. This
patch moves the quirks code to the xhci_plat_quirks() callback function
which gets called directly after the quirks member variable is
overwritten with the module load parameter.

I do not have any hardware which is using usb3-lpm-capabls so I can not
test this on real hardware.

Signed-off-by: Hauke Mehrtens 
---
 drivers/usb/host/xhci-plat.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 770b6b0..4fb295b 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -39,12 +39,20 @@ static const struct xhci_driver_overrides 
xhci_plat_overrides __initconst = {
 
 static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci)
 {
+   struct platform_device  *pdev = to_platform_device(dev);
+   struct device_node  *node = pdev->dev.of_node;
+   struct usb_xhci_pdata   *pdata = dev_get_platdata(>dev);
+
/*
 * As of now platform drivers don't provide MSI support so we ensure
 * here that the generic code does not try to make a pci_dev from our
 * dev struct in order to setup MSI
 */
xhci->quirks |= XHCI_PLAT;
+
+   if ((node && of_property_read_bool(node, "usb3-lpm-capable")) ||
+   (pdata && pdata->usb3_lpm_capable))
+   xhci->quirks |= XHCI_LPM_SUPPORT;
 }
 
 /* called during probe() after chip reset completes */
@@ -118,7 +126,6 @@ MODULE_DEVICE_TABLE(of, usb_xhci_of_match);
 static int xhci_plat_probe(struct platform_device *pdev)
 {
struct device_node  *node = pdev->dev.of_node;
-   struct usb_xhci_pdata   *pdata = dev_get_platdata(>dev);
const struct of_device_id *match;
const struct hc_driver  *driver;
struct xhci_hcd *xhci;
@@ -204,10 +211,6 @@ static int xhci_plat_probe(struct platform_device *pdev)
goto disable_clk;
}
 
-   if ((node && of_property_read_bool(node, "usb3-lpm-capable")) ||
-   (pdata && pdata->usb3_lpm_capable))
-   xhci->quirks |= XHCI_LPM_SUPPORT;
-
if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
xhci->shared_hcd->can_do_streams = 1;
 
-- 
2.6.2

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


[PATCH v3 0/2] usb: xhci: fix platform quirks and add fake doorbell

2015-12-10 Thread Hauke Mehrtens
These patches are needed to make the Broadcom XHCI controller work. We
will submit support for the controller later.

It would be nice if someone from Broadcom could elaborate a bit why
this workaround is needed. I took this code from a GPL tar of a home router
using a Broadcom Northstar SoC.

changes since:
v2:
 * added device tree attribute "usb3-fake-doorbell"
 * added documentation for platform data member and device tree attribute
 * fixed some style problems
 * tried to improve documentation, still waiting for Broadcom
v1:
 * I removed the bcma-hcd specific patches for now.

Hauke Mehrtens (1):
  usb: xhci: plat: fix adding usb3-lpm-capable quirk

Rafał Miłecki (1):
  usb: xhci: add Broadcom specific fake doorbell

 Documentation/devicetree/bindings/usb/usb-xhci.txt |  2 +
 drivers/usb/host/xhci-plat.c   | 17 +--
 drivers/usb/host/xhci.c| 59 --
 drivers/usb/host/xhci.h|  1 +
 include/linux/usb/xhci_pdriver.h   |  3 ++
 5 files changed, 74 insertions(+), 8 deletions(-)

-- 
2.6.2

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


Re: [PATCH 15/18] usb: dwc2: Improve handling of host and device hwparams

2015-12-10 Thread John Youn
On 12/10/2015 2:55 PM, Felipe Balbi wrote:
> 
> Hi,
> 
> John Youn  writes:
>>> Interesting.  You're getting a new parameter that's never been needed
>>> in the code before and (as far as I can tell) isn't used anywhere in
>>> your series.  I presume this is in prep for a future patch that uses
>>> this?
>>>
>>> At the moment you're burning a decent delay to read this unused
>>> parameter (potentially up to 100ms), so hopefully there's a good use
>>> for it eventually...
>>
>> I'll remove this from this series. It will be used by the gadget but
>> those changes aren't ready to be submitted yet.
> 
> so you're sending this series again ? Seems like I should drop all
> patches from my testing/next ?
> 

Yes I'll resend. You can drop them from your testing/next.

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


[PATCH v2] usb: ehci: refactor scan_isoc function

2015-12-10 Thread Geyslan G. Bem
This patch removes an infinite for loop and makes use of the already
existing 'restart' tag, reducing one leading tab.

The comments and code were corrected conforming coding style.

Tested by compilation only.
Caught by checkpatch:
 WARNING: Too many leading tabs - consider code refactoring

Signed-off-by: Geyslan G. Bem 
---
v2: fixes coding style (removes spaces before parens and open brackets)
---
 drivers/usb/host/ehci-sched.c | 203 ++
 1 file changed, 104 insertions(+), 99 deletions(-)

diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index f9a3327..86b2484 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -2383,6 +2383,9 @@ static void scan_isoc(struct ehci_hcd *ehci)
unsignedfmask = ehci->periodic_size - 1;
boolmodified, live;
 
+   union ehci_shadow q, *q_p;
+   __hc32 type, *hw_p;
+
/*
 * When running, scan from last scan point up to "now"
 * else clean up by scanning everything that's left.
@@ -2399,119 +2402,121 @@ static void scan_isoc(struct ehci_hcd *ehci)
ehci->now_frame = now_frame;
 
frame = ehci->last_iso_frame;
-   for (;;) {
-   union ehci_shadow   q, *q_p;
-   __hc32  type, *hw_p;
 
 restart:
-   /* scan each element in frame's queue for completions */
-   q_p = >pshadow [frame];
-   hw_p = >periodic [frame];
-   q.ptr = q_p->ptr;
-   type = Q_NEXT_TYPE(ehci, *hw_p);
-   modified = false;
-
-   while (q.ptr != NULL) {
-   switch (hc32_to_cpu(ehci, type)) {
-   case Q_TYPE_ITD:
-   /* If this ITD is still active, leave it for
-* later processing ... check the next entry.
-* No need to check for activity unless the
-* frame is current.
-*/
-   if (frame == now_frame && live) {
-   rmb();
-   for (uf = 0; uf < 8; uf++) {
-   if (q.itd->hw_transaction[uf] &
-   ITD_ACTIVE(ehci))
-   break;
-   }
-   if (uf < 8) {
-   q_p = >itd_next;
-   hw_p = >hw_next;
-   type = Q_NEXT_TYPE(ehci,
-   q.itd->hw_next);
-   q = *q_p;
+   /* Scan each element in frame's queue for completions */
+   q_p = >pshadow[frame];
+   hw_p = >periodic[frame];
+   q.ptr = q_p->ptr;
+   type = Q_NEXT_TYPE(ehci, *hw_p);
+   modified = false;
+
+   while (q.ptr != NULL) {
+   switch (hc32_to_cpu(ehci, type)) {
+   case Q_TYPE_ITD:
+   /*
+* If this ITD is still active, leave it for
+* later processing ... check the next entry.
+* No need to check for activity unless the
+* frame is current.
+*/
+   if (frame == now_frame && live) {
+   rmb();
+   for (uf = 0; uf < 8; uf++) {
+   if (q.itd->hw_transaction[uf] &
+   ITD_ACTIVE(ehci))
break;
-   }
}
-
-   /* Take finished ITDs out of the schedule
-* and process them:  recycle, maybe report
-* URB completion.  HC won't cache the
-* pointer for much longer, if at all.
-*/
-   *q_p = q.itd->itd_next;
-   if (!ehci->use_dummy_qh ||
-   q.itd->hw_next != EHCI_LIST_END(ehci))
-   *hw_p = q.itd->hw_next;
-   else
-   *hw_p = cpu_to_hc32(ehci,
-   ehci->dummy->qh_dma);
-   type = Q_NEXT_TYPE(ehci, q.itd->hw_next);
-   wmb();
-   modified = itd_complete (ehci, q.itd);
-   

Re: [PATCH v2 1/2] usb: renesas_usbhs: add fallback compatibility strings

2015-12-10 Thread Simon Horman
On Thu, Dec 10, 2015 at 07:28:06AM +, Kuninori Morimoto wrote:
> 
> Hi Simon
> 
> Thank you for your patch
> 
> > Add fallback compatibility strings for R-Car Gen2 and Gen3.
> > This is in keeping with the fallback scheme being adopted wherever
> > appropriate for drivers for Renesas SoCs.
> > 
> > Also add SoC names.
> > 
> > Signed-off-by: Simon Horman 
> > ---
> (snip)
> >  Required properties:
> >- compatible: Must contain one of the following:
> > -   - "renesas,usbhs-r8a7790"
> > -   - "renesas,usbhs-r8a7791"
> > -   - "renesas,usbhs-r8a7794"
> > -   - "renesas,usbhs-r8a7795"
> > +
> > +   - "renesas,usbhs-r8a7790" for r8a7790 (R-Car H2) compatible device
> > +   - "renesas,usbhs-r8a7791" for r8a7791 (R-Car M2-W) compatible device
> > +   - "renesas,usbhs-r8a7794" for r8a7794 (R-Car E2) compatible device
> > +   - "renesas,usbhs-r8a7795" for r8a7795 (R-Car H3) compatible device
> > +   - "renesas,rcar-gen2-usbhs" for R-Car Gen2 compatibile device
> > +   - "renesas,rcar-gen3-usbhs" for R-Car Gen3 compatibile device
> > +
> > +   When compatible with the generic version, nodes must list the
> > +   SoC-specific version corresponding to the platform first followed
> > +   by the generic version.
> 
> I think these can be separated ?
> 
>  1. document update for "renesas,usbhs-r8a77xx"
>  2. add new "rcar-genX" (this patch)

Sure, will do.

> >  Example:
> > usbhs: usb@e659 {
> > -   compatible = "renesas,usbhs-r8a7790";
> > +   compatible = "renesas,usbhs-r8a7790", "renesas,rcar-usbhs";
> 
> I think you want
> 
>  -compatible = "renesas,usbhs-r8a7790", "renesas,rcar-usbhs";
>  +compatible = "renesas,usbhs-r8a7790", "renesas,rcar-gen2-usbhs";

Thanks, I will fix 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


[PATCH v3 2/2] usb: xhci: add Broadcom specific fake doorbell

2015-12-10 Thread Hauke Mehrtens
From: Rafał Miłecki 

This fixes a problem with the XHCI controller found in the Broadcom
Northstar SoCs. These controllers see the devices connected via USB
only in a small percentage of cold boots.
This quirk is also added to the platform data so we can activate it
when we register our platform driver.

Currently it is unknown to me what exactly is wrong in the XHCI controller.

Signed-off-by: Rafał Miłecki 
Signed-off-by: Hauke Mehrtens 
---
 Documentation/devicetree/bindings/usb/usb-xhci.txt |  2 +
 drivers/usb/host/xhci-plat.c   |  4 ++
 drivers/usb/host/xhci.c| 59 --
 drivers/usb/host/xhci.h|  1 +
 include/linux/usb/xhci_pdriver.h   |  3 ++
 5 files changed, 66 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
b/Documentation/devicetree/bindings/usb/usb-xhci.txt
index 0825732..c014eca 100644
--- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
+++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
@@ -12,6 +12,8 @@ Required properties:
 Optional properties:
   - clocks: reference to a clock
   - usb3-lpm-capable: determines if platform is USB3 LPM capable
+  - usb3-fake-doorbell: determines is the controller needs a fake doorbell
+to detect the device
 
 Example:
usb@f0931000 {
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 4fb295b..119ae3e 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -53,6 +53,10 @@ static void xhci_plat_quirks(struct device *dev, struct 
xhci_hcd *xhci)
if ((node && of_property_read_bool(node, "usb3-lpm-capable")) ||
(pdata && pdata->usb3_lpm_capable))
xhci->quirks |= XHCI_LPM_SUPPORT;
+
+   if ((node && of_property_read_bool(node, "usb3-fake-doorbell")) ||
+   (pdata && pdata->usb3_fake_doorbell))
+   xhci->quirks |= XHCI_FAKE_DOORBELL;
 }
 
 /* called during probe() after chip reset completes */
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 643d312..17166aa 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -122,6 +122,39 @@ int xhci_halt(struct xhci_hcd *xhci)
return ret;
 }
 
+static int xhci_fake_doorbell(struct xhci_hcd *xhci, int slot_id)
+{
+   u32 temp;
+
+   /* alloc a virt device for slot */
+   if (!xhci_alloc_virt_device(xhci, slot_id, NULL, GFP_NOIO)) {
+   xhci_warn(xhci, "Could not allocate xHCI USB device data 
structures\n");
+   return -ENOMEM;
+   }
+
+   /* ring fake doorbell for slot_id ep 0 */
+   xhci_ring_ep_doorbell(xhci, slot_id, 0, 0);
+   usleep_range(1000, 1500);
+
+   /* read the status register to check if HSE is set or not? */
+   temp = readl(>op_regs->status);
+
+   /* clear HSE if set */
+   if (temp & STS_FATAL) {
+   xhci_dbg(xhci, "HSE problem detected, status: 0x%x\n", temp);
+   temp &= ~0x1fff;
+   temp |= STS_FATAL;
+   writel(temp, >op_regs->status);
+   usleep_range(1000, 1500);
+   readl(>op_regs->status);
+   }
+
+   /* Free virt device */
+   xhci_free_virt_device(xhci, slot_id);
+
+   return 0;
+}
+
 /*
  * Set the run bit and wait for the host to be running.
  */
@@ -568,10 +601,26 @@ int xhci_init(struct usb_hcd *hcd)
 
 static int xhci_run_finished(struct xhci_hcd *xhci)
 {
-   if (xhci_start(xhci)) {
-   xhci_halt(xhci);
-   return -ENODEV;
+   int err;
+
+   err = xhci_start(xhci);
+   if (err) {
+   err = -ENODEV;
+   goto out_err;
}
+
+   if (xhci->quirks & XHCI_FAKE_DOORBELL) {
+   err = xhci_fake_doorbell(xhci, 1);
+   if (err)
+   goto out_err;
+
+   err = xhci_start(xhci);
+   if (err) {
+   err = -ENODEV;
+   goto out_err;
+   }
+   }
+
xhci->shared_hcd->state = HC_STATE_RUNNING;
xhci->cmd_ring_state = CMD_RING_STATE_RUNNING;
 
@@ -581,6 +630,10 @@ static int xhci_run_finished(struct xhci_hcd *xhci)
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
"Finished xhci_run for USB3 roothub");
return 0;
+
+out_err:
+   xhci_halt(xhci);
+   return err;
 }
 
 /*
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 9be7348..8c1faf4 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1631,6 +1631,7 @@ struct xhci_hcd {
 #define XHCI_BROKEN_STREAMS(1 << 19)
 #define XHCI_PME_STUCK_QUIRK   (1 << 20)
 #define XHCI_MTK_HOST  (1 << 21)
+#define XHCI_FAKE_DOORBELL (1 << 22)
unsigned intnum_active_eps;
unsigned int

Re: [PATCH 15/18] usb: dwc2: Improve handling of host and device hwparams

2015-12-10 Thread Felipe Balbi

Hi,

John Youn  writes:
>> Interesting.  You're getting a new parameter that's never been needed
>> in the code before and (as far as I can tell) isn't used anywhere in
>> your series.  I presume this is in prep for a future patch that uses
>> this?
>> 
>> At the moment you're burning a decent delay to read this unused
>> parameter (potentially up to 100ms), so hopefully there's a good use
>> for it eventually...
>
> I'll remove this from this series. It will be used by the gadget but
> those changes aren't ready to be submitted yet.

so you're sending this series again ? Seems like I should drop all
patches from my testing/next ?

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH] usb: remove redundant conditions

2015-12-10 Thread Johan Hovold
On Wed, Dec 09, 2015 at 10:52:42PM -0300, Geyslan G. Bem wrote:
> This patch removes redundant conditions.
> 
>  - (!A || (A && B)) is the same as (!A || B).
>  - (length && length > 5) can be reduced to a single evaluation.
> 
> Caught by: cppcheck
> 
> Signed-off-by: Geyslan G. Bem 
> ---
>  drivers/usb/gadget/udc/s3c-hsudc.c |  2 +-
>  drivers/usb/host/fhci-sched.c  |  2 +-
>  drivers/usb/musb/musb_gadget.c |  5 ++---
>  drivers/usb/serial/io_edgeport.c   | 35 ++-
>  drivers/usb/serial/mos7840.c   |  2 +-
>  5 files changed, 19 insertions(+), 27 deletions(-)

Please split out (at least) the usb-serial changes into two patches.

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


[PATCHv2] usb: gadget: f_tcm: ignore return value of queue_work

2015-12-10 Thread Andrzej Pietrasiewicz
queue_work() has never returned anything less than zero.

Signed-off-by: Andrzej Pietrasiewicz 
---

This patch depends on the series adding configfs support to tcm usb gadget:
http://www.spinics.net/lists/target-devel/msg11215.html

v1..v2: removed unused "ret" variable

 drivers/usb/gadget/function/f_tcm.c | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/gadget/function/f_tcm.c 
b/drivers/usb/gadget/function/f_tcm.c
index 9cb4a6b..c856850 100644
--- a/drivers/usb/gadget/function/f_tcm.c
+++ b/drivers/usb/gadget/function/f_tcm.c
@@ -1091,7 +1091,6 @@ static int usbg_submit_command(struct f_uas *fu,
struct se_cmd *se_cmd;
struct tcm_usbg_nexus *tv_nexus;
u32 cmd_len;
-   int ret;
 
if (cmd_iu->iu_id != IU_ID_COMMAND) {
pr_err("Unsupported type %d\n", cmd_iu->iu_id);
@@ -1156,9 +1155,7 @@ static int usbg_submit_command(struct f_uas *fu,
cmd->unpacked_lun = scsilun_to_int(_iu->lun);
 
INIT_WORK(>work, usbg_cmd_work);
-   ret = queue_work(tpg->workqueue, >work);
-   if (ret < 0)
-   goto err;
+   queue_work(tpg->workqueue, >work);
 
return 0;
 err:
@@ -1208,7 +1205,6 @@ static int bot_submit_command(struct f_uas *fu,
struct se_cmd *se_cmd;
struct tcm_usbg_nexus *tv_nexus;
u32 cmd_len;
-   int ret;
 
if (cbw->Signature != cpu_to_le32(US_BULK_CB_SIGN)) {
pr_err("Wrong signature on CBW\n");
@@ -1253,9 +1249,7 @@ static int bot_submit_command(struct f_uas *fu,
cmd->se_cmd.tag = le32_to_cpu(cmd->bot_tag);
 
INIT_WORK(>work, bot_cmd_work);
-   ret = queue_work(tpg->workqueue, >work);
-   if (ret < 0)
-   goto err;
+   queue_work(tpg->workqueue, >work);
 
return 0;
 err:
-- 
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 7/9v2] usb: host: ehci.h: remove macros trailing semicolon

2015-12-10 Thread Peter Senna Tschudin
On Wed, Dec 09, 2015 at 07:32:36PM -0300, Geyslan G. Bem wrote:
> Removes trailing semicolon from macros.
> 
> Caught by checkpatch:
> "WARNING: macros should not use a trailing semicolon"
> 
> Signed-off-by: Geyslan G. Bem 
As with previous, missing the changelog, but other than that the patch
looks good to me.

Acked-by: Peter Senna Tschudin 
> ---
>  drivers/usb/host/ehci.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
> index ea56147..15de5bf 100644
> --- a/drivers/usb/host/ehci.h
> +++ b/drivers/usb/host/ehci.h
> @@ -635,10 +635,10 @@ struct ehci_tt {
>  /* Prepare the PORTSC wakeup flags during controller suspend/resume */
>  
>  #define ehci_prepare_ports_for_controller_suspend(ehci, do_wakeup)   \
> - ehci_adjust_port_wakeup_flags(ehci, true, do_wakeup);
> + ehci_adjust_port_wakeup_flags(ehci, true, do_wakeup)
>  
>  #define ehci_prepare_ports_for_controller_resume(ehci)   
> \
> - ehci_adjust_port_wakeup_flags(ehci, false, false);
> + ehci_adjust_port_wakeup_flags(ehci, false, false)
>  
>  /*-*/
>  
> -- 
> 2.6.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 9/9] usb: host: ehci.h: move constant to right

2015-12-10 Thread Peter Senna Tschudin
On Wed, Dec 09, 2015 at 07:15:37PM -0300, Geyslan G. Bem wrote:
> This patch moves the constant 0x3ff to right and put spaces
> in the right shift.
> 
> Caught by coccinelle:
> scripts/coccinelle/misc/compare_const_fl.cocci
> 
> Signed-off-by: Geyslan G. Bem 
Acked-by: Peter Senna Tschudin 
> ---
>  drivers/usb/host/ehci.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
> index 81e609a..de94555 100644
> --- a/drivers/usb/host/ehci.h
> +++ b/drivers/usb/host/ehci.h
> @@ -555,7 +555,7 @@ struct ehci_sitd {
>   __hc32  hw_results; /* EHCI table 3-11 */
>  #define  SITD_IOC(1 << 31)   /* interrupt on completion */
>  #define  SITD_PAGE   (1 << 30)   /* buffer 0/1 */
> -#define  SITD_LENGTH(x)  (0x3ff & ((x)>>16))
> +#define  SITD_LENGTH(x)  (((x) >> 16) & 0x3ff)
>  #define  SITD_STS_ACTIVE (1 << 7)/* HC may execute this */
>  #define  SITD_STS_ERR(1 << 6)/* error from TT */
>  #define  SITD_STS_DBE(1 << 5)/* data buffer error (in HC) */
> -- 
> 2.6.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 1/2] usb: renesas_usbhs: add fallback compatibility strings

2015-12-10 Thread Sergei Shtylyov

Hello.

On 12/10/2015 8:40 AM, Simon Horman wrote:


Add fallback compatibility strings for R-Car Gen2 and Gen3.
This is in keeping with the fallback scheme being adopted wherever
appropriate for drivers for Renesas SoCs.

Also add SoC names.

Signed-off-by: Simon Horman 
---
v2
* Add R-Car Gen2 and Gen3 fallback compatibility strings rather than
   a single compatibility string for all of R-Car.
---
  .../devicetree/bindings/usb/renesas_usbhs.txt  | 18 +-
  drivers/usb/renesas_usbhs/common.c |  9 +
  2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/renesas_usbhs.txt 
b/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
index 7d48f63db44e..b959059826cd 100644
--- a/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
+++ b/Documentation/devicetree/bindings/usb/renesas_usbhs.txt

[...]

@@ -22,7 +30,7 @@ Optional properties:

  Example:
usbhs: usb@e659 {
-   compatible = "renesas,usbhs-r8a7790";
+   compatible = "renesas,usbhs-r8a7790", "renesas,rcar-usbhs";


   You forgot "gen2-" here.

[...]

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


Re: [PATCH 6/9v2] usb: host: ehci.h: use space after comma

2015-12-10 Thread Peter Senna Tschudin
On Wed, Dec 09, 2015 at 07:32:35PM -0300, Geyslan G. Bem wrote:
> Put space after comma.
> 
> This patch also changes QH_NEXT macro for better reading.
> 
> Caught by checkpatch: "ERROR: space required after that ','"
> 
> Signed-off-by: Geyslan G. Bem 
> ---
>  drivers/usb/host/ehci.h | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
> index 7b2b213..ea56147 100644
> --- a/drivers/usb/host/ehci.h
> +++ b/drivers/usb/host/ehci.h
> @@ -334,7 +334,7 @@ struct ehci_qtd {
>  /*-*/
>  
>  /* type tag from {qh,itd,sitd,fstn}->hw_next */
> -#define Q_NEXT_TYPE(ehci,dma)((dma) & cpu_to_hc32(ehci, 3 << 1))
> +#define Q_NEXT_TYPE(ehci, dma)   ((dma) & cpu_to_hc32(ehci, 3 << 1))
>  
>  /*
>   * Now the following defines are not converted using the
> @@ -350,7 +350,8 @@ struct ehci_qtd {
>  #define Q_TYPE_FSTN  (3 << 1)
>  
>  /* next async queue entry, or pointer to interrupt/periodic QH */
> -#define QH_NEXT(ehci,dma)(cpu_to_hc32(ehci, 
> (((u32)dma)&~0x01f)|Q_TYPE_QH))
> +#define QH_NEXT(ehci, dma) \
> + (cpu_to_hc32(ehci, (((u32) dma) & ~0x01f) | Q_TYPE_QH))

For the maintainers: Is having two lines here better than having a line with 83 
chars?

>  
>  /* for periodic/async schedules and qtd lists, mark end of list */
>  #define EHCI_LIST_END(ehci)  cpu_to_hc32(ehci, 1) /* "null pointer" to hw */
> -- 
> 2.6.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 5/9v2] usb: host: ehci.h: remove direct use of __attribute__ keyword

2015-12-10 Thread Geyslan G. Bem
2015-12-10 7:01 GMT-03:00 Peter Senna Tschudin :
> On Wed, Dec 09, 2015 at 07:32:34PM -0300, Geyslan G. Bem wrote:
>> Prefer to use __aligned(size) macro instead of
>> __attribute__((aligned(size))).
>>
>> Caught by checkpatch: "WARNING"
> Not sure about the WARNING here, maybe just remove this line?
Or just to be changed to "Caught by checkpatch."

>
>>
>> Signed-off-by: Geyslan G. Bem 
> As with previous, missing the changelog, but other than that the patch
> looks good to me.
>
> Acked-by: Peter Senna Tschudin 
>> ---
>>  drivers/usb/host/ehci.h | 10 +-
>>  1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
>> index 945000a..7b2b213 100644
>> --- a/drivers/usb/host/ehci.h
>> +++ b/drivers/usb/host/ehci.h
>> @@ -324,7 +324,7 @@ struct ehci_qtd {
>>   struct list_headqtd_list;   /* sw qtd list */
>>   struct urb  *urb;   /* qtd's urb */
>>   size_t  length; /* length of buffer */
>> -} __attribute__ ((aligned (32)));
>> +} __aligned(32);
>>
>>  /* mask NakCnt+T in qh->hw_alt_next */
>>  #define QTD_MASK(ehci)   cpu_to_hc32(ehci, ~0x1f)
>> @@ -407,7 +407,7 @@ struct ehci_qh_hw {
>>   __hc32  hw_token;
>>   __hc32  hw_buf[5];
>>   __hc32  hw_buf_hi[5];
>> -} __attribute__ ((aligned(32)));
>> +} __aligned(32);
>>
>>  struct ehci_qh {
>>   struct ehci_qh_hw   *hw;/* Must come first */
>> @@ -535,7 +535,7 @@ struct ehci_itd {
>>   unsignedframe;  /* where scheduled */
>>   unsignedpg;
>>   unsignedindex[8];   /* in urb->iso_frame_desc */
>> -} __attribute__ ((aligned (32)));
>> +} __aligned(32);
>>
>>  
>> /*-*/
>>
>> @@ -578,7 +578,7 @@ struct ehci_sitd {
>>   struct list_headsitd_list;  /* list of stream's sitds */
>>   unsignedframe;
>>   unsignedindex;
>> -} __attribute__ ((aligned (32)));
>> +} __aligned(32);
>>
>>  
>> /*-*/
>>
>> @@ -598,7 +598,7 @@ struct ehci_fstn {
>>   /* the rest is HCD-private */
>>   dma_addr_t  fstn_dma;
>>   union ehci_shadow   fstn_next;  /* ptr to periodic q entry */
>> -} __attribute__ ((aligned (32)));
>> +} __aligned(32);
>>
>>  
>> /*-*/
>>
>> --
>> 2.6.3
>>



-- 
Regards,

Geyslan G. Bem
hackingbits.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


Re: [PATCH 4/9v2] usb: host: ehci.h: fix single statement macros

2015-12-10 Thread Sergei Shtylyov

Hello.

On 12/10/2015 1:32 AM, Geyslan G. Bem wrote:


Don't use the 'do {} while (0)' wrapper in a single statement macro.

Caught by checkpatch: "WARNING: Single statement macros should not
use a do {} while (0) loop"

Signed-off-by: Geyslan G. Bem 
---
  drivers/usb/host/ehci.h | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index cfeebd8..945000a 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -244,9 +244,9 @@ struct ehci_hcd {   /* one per controller */
/* irq statistics */
  #ifdef EHCI_STATS
struct ehci_stats   stats;
-#  define COUNT(x) do { (x)++; } while (0)
+#  define COUNT(x) ((x)++)
  #else
-#  define COUNT(x) do {} while (0)
+#  define COUNT(x) ((void) 0)


   Why not just empty #define?

[...]

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


Re: [PATCH 8/9v2] usb: host: ehci.h: move pointer operator to name side

2015-12-10 Thread Peter Senna Tschudin
On Wed, Dec 09, 2015 at 07:32:37PM -0300, Geyslan G. Bem wrote:
> The pointer operator must be sticked to name.
> 
> Caught by checkpatch:
> ERROR: "foo * bar" should be "foo *bar"
> 
> Signed-off-by: Geyslan G. Bem 
As with previous, missing the changelog, but other than that the patch
looks good to me.

Acked-by: Peter Senna Tschudin 
> ---
>  drivers/usb/host/ehci.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
> index 15de5bf..81e609a 100644
> --- a/drivers/usb/host/ehci.h
> +++ b/drivers/usb/host/ehci.h
> @@ -732,7 +732,7 @@ ehci_port_speed(struct ehci_hcd *ehci, unsigned int 
> portsc)
>  #endif
>  
>  static inline unsigned int ehci_readl(const struct ehci_hcd *ehci,
> - __u32 __iomem * regs)
> + __u32 __iomem *regs)
>  {
>  #ifdef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO
>   return ehci_big_endian_mmio(ehci) ?
> -- 
> 2.6.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] usb: remove redundant conditions

2015-12-10 Thread Geyslan G. Bem
2015-12-10 7:44 GMT-03:00 Johan Hovold :
> On Wed, Dec 09, 2015 at 10:52:42PM -0300, Geyslan G. Bem wrote:
>> This patch removes redundant conditions.
>>
>>  - (!A || (A && B)) is the same as (!A || B).
>>  - (length && length > 5) can be reduced to a single evaluation.
>>
>> Caught by: cppcheck
>>
>> Signed-off-by: Geyslan G. Bem 
>> ---
>>  drivers/usb/gadget/udc/s3c-hsudc.c |  2 +-
>>  drivers/usb/host/fhci-sched.c  |  2 +-
>>  drivers/usb/musb/musb_gadget.c |  5 ++---
>>  drivers/usb/serial/io_edgeport.c   | 35 ++-
>>  drivers/usb/serial/mos7840.c   |  2 +-
>>  5 files changed, 19 insertions(+), 27 deletions(-)
>
> Please split out (at least) the usb-serial changes into two patches.
Ok, I'll send v2 later.

>
> Johan



-- 
Regards,

Geyslan G. Bem
hackingbits.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


Re: [PATCH 4/9v2] usb: host: ehci.h: fix single statement macros

2015-12-10 Thread Geyslan G. Bem
2015-12-10 8:54 GMT-03:00 Sergei Shtylyov :
> Hello.
>
> On 12/10/2015 1:32 AM, Geyslan G. Bem wrote:
>
>> Don't use the 'do {} while (0)' wrapper in a single statement macro.
>>
>> Caught by checkpatch: "WARNING: Single statement macros should not
>> use a do {} while (0) loop"
>>
>> Signed-off-by: Geyslan G. Bem 
>> ---
>>   drivers/usb/host/ehci.h | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
>> index cfeebd8..945000a 100644
>> --- a/drivers/usb/host/ehci.h
>> +++ b/drivers/usb/host/ehci.h
>> @@ -244,9 +244,9 @@ struct ehci_hcd {   /* one per
>> controller */
>> /* irq statistics */
>>   #ifdef EHCI_STATS
>> struct ehci_stats   stats;
>> -#  define COUNT(x) do { (x)++; } while (0)
>> +#  define COUNT(x) ((x)++)
>>   #else
>> -#  define COUNT(x) do {} while (0)
>> +#  define COUNT(x) ((void) 0)
>
>
>Why not just empty #define?

Indeed. I'll change it.
Tks Sergei.


>
> [...]
>
> MBR, Sergei
>



-- 
Regards,

Geyslan G. Bem
hackingbits.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


Re: [PATCHv2] usb: gadget: f_tcm: ignore return value of queue_work

2015-12-10 Thread Andrzej Pietrasiewicz

Hi

W dniu 10.12.2015 o 17:51, Felipe Balbi pisze:


Hi,

Andrzej Pietrasiewicz  writes:

queue_work() has never returned anything less than zero.

Signed-off-by: Andrzej Pietrasiewicz 


I don't have f_tcm.c anywhere. Where did you base this commit ?


The comment after the scissors line states that:

"This patch depends on the series adding configfs support to tcm usb gadget:
http://www.spinics.net/lists/target-devel/msg11215.html;

AP


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


Re: [PATCH 2/2] usb: dwc2: forbid queuing request to a disabled ep

2015-12-10 Thread Felipe Balbi

Hi,

changbin...@intel.com writes:
> From: "Du, Changbin" 
>
> Queue a request to disabled ep  doesn't make sense, and induce caller
> make mistakes.
>
> Here is a example for the android mtp gadget function driver. A mem
> corruption can happen on below senario.
> 1) On disconnect, mtp driver disable its EPs,
> 2) During send_file_work and receive_file_work, mtp queues a request
>to ep. (The mtp driver need improve its synchronization logic!)
> 3) mtp_function_unbind is invoked and all mtp requests are freed.
> 4) when dwc2 process the request queued on step 2, will cause kernel
>NULL pointer dereference exception.
>
> Signed-off-by: Du, Changbin 
> ---
>  drivers/usb/dwc2/gadget.c | 6 ++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
> index 586bbcd..4d637ab 100644
> --- a/drivers/usb/dwc2/gadget.c
> +++ b/drivers/usb/dwc2/gadget.c
> @@ -786,6 +786,12 @@ static int dwc2_hsotg_ep_queue(struct usb_ep *ep, struct 
> usb_request *req,
>   ep->name, req, req->length, req->buf, req->no_interrupt,
>   req->zero, req->short_not_ok);
>  
> + if (!hs_ep->enabled) {
> + dev_warn(hs->dev, "%s: cannot queue to disabled ep\n",
> + __func__);

similar comment to previous patch:

if (dev_WARN_ONCE(hs->dev, !hs_ep->enabled,
"cannot queue to disabled ep %s\n", hs_ep->name))

> + return -ESHUTDOWN;
> + }
> +
>   /* Prevent new request submission when controller is suspended */
>   if (hs->lx_state == DWC2_L2) {
>   dev_dbg(hs->dev, "%s: don't submit request while suspended\n",
> -- 
> 2.5.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH] usb: gadget: forbid queuing request to a disabled ep

2015-12-10 Thread Felipe Balbi

Hi,

changbin...@intel.com writes:
> From: "Du, Changbin" 
>
> Queue a request to disabled ep  doesn't make sense, and induce caller
> make mistakes.
>
> Here is a example for the android mtp gadget function driver. A mem
> corruption can happen on below senario.
> 1) On disconnect, mtp driver disable its EPs,
> 2) During send_file_work and receive_file_work, mtp queues a request
>to ep. (The mtp driver need improve its synchronization logic!)
> 3) mtp_function_unbind is invoked and all mtp requests are freed.
> 4) when udc process the request queued on step 2, will cause kernel
>NULL pointer dereference exception.
>
> Signed-off-by: Du, Changbin 
> ---
> This patch is seprated from below patches because gadget layer has
> added the 'enabled' flag in v4.4. so abandon it and submit new one.
> [PATCH 0/2] Two fix for dwc2 gadget driver
>   usb: dwc2: add ep enabled flag to avoid double enable/disable
>   usb: dwc2: forbid queuing request to a disabled ep
>
> ---
>  include/linux/usb/gadget.h | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
> index 3d583a1..d813bd2 100644
> --- a/include/linux/usb/gadget.h
> +++ b/include/linux/usb/gadget.h
> @@ -402,6 +402,9 @@ static inline void usb_ep_free_request(struct usb_ep *ep,
>  static inline int usb_ep_queue(struct usb_ep *ep,
>  struct usb_request *req, gfp_t gfp_flags)
>  {
> + if (!ep->enabled)
> + return -ESHUTDOWN;

same warn here:

if (WARN_ON_ONCE(!ep->enabled))
return -ESHUTDOWN;

> +
>   return ep->ops->queue(ep, req, gfp_flags);
>  }
>  
> -- 
> 2.5.0
>

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH 4/9v2] usb: host: ehci.h: fix single statement macros

2015-12-10 Thread Geyslan G. Bem
2015-12-10 14:26 GMT-03:00 Sergei Shtylyov :
> On 12/10/2015 05:56 PM, Geyslan G. Bem wrote:
>
>>> Don't use the 'do {} while (0)' wrapper in a single statement macro.
>>>
>>> Caught by checkpatch: "WARNING: Single statement macros should not
>>> use a do {} while (0) loop"
>>>
>>> Signed-off-by: Geyslan G. Bem 
>>> ---
>>> drivers/usb/host/ehci.h | 4 ++--
>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
>>> index cfeebd8..945000a 100644
>>> --- a/drivers/usb/host/ehci.h
>>> +++ b/drivers/usb/host/ehci.h
>>> @@ -244,9 +244,9 @@ struct ehci_hcd {   /* one per
>>> controller */
>>>   /* irq statistics */
>>> #ifdef EHCI_STATS
>>>   struct ehci_stats   stats;
>>> -#  define COUNT(x) do { (x)++; } while (0)
>>> +#  define COUNT(x) ((x)++)
>>> #else
>>> -#  define COUNT(x) do {} while (0)
>>> +#  define COUNT(x) ((void) 0)
>>
>>
>>
>>
>>  Why not just empty #define?
>
>
>
> Indeed. I'll change it.
> Tks Sergei.



 Since COUNT is not used to return the empty #define is ok. Another way
 is to use #define COUNT(x) (0) to get a 0 when necessary to read
 returns.
>
>
>>> Just 0, no parens please.
>
>
>> Ok, no parens, since there's no evaluation.
>
>
>It's because the literals don't need parens at all.
>
>> Then my change is:
>>
>> -#  define COUNT(x) do { (x)++; } while (0)
>> +#  define COUNT(x) (++(x))
>>   #else
>> -#  define COUNT(x) do {} while (0)
>> +#  define COUNT(x) 0
>>
>> Pre-increment allowing to return the updated x.
>
>
>Why if there was a post-increment before?
There's nothing wrong with post-increment. The pre one would be
necessary if using return.

>
>Anyway, this talk is quite pointless since the macro didn't return any
> value anyway.
You're sure, there's no use anywhere of the return of that macro indeed.

Sending v2 soon.

>
> MBR, Sergei
>



-- 
Regards,

Geyslan G. Bem
hackingbits.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


Re: [PATCH 2/2] usb: host: ehci-msm: Use posted data writes on AHB

2015-12-10 Thread Timur Tabi
On Fri, Nov 6, 2015 at 12:04 AM, Andy Gross  wrote:
> This patch sets the AHBMODE to allow for posted data writes.  This
> results in higher performance.
>
> Signed-off-by: Andy Gross 

I know it's a little late, but ...

Acked-by: Timur Tabi 

-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v7 0/4] usb/gadget: independent registration of gadgets and gadget drivers

2015-12-10 Thread Felipe Balbi

Hi,

Felipe Balbi  writes:
> Marek Szyprowski  writes:
>> Hello,
>>
>> This is a resurrection of the patches initially submitted by Ruslan
>> Bilovol in the following thread: https://lkml.org/lkml/2015/6/22/554
>>
>> The changes since the original submission (v5) includes rebase onto
>> latest linux-next branch, simplification of the code requested by Alan
>> Stern and Felipe Balbi, removal of a patch, which deleted __init/__exit
>> attributes (this change has been already merged) and fixes of the
>> checkpatch issues.
>>
>> This feature is urgently needed, because it is not longer possible to
>> use workaround to avoid deferred probe in UDC drivers due to
>> not-yet-probed i2c regulator drivers (for more information see
>> https://lkml.org/lkml/2015/10/30/374 ).
>>
>> This patchset has been successfully tested on Odroid XU3 boards with
>> DWC3 UDC driver being deferred by missing regulator drivers.
>
> there is one problem with this patchset. If I try to statically link
> gadget drivers, only one can be chosen, even though I can enable both
> dwc3 and dummy_hcd just fine. And, actually, this brings another
> problem. How do we handle systems which have 2 USB peripheral
> controllers (say, 2 instances of dwc3) and choose which gadget driver
> will bind to which controller ?

We also seem to have issues with Kconfig. If I try to make gadget driver
built-in, when compiling I'll get asked again if I want gadget drivers
built-in.

Another one: I just tried dummy_hcd built-in, g_zero built-in, dwc3 as a
module. I can never load anything to dwc3 ;-)

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH 4/9v2] usb: host: ehci.h: fix single statement macros

2015-12-10 Thread Sergei Shtylyov

On 12/10/2015 08:40 PM, Geyslan G. Bem wrote:


Don't use the 'do {} while (0)' wrapper in a single statement macro.

Caught by checkpatch: "WARNING: Single statement macros should not
use a do {} while (0) loop"

Signed-off-by: Geyslan G. Bem 
---
 drivers/usb/host/ehci.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index cfeebd8..945000a 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -244,9 +244,9 @@ struct ehci_hcd {   /* one per
controller */
   /* irq statistics */
 #ifdef EHCI_STATS
   struct ehci_stats   stats;
-#  define COUNT(x) do { (x)++; } while (0)
+#  define COUNT(x) ((x)++)
 #else
-#  define COUNT(x) do {} while (0)
+#  define COUNT(x) ((void) 0)


  Why not just empty #define?


Indeed. I'll change it.
Tks Sergei.


Since COUNT is not used to return the empty #define is ok. Another way
is to use #define COUNT(x) (0) to get a 0 when necessary to read
returns.



 Just 0, no parens please.



Ok, no parens, since there's no evaluation.


It's because the literals don't need parens at all.


Then my change is:

-#  define COUNT(x) do { (x)++; } while (0)
+#  define COUNT(x) (++(x))
   #else
-#  define COUNT(x) do {} while (0)
+#  define COUNT(x) 0

Pre-increment allowing to return the updated x.



Why if there was a post-increment before?



There's nothing wrong with post-increment. The pre one would be
necessary if using return.


   Maybe it was intended to return the old value? :-)



Anyway, this talk is quite pointless since the macro didn't return any
value anyway.

You're sure, there's no use anywhere of the return of that macro indeed.


   *do* {} *while* (0) just couldn't return any value, it's not just a 
compound statement which gcc indeed allows to be evaluated.



Sending v2 soon.


MBR, 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 v3 4/9] usb: host: ehci.h: fix single statement macros

2015-12-10 Thread Geyslan G. Bem
Don't use the 'do {} while (0)' wrapper in a single statement macro.

Caught by checkpatch: "WARNING: Single statement macros should not
use a do {} while (0) loop"

Signed-off-by: Geyslan G. Bem 
---
Change in v3:
 - There's no need to evaluate COUNT(x) in #ifdef EHCI_STATS
   false branch. Thus an empty #define is the choice.
---
 drivers/usb/host/ehci.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index cfeebd8..c86194f 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -244,9 +244,9 @@ struct ehci_hcd {   /* one per controller */
/* irq statistics */
 #ifdef EHCI_STATS
struct ehci_stats   stats;
-#  define COUNT(x) do { (x)++; } while (0)
+#  define COUNT(x) ((x)++)
 #else
-#  define COUNT(x) do {} while (0)
+#  define COUNT(x)
 #endif
 
/* debug files */
-- 
2.6.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 4/9v2] usb: host: ehci.h: fix single statement macros

2015-12-10 Thread Geyslan G. Bem
2015-12-10 14:47 GMT-03:00 Sergei Shtylyov :
> On 12/10/2015 08:40 PM, Geyslan G. Bem wrote:
>
> Don't use the 'do {} while (0)' wrapper in a single statement
> macro.
>
> Caught by checkpatch: "WARNING: Single statement macros should not
> use a do {} while (0) loop"
>
> Signed-off-by: Geyslan G. Bem 
> ---
>  drivers/usb/host/ehci.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
> index cfeebd8..945000a 100644
> --- a/drivers/usb/host/ehci.h
> +++ b/drivers/usb/host/ehci.h
> @@ -244,9 +244,9 @@ struct ehci_hcd {   /* one per
> controller */
>/* irq statistics */
>  #ifdef EHCI_STATS
>struct ehci_stats   stats;
> -#  define COUNT(x) do { (x)++; } while (0)
> +#  define COUNT(x) ((x)++)
>  #else
> -#  define COUNT(x) do {} while (0)
> +#  define COUNT(x) ((void) 0)


   Why not just empty #define?
>>>
>>>
>>> Indeed. I'll change it.
>>> Tks Sergei.
>>
>>
>> Since COUNT is not used to return the empty #define is ok. Another way
>> is to use #define COUNT(x) (0) to get a 0 when necessary to read
>> returns.
>>>
>>>
>  Just 0, no parens please.
>>>
>>>
 Ok, no parens, since there's no evaluation.
>>>
>>>
>>> It's because the literals don't need parens at all.
>>>
 Then my change is:

 -#  define COUNT(x) do { (x)++; } while (0)
 +#  define COUNT(x) (++(x))
#else
 -#  define COUNT(x) do {} while (0)
 +#  define COUNT(x) 0

 Pre-increment allowing to return the updated x.
>>>
>>>
>>>
>>> Why if there was a post-increment before?
>
>
>> There's nothing wrong with post-increment. The pre one would be
>> necessary if using return.
>
>
>Maybe it was intended to return the old value? :-)
>
>>>
>>> Anyway, this talk is quite pointless since the macro didn't return
>>> any
>>> value anyway.
>>
>> You're sure, there's no use anywhere of the return of that macro indeed.
>
>
>*do* {} *while* (0) just couldn't return any value, it's not just a
> compound statement which gcc indeed allows to be evaluated.
Indeed. :-)

v2 in the oven.
>
>
>> Sending v2 soon.
>
>
> MBR, Sergei
>



-- 
Regards,

Geyslan G. Bem
hackingbits.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


Re: [PATCHv2] usb: gadget: f_tcm: ignore return value of queue_work

2015-12-10 Thread Felipe Balbi

Hi,

Andrzej Pietrasiewicz  writes:
>> Andrzej Pietrasiewicz  writes:
>>> queue_work() has never returned anything less than zero.
>>>
>>> Signed-off-by: Andrzej Pietrasiewicz 
>>
>> I don't have f_tcm.c anywhere. Where did you base this commit ?
>>
> The comment after the scissors line states that:
>
> "This patch depends on the series adding configfs support to tcm usb gadget:
> http://www.spinics.net/lists/target-devel/msg11215.html;

so you want me to apply patches which are known to be broken ? Care to
amend your change (and Dan's change) to original patches and resend ?

cheers

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH] usb: gadget: make usb_ep_enable return -EBUSY if ep has already enabled

2015-12-10 Thread Felipe Balbi

Hi,

changbin...@intel.com writes:
> From: "Du, Changbin" 
>
> When usb_ep_enable on a enabled ep, the configuration of the ep probably
> has changed. In this scenario, the ep configuration in hw should be
> reprogrammed by udc driver. Hence, it is better to return an error to
> inform the caller.
>
> Signed-off-by: Du, Changbin 
> ---
>  include/linux/usb/gadget.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
> index d813bd2..89f9fdd 100644
> --- a/include/linux/usb/gadget.h
> +++ b/include/linux/usb/gadget.h
> @@ -268,7 +268,7 @@ static inline int usb_ep_enable(struct usb_ep *ep)
>   int ret;
>  
>   if (ep->enabled)
> - return 0;
> + return -EBUSY;

While at that, can you add a WARN_ON() as well ?

if (WARN_ON(ep->enabled))
return -EBUSY;

-- 
balbi


signature.asc
Description: PGP signature


[PATCH v3 3/3] usb: renesas_usbhs: add device tree support for r8a779[23]

2015-12-10 Thread Simon Horman
Simply document new compatibility string.
As a previous patch adds a generic R-Car Gen2 compatibility string
there appears to be no need for a driver updates.

Signed-off-by: Simon Horman 
Acked-by: Rob Herring 
---
 Documentation/devicetree/bindings/usb/renesas_usbhs.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/renesas_usbhs.txt 
b/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
index c55cf77006d0..471a0649e63e 100644
--- a/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
+++ b/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
@@ -5,6 +5,8 @@ Required properties:
 
- "renesas,usbhs-r8a7790" for r8a7790 (R-Car H2) compatible device
- "renesas,usbhs-r8a7791" for r8a7791 (R-Car M2-W) compatible device
+   - "renesas,usbhs-r8a7792" for r8a7792 (R-Car V2H) compatible device
+   - "renesas,usbhs-r8a7793" for r8a7793 (R-Car M2-N) compatible device
- "renesas,usbhs-r8a7794" for r8a7794 (R-Car E2) compatible device
- "renesas,usbhs-r8a7795" for r8a7795 (R-Car H3) compatible device
- "renesas,rcar-gen2-usbhs" for R-Car Gen2 compatible device
-- 
2.1.4

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


[PATCH v3 0/3] usb: renesas_usbhs: More compat strings

2015-12-10 Thread Simon Horman
Hi,

this short series adds generic, and soc-specific r8a7792 and r8a7793 compat
strings to the Renesas USBHS driver. The intention is to provide a complete
set of compat strings for known R-Car SoCs.

Changes since v2:
* Split documentation of SoC names into separate patch
* Use correct fallback compatibility string in example

Changes since v1:
* Add R-Car Gen2 and Gen3 fallback compatibility strings rather than
  a single compatibility string for all of R-Car.

Simon Horman (3):
  usb: renesas_usbhs: add SoC names to compatibility string
documentation
  usb: renesas_usbhs: add fallback compatibility strings
  usb: renesas_usbhs: add device tree support for r8a779[23]

 .../devicetree/bindings/usb/renesas_usbhs.txt| 20 +++-
 drivers/usb/renesas_usbhs/common.c   |  9 +
 2 files changed, 24 insertions(+), 5 deletions(-)

-- 
2.1.4

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


[PATCH v3 2/3] usb: renesas_usbhs: add fallback compatibility strings

2015-12-10 Thread Simon Horman
Add fallback compatibility strings for R-Car Gen2 and Gen3.
This is in keeping with the fallback scheme being adopted wherever
appropriate for drivers for Renesas SoCs.

Signed-off-by: Simon Horman 
---
v3
* Moved documentation of SoC names to a separate patch
* Use correct fallback compatibility string in example

v2
* Add R-Car Gen2 and Gen3 fallback compatibility strings rather than
  a single compatibility string for all of R-Car.
---
 Documentation/devicetree/bindings/usb/renesas_usbhs.txt | 10 +-
 drivers/usb/renesas_usbhs/common.c  |  9 +
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/usb/renesas_usbhs.txt 
b/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
index a14c0bb561d5..c55cf77006d0 100644
--- a/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
+++ b/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
@@ -2,10 +2,18 @@ Renesas Electronics USBHS driver
 
 Required properties:
   - compatible: Must contain one of the following:
+
- "renesas,usbhs-r8a7790" for r8a7790 (R-Car H2) compatible device
- "renesas,usbhs-r8a7791" for r8a7791 (R-Car M2-W) compatible device
- "renesas,usbhs-r8a7794" for r8a7794 (R-Car E2) compatible device
- "renesas,usbhs-r8a7795" for r8a7795 (R-Car H3) compatible device
+   - "renesas,rcar-gen2-usbhs" for R-Car Gen2 compatible device
+   - "renesas,rcar-gen3-usbhs" for R-Car Gen3 compatible device
+
+   When compatible with the generic version, nodes must list the
+   SoC-specific version corresponding to the platform first followed
+   by the generic version.
+
   - reg: Base address and length of the register for the USBHS
   - interrupts: Interrupt specifier for the USBHS
   - clocks: A list of phandle + clock specifier pairs
@@ -22,7 +30,7 @@ Optional properties:
 
 Example:
usbhs: usb@e659 {
-   compatible = "renesas,usbhs-r8a7790";
+   compatible = "renesas,usbhs-r8a7790", "renesas,rcar-gen2-usbhs";
reg = <0 0xe659 0 0x100>;
interrupts = <0 107 IRQ_TYPE_LEVEL_HIGH>;
clocks = <_clks R8A7790_CLK_HSUSB>;
diff --git a/drivers/usb/renesas_usbhs/common.c 
b/drivers/usb/renesas_usbhs/common.c
index d82fa36c3465..db9a17bd8997 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -481,6 +481,15 @@ static const struct of_device_id usbhs_of_match[] = {
.compatible = "renesas,usbhs-r8a7795",
.data = (void *)USBHS_TYPE_RCAR_GEN2,
},
+   {
+   .compatible = "renesas,rcar-gen2-usbhs",
+   .data = (void *)USBHS_TYPE_RCAR_GEN2,
+   },
+   {
+   /* Gen3 is compatible with Gen2 */
+   .compatible = "renesas,rcar-gen3-usbhs",
+   .data = (void *)USBHS_TYPE_RCAR_GEN2,
+   },
{ },
 };
 MODULE_DEVICE_TABLE(of, usbhs_of_match);
-- 
2.1.4

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


[PATCH v3 1/3] usb: renesas_usbhs: add SoC names to compatibility string documentation

2015-12-10 Thread Simon Horman
This extends the documentation of compatibility strings a little to
include the SoC names.

Signed-off-by: Simon Horman 
---
v3
* Split into separate patch
---
 Documentation/devicetree/bindings/usb/renesas_usbhs.txt | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/renesas_usbhs.txt 
b/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
index 7d48f63db44e..a14c0bb561d5 100644
--- a/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
+++ b/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
@@ -2,10 +2,10 @@ Renesas Electronics USBHS driver
 
 Required properties:
   - compatible: Must contain one of the following:
-   - "renesas,usbhs-r8a7790"
-   - "renesas,usbhs-r8a7791"
-   - "renesas,usbhs-r8a7794"
-   - "renesas,usbhs-r8a7795"
+   - "renesas,usbhs-r8a7790" for r8a7790 (R-Car H2) compatible device
+   - "renesas,usbhs-r8a7791" for r8a7791 (R-Car M2-W) compatible device
+   - "renesas,usbhs-r8a7794" for r8a7794 (R-Car E2) compatible device
+   - "renesas,usbhs-r8a7795" for r8a7795 (R-Car H3) compatible device
   - reg: Base address and length of the register for the USBHS
   - interrupts: Interrupt specifier for the USBHS
   - clocks: A list of phandle + clock specifier pairs
-- 
2.1.4

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


Re: [PATCH] extcon-usb-gpio: add enable pin support

2015-12-10 Thread Rob Herring
On Fri, Dec 11, 2015 at 02:07:05AM +0300, Sergei Shtylyov wrote:
> Sometimes  there's a real  OTG chip behind the USB ID signal mapped to a GPIO
> pin: in my case it's Maxim Integrated MAX3355E which  integrates Vbus charge
> pump and comparators and passes  thru the ID  signal  from an OTG connector.
> This chip also has the SHDN# pin which  should be  driven high for the normal
> operation  and low to  save power;  it  is connected to a GPIO pin as well on,
> hence  we'll have  to  teach the driver to parse the new optional device tree
> property, "enable-gpio"...

Some wierd spacing going on here.

> 
> Signed-off-by: Sergei Shtylyov 
> 
> ---
> The patch is against the 'extcon-next' branch of the 'extcon.git' repo.
> 
>  Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt |3 +++
>  drivers/extcon/extcon-usb-gpio.c |5 +
>  2 files changed, 8 insertions(+)
> 
> Index: extcon/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
> ===
> --- extcon.orig/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
> +++ extcon/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
> @@ -7,6 +7,9 @@ Required properties:
>  - compatible: Should be "linux,extcon-usb-gpio"
>  - id-gpio: gpio for USB ID pin. See gpio binding.
>  
> +Optional properties:
> +- enable-gpio: gpio for the enable pin. See gpio binding.

Use -gpios as -gpio is deprecated. 

> +
>  Example: Examples of extcon-usb-gpio node in dra7-evm.dts as listed below:
>   extcon_usb1 {
>   compatible = "linux,extcon-usb-gpio";
> Index: extcon/drivers/extcon/extcon-usb-gpio.c
> ===
> --- extcon.orig/drivers/extcon/extcon-usb-gpio.c
> +++ extcon/drivers/extcon/extcon-usb-gpio.c
> @@ -33,6 +33,7 @@ struct usb_extcon_info {
>   struct device *dev;
>   struct extcon_dev *edev;
>  
> + struct gpio_desc *enable_gpiod;
>   struct gpio_desc *id_gpiod;
>   int id_irq;
>  
> @@ -99,6 +100,8 @@ static int usb_extcon_probe(struct platf
>   return -ENOMEM;
>  
>   info->dev = dev;
> + info->enable_gpiod = devm_gpiod_get_optional(>dev, "enable",
> +  GPIOD_OUT_HIGH);
>   info->id_gpiod = devm_gpiod_get(>dev, "id", GPIOD_IN);
>   if (IS_ERR(info->id_gpiod)) {
>   dev_err(dev, "failed to get ID GPIO\n");
> @@ -155,6 +158,8 @@ static int usb_extcon_remove(struct plat
>  
>   cancel_delayed_work_sync(>wq_detcable);
>  
> + gpiod_set_value_cansleep(info->enable_gpiod, 0);

Shouldn't you support either polarity?

Rob
--
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 2/3] usb: renesas_usbhs: add fallback compatibility strings

2015-12-10 Thread Rob Herring
On Fri, Dec 11, 2015 at 11:12:26AM +0900, Simon Horman wrote:
> Add fallback compatibility strings for R-Car Gen2 and Gen3.
> This is in keeping with the fallback scheme being adopted wherever
> appropriate for drivers for Renesas SoCs.
> 
> Signed-off-by: Simon Horman 

Binding looks okay, but one possible typo.

Acked-by: Rob Herring 

> --- a/drivers/usb/renesas_usbhs/common.c
> +++ b/drivers/usb/renesas_usbhs/common.c
> @@ -481,6 +481,15 @@ static const struct of_device_id usbhs_of_match[] = {
>   .compatible = "renesas,usbhs-r8a7795",
>   .data = (void *)USBHS_TYPE_RCAR_GEN2,
>   },
> + {
> + .compatible = "renesas,rcar-gen2-usbhs",
> + .data = (void *)USBHS_TYPE_RCAR_GEN2,
> + },
> + {
> + /* Gen3 is compatible with Gen2 */
> + .compatible = "renesas,rcar-gen3-usbhs",
> + .data = (void *)USBHS_TYPE_RCAR_GEN2,

This supposed to be GEN3?

--
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 2/3] usb: renesas_usbhs: add fallback compatibility strings

2015-12-10 Thread Simon Horman
On Thu, Dec 10, 2015 at 09:56:24PM -0600, Rob Herring wrote:
> On Fri, Dec 11, 2015 at 11:12:26AM +0900, Simon Horman wrote:
> > Add fallback compatibility strings for R-Car Gen2 and Gen3.
> > This is in keeping with the fallback scheme being adopted wherever
> > appropriate for drivers for Renesas SoCs.
> > 
> > Signed-off-by: Simon Horman 
> 
> Binding looks okay, but one possible typo.
> 
> Acked-by: Rob Herring 
> 
> > --- a/drivers/usb/renesas_usbhs/common.c
> > +++ b/drivers/usb/renesas_usbhs/common.c
> > @@ -481,6 +481,15 @@ static const struct of_device_id usbhs_of_match[] = {
> > .compatible = "renesas,usbhs-r8a7795",
> > .data = (void *)USBHS_TYPE_RCAR_GEN2,
> > },
> > +   {
> > +   .compatible = "renesas,rcar-gen2-usbhs",
> > +   .data = (void *)USBHS_TYPE_RCAR_GEN2,
> > +   },
> > +   {
> > +   /* Gen3 is compatible with Gen2 */
> > +   .compatible = "renesas,rcar-gen3-usbhs",
> > +   .data = (void *)USBHS_TYPE_RCAR_GEN2,
> 
> This supposed to be GEN3?

Confusingly the symbol is called GEN2 as it was there for Gen 2
before Gen 3 came along and (so far) Gen 3 is compatible with Gen 2.

I'd be happy to change the name but I think that would be best
as an incremental change on top of this one.
--
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 1/3] usb: renesas_usbhs: add SoC names to compatibility string documentation

2015-12-10 Thread Rob Herring
On Fri, Dec 11, 2015 at 11:12:25AM +0900, Simon Horman wrote:
> This extends the documentation of compatibility strings a little to
> include the SoC names.
> 
> Signed-off-by: Simon Horman 

Acked-by: Rob Herring 

> ---
> v3
> * Split into separate patch
> ---
>  Documentation/devicetree/bindings/usb/renesas_usbhs.txt | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/usb/renesas_usbhs.txt 
> b/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
> index 7d48f63db44e..a14c0bb561d5 100644
> --- a/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
> +++ b/Documentation/devicetree/bindings/usb/renesas_usbhs.txt
> @@ -2,10 +2,10 @@ Renesas Electronics USBHS driver
>  
>  Required properties:
>- compatible: Must contain one of the following:
> - - "renesas,usbhs-r8a7790"
> - - "renesas,usbhs-r8a7791"
> - - "renesas,usbhs-r8a7794"
> - - "renesas,usbhs-r8a7795"
> + - "renesas,usbhs-r8a7790" for r8a7790 (R-Car H2) compatible device
> + - "renesas,usbhs-r8a7791" for r8a7791 (R-Car M2-W) compatible device
> + - "renesas,usbhs-r8a7794" for r8a7794 (R-Car E2) compatible device
> + - "renesas,usbhs-r8a7795" for r8a7795 (R-Car H3) compatible device
>- reg: Base address and length of the register for the USBHS
>- interrupts: Interrupt specifier for the USBHS
>- clocks: A list of phandle + clock specifier pairs
> -- 
> 2.1.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe devicetree" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] extcon-usb-gpio: add enable pin support

2015-12-10 Thread Chanwoo Choi
Hi Sergei,

On 2015년 12월 11일 08:07, Sergei Shtylyov wrote:
> Sometimes  there's a real  OTG chip behind the USB ID signal mapped to a GPIO
> pin: in my case it's Maxim Integrated MAX3355E which  integrates Vbus charge
> pump and comparators and passes  thru the ID  signal  from an OTG connector.

s/thru/through ?

> This chip also has the SHDN# pin which  should be  driven high for the normal
> operation  and low to  save power;  it  is connected to a GPIO pin as well on,
> hence  we'll have  to  teach the driver to parse the new optional device tree
> property, "enable-gpio"...

This patch description includes the double space between words. Also, I think
you need to write the patch description again for formal style.

This patch adds the specific 'enable-gpio' pin to express the SHDN#pin for 
MAX3355E.
I think it is not regular and standard case because maybe USB specification
don't include the SHDN#pin information. I think it not appropriate way.
Instead, you better to make the MAX3355 extcon driver to support this case.

Thanks,
Chanwoo 

> 
> Signed-off-by: Sergei Shtylyov 
> 
> ---
> The patch is against the 'extcon-next' branch of the 'extcon.git' repo.
> 
>  Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt |3 +++
>  drivers/extcon/extcon-usb-gpio.c |5 +
>  2 files changed, 8 insertions(+)
> 
> Index: extcon/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
> ===
> --- extcon.orig/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
> +++ extcon/Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt
> @@ -7,6 +7,9 @@ Required properties:
>  - compatible: Should be "linux,extcon-usb-gpio"
>  - id-gpio: gpio for USB ID pin. See gpio binding.
>  
> +Optional properties:
> +- enable-gpio: gpio for the enable pin. See gpio binding.
> +
>  Example: Examples of extcon-usb-gpio node in dra7-evm.dts as listed below:
>   extcon_usb1 {
>   compatible = "linux,extcon-usb-gpio";
> Index: extcon/drivers/extcon/extcon-usb-gpio.c
> ===
> --- extcon.orig/drivers/extcon/extcon-usb-gpio.c
> +++ extcon/drivers/extcon/extcon-usb-gpio.c
> @@ -33,6 +33,7 @@ struct usb_extcon_info {
>   struct device *dev;
>   struct extcon_dev *edev;
>  
> + struct gpio_desc *enable_gpiod;
>   struct gpio_desc *id_gpiod;
>   int id_irq;
>  
> @@ -99,6 +100,8 @@ static int usb_extcon_probe(struct platf
>   return -ENOMEM;
>  
>   info->dev = dev;
> + info->enable_gpiod = devm_gpiod_get_optional(>dev, "enable",
> +  GPIOD_OUT_HIGH);
>   info->id_gpiod = devm_gpiod_get(>dev, "id", GPIOD_IN);
>   if (IS_ERR(info->id_gpiod)) {
>   dev_err(dev, "failed to get ID GPIO\n");
> @@ -155,6 +158,8 @@ static int usb_extcon_remove(struct plat
>  
>   cancel_delayed_work_sync(>wq_detcable);
>  
> + gpiod_set_value_cansleep(info->enable_gpiod, 0);
> +
>   return 0;
>  }
>  
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 
> 

--
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 0/3] usb: renesas_usbhs: More compat strings

2015-12-10 Thread Kuninori Morimoto

Hi

> this short series adds generic, and soc-specific r8a7792 and r8a7793 compat
> strings to the Renesas USBHS driver. The intention is to provide a complete
> set of compat strings for known R-Car SoCs.
> 
> Changes since v2:
> * Split documentation of SoC names into separate patch
> * Use correct fallback compatibility string in example
> 
> Changes since v1:
> * Add R-Car Gen2 and Gen3 fallback compatibility strings rather than
>   a single compatibility string for all of R-Car.
> 
> Simon Horman (3):
>   usb: renesas_usbhs: add SoC names to compatibility string
> documentation
>   usb: renesas_usbhs: add fallback compatibility strings
>   usb: renesas_usbhs: add device tree support for r8a779[23]
> 
>  .../devicetree/bindings/usb/renesas_usbhs.txt| 20 
> +++-
>  drivers/usb/renesas_usbhs/common.c   |  9 +
>  2 files changed, 24 insertions(+), 5 deletions(-)

For all patches

Acked-by: Kuninori Morimoto 

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


Re: [PATCH 4/9v2] usb: host: ehci.h: fix single statement macros

2015-12-10 Thread Geyslan G. Bem
2015-12-10 9:20 GMT-03:00 Geyslan G. Bem :
> 2015-12-10 8:54 GMT-03:00 Sergei Shtylyov 
> :
>> Hello.
>>
>> On 12/10/2015 1:32 AM, Geyslan G. Bem wrote:
>>
>>> Don't use the 'do {} while (0)' wrapper in a single statement macro.
>>>
>>> Caught by checkpatch: "WARNING: Single statement macros should not
>>> use a do {} while (0) loop"
>>>
>>> Signed-off-by: Geyslan G. Bem 
>>> ---
>>>   drivers/usb/host/ehci.h | 4 ++--
>>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
>>> index cfeebd8..945000a 100644
>>> --- a/drivers/usb/host/ehci.h
>>> +++ b/drivers/usb/host/ehci.h
>>> @@ -244,9 +244,9 @@ struct ehci_hcd {   /* one per
>>> controller */
>>> /* irq statistics */
>>>   #ifdef EHCI_STATS
>>> struct ehci_stats   stats;
>>> -#  define COUNT(x) do { (x)++; } while (0)
>>> +#  define COUNT(x) ((x)++)
>>>   #else
>>> -#  define COUNT(x) do {} while (0)
>>> +#  define COUNT(x) ((void) 0)
>>
>>
>>Why not just empty #define?
>
> Indeed. I'll change it.
> Tks Sergei.

Since COUNT is not used to return the empty #define is ok. Another way
is to use #define COUNT(x) (0) to get a 0 when necessary to read
returns.

>
>
>>
>> [...]
>>
>> MBR, Sergei
>>
>
>
>
> --
> Regards,
>
> Geyslan G. Bem
> hackingbits.com



-- 
Regards,

Geyslan G. Bem
hackingbits.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


Re: [PATCH 6/9v2] usb: host: ehci.h: use space after comma

2015-12-10 Thread Alan Stern
On Thu, 10 Dec 2015, Peter Senna Tschudin wrote:

> >  /* next async queue entry, or pointer to interrupt/periodic QH */
> > -#define QH_NEXT(ehci,dma)  (cpu_to_hc32(ehci, 
> > (((u32)dma)&~0x01f)|Q_TYPE_QH))
> > +#define QH_NEXT(ehci, dma) \
> > +   (cpu_to_hc32(ehci, (((u32) dma) & ~0x01f) | Q_TYPE_QH))
> 
> For the maintainers: Is having two lines here better than having a line with 
> 83 chars?

Two lines is better.  This patch is fine and so are the other 7 -- I 
never received 9/9v2 (the original 9/9 was okay).

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


Locking problem in USB/IP

2015-12-10 Thread Andrew Goodbody
I have an application using the USB/IP drivers and I turned on the lock 
debugging and checking options in the kernel.

I now get this deadlock report in syslog

Dec 11 15:03:20 cbrx-fw01 kernel: [  220.497958] usbip_core: USB/IP Core v1.0.0
Dec 10 15:03:20 cbrx-fw01 kernel: [  220.499707] vhci_hcd vhci_hcd: USB/IP 
Virtual Host Controller
Dec 10 15:03:20 cbrx-fw01 kernel: [  220.499713] vhci_hcd vhci_hcd: new USB bus 
registered, assigned bus number 3
Dec 10 15:03:20 cbrx-fw01 kernel: [  220.501600] usb usb3: New USB device 
found, idVendor=1d6b, idProduct=0002
Dec 10 15:03:20 cbrx-fw01 kernel: [  220.501602] usb usb3: New USB device 
strings: Mfr=3, Product=2, SerialNumber=1
Dec 10 15:03:20 cbrx-fw01 kernel: [  220.501604] usb usb3: Product: USB/IP 
Virtual Host Controller
Dec 10 15:03:20 cbrx-fw01 kernel: [  220.501605] usb usb3: Manufacturer: Linux 
4.3.0-040300-generic vhci_hcd
Dec 10 15:03:20 cbrx-fw01 kernel: [  220.501606] usb usb3: SerialNumber: 
vhci_hcd
Dec 10 15:03:20 cbrx-fw01 kernel: [  220.502978] hub 3-0:1.0: USB hub found
Dec 10 15:03:20 cbrx-fw01 kernel: [  220.503138] hub 3-0:1.0: 8 ports detected
Dec 10 15:03:20 cbrx-fw01 kernel: [  220.504814] vhci_hcd: USB/IP 'Virtual' 
Host Controller (VHCI) Driver v1.0.0
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.195937] vhci_hcd vhci_hcd: rhport(0) 
sockfd(15) devid(4) speed(2) speed_str(full-speed)
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304076] 
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304079] 
=
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304080] [ INFO: inconsistent lock 
state ]
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304082] 4.3.0-040300-generic 
#201511020846 Tainted: GE  
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304083] 
-
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304084] inconsistent {SOFTIRQ-ON-W} -> 
{IN-SOFTIRQ-W} usage.
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304085] swapper/0/0 
[HC0[0]:SC1[1]:HE1:SE0] takes:
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304086]  
(&(>lock)->rlock){+.?...}, at: [] 
vhci_hub_status+0x34/0x170 [vhci_hcd]
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304091] {SOFTIRQ-ON-W} state was 
registered at:
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304092]   [] 
__lock_acquire+0x831/0x1b40
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304095]   [] 
lock_acquire+0xaf/0x130
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304097]   [] 
_raw_spin_lock+0x31/0x40
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304100]   [] 
vhci_hub_control+0x69/0x9a0 [vhci_hcd]
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304102]   [] 
usb_hcd_submit_urb+0x757/0xaa0
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304105]   [] 
usb_submit_urb.part.6+0x2f0/0x550
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304107]   [] 
usb_submit_urb+0x62/0x70
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304109]   [] 
usb_start_wait_urb+0x74/0x180
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304111]   [] 
usb_control_msg+0xc1/0x100
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304113]   [] 
hub_configure+0x129/0xba0
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304114]   [] 
hub_probe+0x2b4/0x340
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304116]   [] 
usb_probe_interface+0x1bb/0x2e0
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304117]   [] 
driver_probe_device+0x224/0x490
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304120]   [] 
__device_attach_driver+0x71/0xa0
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304122]   [] 
bus_for_each_drv+0x5d/0x90
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304124]   [] 
__device_attach+0xbc/0x140
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304126]   [] 
device_initial_probe+0x13/0x20
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304128]   [] 
bus_probe_device+0xa3/0xb0
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304129]   [] 
device_add+0x40d/0x690
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304131]   [] 
usb_set_configuration+0x50a/0x8e0
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304133]   [] 
generic_probe+0x2e/0x80
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304136]   [] 
usb_probe_device+0x32/0x70
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304137]   [] 
driver_probe_device+0x224/0x490
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304139]   [] 
__device_attach_driver+0x71/0xa0
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304141]   [] 
bus_for_each_drv+0x5d/0x90
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304142]   [] 
__device_attach+0xbc/0x140
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304144]   [] 
device_initial_probe+0x13/0x20
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304146]   [] 
bus_probe_device+0xa3/0xb0
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304147]   [] 
device_add+0x40d/0x690
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304149]   [] 
usb_new_device+0x277/0x4b0
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304150]   [] 
usb_add_hcd+0x582/0x970
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304152]   [] 
vhci_hcd_probe+0x6b/0x110 [vhci_hcd]
Dec 10 15:03:34 cbrx-fw01 kernel: [  234.304154]   [] 
platform_drv_probe+0x34/0x90
Dec 10 15:03:34 cbrx-fw01 kernel: [  

Re: [PATCH 6/9v2] usb: host: ehci.h: use space after comma

2015-12-10 Thread Geyslan G. Bem
2015-12-10 12:57 GMT-03:00 Alan Stern :
> On Thu, 10 Dec 2015, Peter Senna Tschudin wrote:
>
>> >  /* next async queue entry, or pointer to interrupt/periodic QH */
>> > -#define QH_NEXT(ehci,dma)  (cpu_to_hc32(ehci, 
>> > (((u32)dma)&~0x01f)|Q_TYPE_QH))
>> > +#define QH_NEXT(ehci, dma) \
>> > +   (cpu_to_hc32(ehci, (((u32) dma) & ~0x01f) | Q_TYPE_QH))
>>
>> For the maintainers: Is having two lines here better than having a line with 
>> 83 chars?
>
> Two lines is better.  This patch is fine and so are the other 7 -- I
> never received 9/9v2 (the original 9/9 was okay).
Alan,

The 9 is v1 only, since it mentions the tool (coccinelle) correctly.

Tks.

>
> Alan Stern
>



-- 
Regards,

Geyslan G. Bem
hackingbits.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


[PATCH v2 RESEND] usb: Use memdup_user to reuse the code

2015-12-10 Thread Pathak, Rahul (R.)
From: Rahul Pathak 

Fixing coccicheck warning which recommends to use memdup_user instead
to reimplement its code, using memdup_user simplifies the code

./drivers/usb/core/devio.c:1398:11-18: WARNING opportunity for memdup_user


Signed-off-by: Rahul Pathak 

---

Changes after v1: setting isopkt=NULL for proper kfree() call

---
 drivers/usb/core/devio.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 38ae877c..844407c 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1395,11 +1395,10 @@ static int proc_do_submiturb(struct usb_dev_state *ps, 
struct usbdevfs_urb *uurb
number_of_packets = uurb->number_of_packets;
isofrmlen = sizeof(struct usbdevfs_iso_packet_desc) *
   number_of_packets;
-   isopkt = kmalloc(isofrmlen, GFP_KERNEL);
-   if (!isopkt)
-   return -ENOMEM;
-   if (copy_from_user(isopkt, iso_frame_desc, isofrmlen)) {
-   ret = -EFAULT;
+   isopkt = memdup_user(iso_frame_desc, isofrmlen);
+   if (IS_ERR(isopkt)) {
+   ret = PTR_ERR(isopkt);
+   isopkt = NULL;
goto error;
}
for (totlen = u = 0; u < number_of_packets; u++) {
-- 
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 4/9v2] usb: host: ehci.h: fix single statement macros

2015-12-10 Thread Sergei Shtylyov

On 12/10/2015 04:05 PM, Geyslan G. Bem wrote:


Don't use the 'do {} while (0)' wrapper in a single statement macro.

Caught by checkpatch: "WARNING: Single statement macros should not
use a do {} while (0) loop"

Signed-off-by: Geyslan G. Bem 
---
   drivers/usb/host/ehci.h | 4 ++--
   1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index cfeebd8..945000a 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -244,9 +244,9 @@ struct ehci_hcd {   /* one per
controller */
 /* irq statistics */
   #ifdef EHCI_STATS
 struct ehci_stats   stats;
-#  define COUNT(x) do { (x)++; } while (0)
+#  define COUNT(x) ((x)++)
   #else
-#  define COUNT(x) do {} while (0)
+#  define COUNT(x) ((void) 0)



Why not just empty #define?


Indeed. I'll change it.
Tks Sergei.


Since COUNT is not used to return the empty #define is ok. Another way
is to use #define COUNT(x) (0) to get a 0 when necessary to read
returns.


   Just 0, no parens please.

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


Re: [PATCH 4/9v2] usb: host: ehci.h: fix single statement macros

2015-12-10 Thread Geyslan G. Bem
2015-12-10 11:44 GMT-03:00 Sergei Shtylyov :
> On 12/10/2015 04:05 PM, Geyslan G. Bem wrote:
>
> Don't use the 'do {} while (0)' wrapper in a single statement macro.
>
> Caught by checkpatch: "WARNING: Single statement macros should not
> use a do {} while (0) loop"
>
> Signed-off-by: Geyslan G. Bem 
> ---
>drivers/usb/host/ehci.h | 4 ++--
>1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
> index cfeebd8..945000a 100644
> --- a/drivers/usb/host/ehci.h
> +++ b/drivers/usb/host/ehci.h
> @@ -244,9 +244,9 @@ struct ehci_hcd {   /* one per
> controller */
>  /* irq statistics */
>#ifdef EHCI_STATS
>  struct ehci_stats   stats;
> -#  define COUNT(x) do { (x)++; } while (0)
> +#  define COUNT(x) ((x)++)
>#else
> -#  define COUNT(x) do {} while (0)
> +#  define COUNT(x) ((void) 0)



 Why not just empty #define?
>>>
>>>
>>> Indeed. I'll change it.
>>> Tks Sergei.
>>
>>
>> Since COUNT is not used to return the empty #define is ok. Another way
>> is to use #define COUNT(x) (0) to get a 0 when necessary to read
>> returns.
>
>
>Just 0, no parens please.
Ok, no parens, since there's no evaluation.

Then my change is:

-#  define COUNT(x) do { (x)++; } while (0)
+#  define COUNT(x) (++(x))
 #else
-#  define COUNT(x) do {} while (0)
+#  define COUNT(x) 0

Pre-increment allowing to return the updated x.

>
> MBR, Sergei
>



-- 
Regards,

Geyslan G. Bem
hackingbits.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


Re: [PATCH] usb: remove redundant conditions

2015-12-10 Thread Geyslan G. Bem
2015-12-10 11:50 GMT-03:00 Felipe Balbi :
>
> Hi,
>
> "Geyslan G. Bem"  writes:
>> This patch removes redundant conditions.
>>
>>  - (!A || (A && B)) is the same as (!A || B).
>>  - (length && length > 5) can be reduced to a single evaluation.
>>
>> Caught by: cppcheck
>>
>> Signed-off-by: Geyslan G. Bem 
>
> Can you split this into one patch per driver, that way it's easier to
> apply by different maintainers.
Balbi, sure, I can.

Tks.
>
> --
> balbi



-- 
Regards,

Geyslan G. Bem
hackingbits.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


Re: [PATCH] usb: remove redundant conditions

2015-12-10 Thread Felipe Balbi

Hi,

"Geyslan G. Bem"  writes:
> This patch removes redundant conditions.
>
>  - (!A || (A && B)) is the same as (!A || B).
>  - (length && length > 5) can be reduced to a single evaluation.
>
> Caught by: cppcheck
>
> Signed-off-by: Geyslan G. Bem 

Can you split this into one patch per driver, that way it's easier to
apply by different maintainers.

-- 
balbi


signature.asc
Description: PGP signature


[PATCH v1 1/1] usb: core: use kbasename() instead of open-coded variant

2015-12-10 Thread Andy Shevchenko
kbasename() helper is dedicated to find a last part of the filename or
pathname. USB core uses open-coded variant of that helper.

Replace some lines of code by kbasename() call.

The current users do not have trailing slash and we are on the safe side to
make such change. I dig a history of the code under question up and found the
patch [1] that brought it along with the same to tty layer. The check for
trailing slash looks like copy'n'paste thing and I consider it as redundant.

[1] 
http://www.kernel.org/pub/linux/kernel//people/akpm/patches/2.5/2.5.69/2.5.69-mm3/broken-out/linus.patch

Signed-off-by: Andy Shevchenko 
Cc: Greg Kroah-Hartman 
Cc: Rasmus Villemoes 
---
 drivers/usb/core/file.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c
index ea337a7..822ced9 100644
--- a/drivers/usb/core/file.c
+++ b/drivers/usb/core/file.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "usb.h"
@@ -155,7 +156,6 @@ int usb_register_dev(struct usb_interface *intf,
int minor_base = class_driver->minor_base;
int minor;
char name[20];
-   char *temp;
 
 #ifdef CONFIG_USB_DYNAMIC_MINORS
/*
@@ -192,14 +192,9 @@ int usb_register_dev(struct usb_interface *intf,
 
/* create a usb class device for this usb interface */
snprintf(name, sizeof(name), class_driver->name, minor - minor_base);
-   temp = strrchr(name, '/');
-   if (temp && (temp[1] != '\0'))
-   ++temp;
-   else
-   temp = name;
intf->usb_dev = device_create(usb_class->class, >dev,
  MKDEV(USB_MAJOR, minor), class_driver,
- "%s", temp);
+ "%s", kbasename(name));
if (IS_ERR(intf->usb_dev)) {
down_write(_rwsem);
usb_minors[minor] = NULL;
-- 
2.6.2

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


Re: [PATCH] usb: remove redundant conditions

2015-12-10 Thread Felipe Balbi
"Geyslan G. Bem"  writes:

> This patch removes redundant conditions.
>
>  - (!A || (A && B)) is the same as (!A || B).
>  - (length && length > 5) can be reduced to a single evaluation.
>
> Caught by: cppcheck
>
> Signed-off-by: Geyslan G. Bem 
> ---

I guess you didn't get previous comment in time; let's split this per
driver so different maintainers can pick their parts.

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH] usb: remove redundant conditions

2015-12-10 Thread Geyslan G. Bem
2015-12-10 12:17 GMT-03:00 David Laight :
> From: Felipe Balbi
>> Sent: 10 December 2015 15:14
>> "Geyslan G. Bem"  writes:
>>
>> > This patch removes redundant conditions.
>> >
>> >  - (!A || (A && B)) is the same as (!A || B).
>> >  - (length && length > 5) can be reduced to a single evaluation.
>> >
>> > Caught by: cppcheck
>> >
>> > Signed-off-by: Geyslan G. Bem 
>> > ---
>>
>> I guess you didn't get previous comment in time; let's split this per
>> driver so different maintainers can pick their parts.
>
> I also suspect that gcc will optimise out the redundant checks as well.
Yes, David. it will.

Let's see.

void f(int f, int s)
{
if (!f || (f && s))
printf("branch\n");
}

Generates without optimization three comparisons:

cmpl$0, -4(%rbp)
je  .L2
cmpl$0, -4(%rbp)
je  .L4
cmpl$0, -8(%rbp)
je  .L4

But with -O2 it generates only two:

testl   %edi, %edi
je  .L2
testl   %esi, %esi
je  .L1

Despite that, I think that the patches are welcome since they silence
checkpatch and make code clearer. Don't you think?

>
> David
>



-- 
Regards,

Geyslan G. Bem
hackingbits.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


RE: [PATCH] usb: remove redundant conditions

2015-12-10 Thread David Laight
From: Felipe Balbi
> Sent: 10 December 2015 15:14
> "Geyslan G. Bem"  writes:
> 
> > This patch removes redundant conditions.
> >
> >  - (!A || (A && B)) is the same as (!A || B).
> >  - (length && length > 5) can be reduced to a single evaluation.
> >
> > Caught by: cppcheck
> >
> > Signed-off-by: Geyslan G. Bem 
> > ---
> 
> I guess you didn't get previous comment in time; let's split this per
> driver so different maintainers can pick their parts.

I also suspect that gcc will optimise out the redundant checks as well.

David

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


Re: [PATCH] usb: remove redundant conditions

2015-12-10 Thread Geyslan G. Bem
2015-12-10 12:29 GMT-03:00 Geyslan G. Bem :
> 2015-12-10 12:17 GMT-03:00 David Laight :
>> From: Felipe Balbi
>>> Sent: 10 December 2015 15:14
>>> "Geyslan G. Bem"  writes:
>>>
>>> > This patch removes redundant conditions.
>>> >
>>> >  - (!A || (A && B)) is the same as (!A || B).
>>> >  - (length && length > 5) can be reduced to a single evaluation.
>>> >
>>> > Caught by: cppcheck
>>> >
>>> > Signed-off-by: Geyslan G. Bem 
>>> > ---
>>>
>>> I guess you didn't get previous comment in time; let's split this per
>>> driver so different maintainers can pick their parts.
>>
>> I also suspect that gcc will optimise out the redundant checks as well.
> Yes, David. it will.
>
> Let's see.
>
> void f(int f, int s)
> {
> if (!f || (f && s))
> printf("branch\n");
> }
>
> Generates without optimization three comparisons:
>
> cmpl$0, -4(%rbp)
> je  .L2
> cmpl$0, -4(%rbp)
> je  .L4
> cmpl$0, -8(%rbp)
> je  .L4
>
> But with -O2 it generates only two:
>
> testl   %edi, %edi
> je  .L2
> testl   %esi, %esi
> je  .L1
>
> Despite that, I think that the patches are welcome since they silence
> checkpatch and make code clearer. Don't you think?
Sorry, silence "cppcheck". I'm mistaking the tool name.
>
>>
>> David
>>
>
>
>
> --
> Regards,
>
> Geyslan G. Bem
> hackingbits.com



-- 
Regards,

Geyslan G. Bem
hackingbits.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


Re: [PATCH] usb: remove redundant conditions

2015-12-10 Thread Felipe Balbi

Hi,

"Geyslan G. Bem"  writes:
> 2015-12-10 12:13 GMT-03:00 Felipe Balbi :
>> "Geyslan G. Bem"  writes:
>>
>>> This patch removes redundant conditions.
>>>
>>>  - (!A || (A && B)) is the same as (!A || B).
>>>  - (length && length > 5) can be reduced to a single evaluation.
>>>
>>> Caught by: cppcheck
>>>
>>> Signed-off-by: Geyslan G. Bem 
>>> ---
>>
>> I guess you didn't get previous comment in time; let's split this per
>> driver so different maintainers can pick their parts.
>
> Okeydokey. :)

thanks :-)

-- 
balbi


signature.asc
Description: PGP signature


[PATCH] USB: serial: option: add support for Quectel UC20

2015-12-10 Thread yegorslists
From: Yegor Yefremov 

Signed-off-by: Yegor Yefremov 
---
 drivers/usb/serial/option.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index f228060..e0950bf 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -1113,6 +1113,7 @@ static const struct usb_device_id option_ids[] = {
{ USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */
{ USB_DEVICE(QUALCOMM_VENDOR_ID, 0x0023)}, /* ONYX 3G device */
{ USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000)}, /* SIMCom SIM5218 */
+   { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9003)}, /* Quectel UC20 */
{ USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) },
{ USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) },
{ USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6003),
-- 
2.1.4

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


Re: [PATCH] usb: remove redundant conditions

2015-12-10 Thread Geyslan G. Bem
2015-12-10 12:13 GMT-03:00 Felipe Balbi :
> "Geyslan G. Bem"  writes:
>
>> This patch removes redundant conditions.
>>
>>  - (!A || (A && B)) is the same as (!A || B).
>>  - (length && length > 5) can be reduced to a single evaluation.
>>
>> Caught by: cppcheck
>>
>> Signed-off-by: Geyslan G. Bem 
>> ---
>
> I guess you didn't get previous comment in time; let's split this per
> driver so different maintainers can pick their parts.

Okeydokey. :)
>
> --
> balbi



-- 
Regards,

Geyslan G. Bem
hackingbits.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


USB3 xHCI Error, unable to acces the disk

2015-12-10 Thread Sébastien Deligny
Hello I've report a bug on bug tracker but I've been advise to post it
directly to th mailing list. Here is my problem :

Connected on USB3 SSD as root partition, sometimes the system lags a
lot and I'm not able to stop the system properly as the FS become
readonly. Tested with 4.2 kernel. With testing version 4.3, the lags
occur again but after few minutes it come back to a stable situation.

Could you please CC'ed me in the answers of this post?

Here is the extract of journalctl :


Connected on USB3 SSD as root partition, sometimes the system lags a
lot and I'm not able to stop the system properly as the FS become
readonly. Tested with 4.2 kernel. With testing version 4.3, the lags
occur again but after few minutes it come back to a stable situation.
Here is the copy of journalctl :

déc. 08 23:10:52 Vulpus kernel: xhci_hcd :00:14.0: ERROR Unknown
event condition 10, HC probably busted
déc. 08 23:10:52 Vulpus kernel: xhci_hcd :00:14.0: ERROR Transfer
event for disabled endpoint or incorrect stream
déc. 08 23:10:52 Vulpus kernel: xhci_hcd :00:14.0:
@00021520e800   0400 04088001
déc. 08 23:11:22 Vulpus kernel: sd 4:0:0:0: [sdb] tag#6
uas_eh_abort_handler 0 uas-tag 7 inflight: CMD OUT
déc. 08 23:11:37 Vulpus kernel: sd 4:0:0:0: [sdb] tag#6 CDB:
opcode=0x2a 2a 00 00 24 a3 e8 00 00 08 00
déc. 08 23:11:37 Vulpus kernel: sd 4:0:0:0: [sdb] tag#5
uas_eh_abort_handler 0 uas-tag 6 inflight: CMD OUT
déc. 08 23:11:37 Vulpus kernel: sd 4:0:0:0: [sdb] tag#5 CDB:
opcode=0x2a 2a 00 01 89 f5 b0 00 00 10 00
déc. 08 23:11:37 Vulpus kernel: sd 4:0:0:0: [sdb] tag#4
uas_eh_abort_handler 0 uas-tag 5 inflight: CMD OUT
déc. 08 23:11:37 Vulpus kernel: sd 4:0:0:0: [sdb] tag#4 CDB:
opcode=0x2a 2a 00 01 89 cf 98 00 00 28 00
déc. 08 23:11:37 Vulpus kernel: sd 4:0:0:0: [sdb] tag#0
uas_eh_abort_handler 0 uas-tag 1 inflight: CMD OUT
déc. 08 23:11:37 Vulpus kernel: sd 4:0:0:0: [sdb] tag#0 CDB:
opcode=0x2a 2a 00 01 44 c3 f0 00 00 90 00
déc. 08 23:11:37 Vulpus kernel: scsi host4: uas_eh_bus_reset_handler start
déc. 08 23:11:37 Vulpus kernel: sd 4:0:0:0: [sdb] tag#1
uas_zap_pending 0 uas-tag 2 inflight: CMD
déc. 08 23:11:37 Vulpus kernel: sd 4:0:0:0: [sdb] tag#1 CDB:
opcode=0x2a 2a 00 08 85 1a 90 00 00 10 00
déc. 08 23:11:37 Vulpus kernel: sd 4:0:0:0: [sdb] tag#2
uas_zap_pending 0 uas-tag 3 inflight: CMD
déc. 08 23:11:37 Vulpus kernel: sd 4:0:0:0: [sdb] tag#2 CDB:
opcode=0x2a 2a 00 0e 39 c3 d0 00 00 08 00
déc. 08 23:11:37 Vulpus kernel: usb 3-3: reset SuperSpeed USB device
number 2 using xhci_hcd
déc. 08 23:11:37 Vulpus kernel: scsi host4: uas_eh_bus_reset_handler success
déc. 08 23:17:41 Vulpus kernel: xhci_hcd :00:14.0: ERROR Unknown
event condition 10, HC probably busted
déc. 08 23:18:12 Vulpus kernel: sd 4:0:0:0: [sdb] tag#2
uas_eh_abort_handler 0 uas-tag 3 inflight: CMD OUT
déc. 08 23:18:12 Vulpus kernel: sd 4:0:0:0: [sdb] tag#2 CDB:
opcode=0x2a 2a 00 02 1f 78 50 00 04 00 00
déc. 08 23:18:12 Vulpus kernel: sd 4:0:0:0: [sdb] tag#1
uas_eh_abort_handler 0 uas-tag 2 inflight: CMD OUT
déc. 08 23:18:12 Vulpus kernel: sd 4:0:0:0: [sdb] tag#1 CDB:
opcode=0x2a 2a 00 02 1f 77 98 00 00 b8 00
déc. 08 23:18:12 Vulpus kernel: sd 4:0:0:0: [sdb] tag#11
uas_eh_abort_handler 0 uas-tag 12 inflight: CMD OUT
déc. 08 23:18:12 Vulpus kernel: sd 4:0:0:0: [sdb] tag#11 CDB:
opcode=0x2a 2a 00 02 1f 73 98 00 04 00 00
déc. 08 23:18:12 Vulpus kernel: sd 4:0:0:0: [sdb] tag#0
uas_eh_abort_handler 0 uas-tag 1 inflight: CMD OUT
déc. 08 23:18:12 Vulpus kernel: sd 4:0:0:0: [sdb] tag#0 CDB:
opcode=0x2a 2a 00 02 1f 72 20 00 01 78 00
déc. 08 23:18:12 Vulpus kernel: sd 4:0:0:0: [sdb] tag#10
uas_eh_abort_handler 0 uas-tag 11 inflight: CMD OUT
déc. 08 23:18:12 Vulpus kernel: sd 4:0:0:0: [sdb] tag#10 CDB:
opcode=0x2a 2a 00 02 1f 6e a8 00 03 78 00
déc. 08 23:18:12 Vulpus kernel: sd 4:0:0:0: [sdb] tag#9
uas_eh_abort_handler 0 uas-tag 10 inflight: CMD OUT
déc. 08 23:18:12 Vulpus kernel: sd 4:0:0:0: [sdb] tag#9 CDB:
opcode=0x2a 2a 00 02 1f 6a e8 00 03 c0 00
déc. 08 23:18:12 Vulpus kernel: sd 4:0:0:0: [sdb] tag#8
uas_eh_abort_handler 0 uas-tag 9 inflight: CMD OUT
déc. 08 23:18:12 Vulpus kernel: sd 4:0:0:0: [sdb] tag#8 CDB:
opcode=0x2a 2a 00 02 1f 67 50 00 03 98 00
déc. 08 23:18:12 Vulpus kernel: sd 4:0:0:0: [sdb] tag#7
uas_eh_abort_handler 0 uas-tag 8 inflight: CMD OUT
déc. 08 23:18:12 Vulpus kernel: sd 4:0:0:0: [sdb] tag#7 CDB:
opcode=0x2a 2a 00 02 1f 63 c8 00 03 88 00
déc. 08 23:18:12 Vulpus kernel: sd 4:0:0:0: [sdb] tag#6
uas_eh_abort_handler 0 uas-tag 7 inflight: CMD OUT
déc. 08 23:18:12 Vulpus kernel: sd 4:0:0:0: [sdb] tag#6 CDB:
opcode=0x2a 2a 00 02 1f 60 48 00 03 80 00
déc. 08 23:18:12 Vulpus kernel: sd 4:0:0:0: [sdb] tag#5
uas_eh_abort_handler 0 uas-tag 6 inflight: CMD OUT
déc. 08 23:18:12 Vulpus kernel: sd 4:0:0:0: [sdb] tag#5 CDB:
opcode=0x2a 2a 00 02 1f 5c 60 00 03 e8 00
déc. 08 23:18:12 Vulpus kernel: sd 4:0:0:0: [sdb] tag#4
uas_eh_abort_handler 0 uas-tag 5 inflight: CMD OUT
déc. 08 23:18:12 Vulpus kernel: sd 4:0:0:0: [sdb] tag#4