Re: [PATCH 52/82] usb: dwc3: host: extract dwc3_host_get_irq()

2016-11-01 Thread Felipe Balbi
Hi,

Felipe Balbi  writes:
>>>  int dwc3_host_init(struct dwc3 *dwc)
>>>  {
>>> struct property_entry   props[2];
>>> struct platform_device  *xhci;
>>> int ret, irq;
>>> struct resource *res;
>>> -   struct platform_device  *dwc3_pdev = to_platform_device(dwc->dev);

forgot to commit the revert of this line, sorry:


8<--
From 3a8a910cbf7f66c63b366e37e9f2513a6455e658 Mon Sep 17 00:00:00 2001
From: Felipe Balbi 
Date: Mon, 3 Oct 2016 12:31:48 +0300
Subject: [PATCH] usb: dwc3: host: extract dwc3_host_get_irq()

Cleanup only, no functional changes.

Signed-off-by: Felipe Balbi 
---
 drivers/usb/dwc3/host.c | 72 -
 1 file changed, 42 insertions(+), 30 deletions(-)

diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
index f6533c68fed1..8c2679e7d4a7 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -19,6 +19,39 @@
 
 #include "core.h"
 
+static int dwc3_host_get_irq(struct dwc3 *dwc)
+{
+   struct platform_device  *dwc3_pdev = to_platform_device(dwc->dev);
+   int irq;
+
+   irq = platform_get_irq_byname(dwc3_pdev, "host");
+   if (irq > 0)
+   goto out;
+
+   if (irq == -EPROBE_DEFER)
+   goto out;
+
+   irq = platform_get_irq_byname(dwc3_pdev, "dwc_usb3");
+   if (irq > 0)
+   goto out;
+
+   if (irq == -EPROBE_DEFER)
+   goto out;
+
+   irq = platform_get_irq(dwc3_pdev, 0);
+   if (irq > 0)
+   goto out;
+
+   if (irq != -EPROBE_DEFER)
+   dev_err(dwc->dev, "missing host IRQ\n");
+
+   if (!irq)
+   irq = -EINVAL;
+
+out:
+   return irq;
+}
+
 int dwc3_host_init(struct dwc3 *dwc)
 {
struct property_entry   props[2];
@@ -27,39 +60,18 @@ int dwc3_host_init(struct dwc3 *dwc)
struct resource *res;
struct platform_device  *dwc3_pdev = to_platform_device(dwc->dev);
 
-   irq = platform_get_irq_byname(dwc3_pdev, "host");
-   if (irq == -EPROBE_DEFER)
+   irq = dwc3_host_get_irq(dwc);
+   if (irq < 0)
return irq;
 
-   if (irq <= 0) {
-   irq = platform_get_irq_byname(dwc3_pdev, "dwc_usb3");
-   if (irq == -EPROBE_DEFER)
-   return irq;
-
-   if (irq <= 0) {
-   irq = platform_get_irq(dwc3_pdev, 0);
-   if (irq <= 0) {
-   if (irq != -EPROBE_DEFER) {
-   dev_err(dwc->dev,
-   "missing host IRQ\n");
-   }
-   if (!irq)
-   irq = -EINVAL;
-   return irq;
-   } else {
-   res = platform_get_resource(dwc3_pdev,
-   IORESOURCE_IRQ, 0);
-   }
-   } else {
-   res = platform_get_resource_byname(dwc3_pdev,
-  IORESOURCE_IRQ,
-  "dwc_usb3");
-   }
-
-   } else {
+   res = platform_get_resource_byname(dwc3_pdev, IORESOURCE_IRQ, "host");
+   if (!res)
res = platform_get_resource_byname(dwc3_pdev, IORESOURCE_IRQ,
-  "host");
-   }
+   "dwc_usb3");
+   if (!res)
+   res = platform_get_resource(dwc3_pdev, IORESOURCE_IRQ, 0);
+   if (!res)
+   return -ENOMEM;
 
dwc->xhci_resources[1].start = irq;
dwc->xhci_resources[1].end = irq;
-- 
2.10.1



-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH 52/82] usb: dwc3: host: extract dwc3_host_get_irq()

2016-11-01 Thread Felipe Balbi

Hi,

John Youn  writes:
> On 10/31/2016 3:51 AM, Felipe Balbi wrote:
>> Cleanup only, no functional changes.
>> 
>> Signed-off-by: Felipe Balbi 
>> ---
>>  drivers/usb/dwc3/host.c | 68 
>> +
>>  1 file changed, 35 insertions(+), 33 deletions(-)
>> 
>> diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
>> index f6533c68fed1..ed824647ead8 100644
>> --- a/drivers/usb/dwc3/host.c
>> +++ b/drivers/usb/dwc3/host.c
>> @@ -19,48 +19,50 @@
>>  
>>  #include "core.h"
>>  
>> +static int dwc3_host_get_irq(struct dwc3 *dwc)
>> +{
>> +struct platform_device  *dwc3_pdev = to_platform_device(dwc->dev);
>> +int irq;
>> +
>> +irq = platform_get_irq_byname(dwc3_pdev, "host");
>> +if (irq > 0)
>> +goto out;
>> +
>> +if (irq == -EPROBE_DEFER)
>> +goto out;
>> +
>> +irq = platform_get_irq_byname(dwc3_pdev, "dwc_usb3");
>> +if (irq > 0)
>> +goto out;
>> +
>> +if (irq == -EPROBE_DEFER)
>> +goto out;
>> +
>> +irq = platform_get_irq(dwc3_pdev, 0);
>> +if (irq > 0)
>> +goto out;
>> +
>> +if (irq != -EPROBE_DEFER)
>> +dev_err(dwc->dev, "missing host IRQ\n");
>> +
>> +if (!irq)
>> +irq = -EINVAL;
>> +
>> +out:
>> +return irq;
>> +}
>> +
>>  int dwc3_host_init(struct dwc3 *dwc)
>>  {
>>  struct property_entry   props[2];
>>  struct platform_device  *xhci;
>>  int ret, irq;
>>  struct resource *res;
>> -struct platform_device  *dwc3_pdev = to_platform_device(dwc->dev);
>>  
>> -irq = platform_get_irq_byname(dwc3_pdev, "host");
>> -if (irq == -EPROBE_DEFER)
>> +irq = dwc3_host_get_irq(dwc);
>> +if (irq < 0)
>>  return irq;
>>  
>> -if (irq <= 0) {
>> -irq = platform_get_irq_byname(dwc3_pdev, "dwc_usb3");
>> -if (irq == -EPROBE_DEFER)
>> -return irq;
>> -
>> -if (irq <= 0) {
>> -irq = platform_get_irq(dwc3_pdev, 0);
>> -if (irq <= 0) {
>> -if (irq != -EPROBE_DEFER) {
>> -dev_err(dwc->dev,
>> -"missing host IRQ\n");
>> -}
>> -if (!irq)
>> -irq = -EINVAL;
>> -return irq;
>> -} else {
>> -res = platform_get_resource(dwc3_pdev,
>> -IORESOURCE_IRQ, 0);
>> -}
>> -} else {
>> -res = platform_get_resource_byname(dwc3_pdev,
>> -   IORESOURCE_IRQ,
>> -   "dwc_usb3");
>> -}
>> -
>> -} else {
>> -res = platform_get_resource_byname(dwc3_pdev, IORESOURCE_IRQ,
>> -   "host");
>> -}
>> -
>>  dwc->xhci_resources[1].start = irq;
>>  dwc->xhci_resources[1].end = irq;
>>  dwc->xhci_resources[1].flags = res->flags;
>
> Similar to patch 51.
>
> Lost the initialization of 'res' and then used uninitialized
> here.

completely missed that and GCC didn't tell me about it :-) Thanks,
here's another version

8<--
From 7a1e5968b7d42ff4524c9841bb139f499ce7cae6 Mon Sep 17 00:00:00 2001
From: Felipe Balbi 
Date: Mon, 3 Oct 2016 12:31:48 +0300
Subject: [PATCH] usb: dwc3: host: extract dwc3_host_get_irq()

Cleanup only, no functional changes.

Signed-off-by: Felipe Balbi 
---
 drivers/usb/dwc3/host.c | 73 -
 1 file changed, 42 insertions(+), 31 deletions(-)

diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
index f6533c68fed1..c39b826c17ba 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -19,47 +19,58 @@
 
 #include "core.h"
 
+static int dwc3_host_get_irq(struct dwc3 *dwc)
+{
+   struct platform_device  *dwc3_pdev = to_platform_device(dwc->dev);
+   int irq;
+
+   irq = platform_get_irq_byname(dwc3_pdev, "host");
+   if (irq > 0)
+   goto out;
+
+   if (irq == -EPROBE_DEFER)
+   goto out;
+
+   irq = platform_get_irq_byname(dwc3_pdev, "dwc_usb3");
+   if (irq > 0)
+   goto out;
+
+   if (irq == -EPROBE_DEFER)
+   goto out;
+
+   irq = platform_get_irq(dwc3_pdev, 0);
+   if (irq > 0)
+   goto out;
+
+   if (irq != -EPROBE_DEFER)
+   dev_err(dwc->dev, "missing host IRQ\n");
+
+   if (!irq)
+   irq = -EINVAL;
+
+out:
+   return irq;
+}
+
 

Re: [PATCH 52/82] usb: dwc3: host: extract dwc3_host_get_irq()

2016-10-31 Thread John Youn
On 10/31/2016 3:51 AM, Felipe Balbi wrote:
> Cleanup only, no functional changes.
> 
> Signed-off-by: Felipe Balbi 
> ---
>  drivers/usb/dwc3/host.c | 68 
> +
>  1 file changed, 35 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
> index f6533c68fed1..ed824647ead8 100644
> --- a/drivers/usb/dwc3/host.c
> +++ b/drivers/usb/dwc3/host.c
> @@ -19,48 +19,50 @@
>  
>  #include "core.h"
>  
> +static int dwc3_host_get_irq(struct dwc3 *dwc)
> +{
> + struct platform_device  *dwc3_pdev = to_platform_device(dwc->dev);
> + int irq;
> +
> + irq = platform_get_irq_byname(dwc3_pdev, "host");
> + if (irq > 0)
> + goto out;
> +
> + if (irq == -EPROBE_DEFER)
> + goto out;
> +
> + irq = platform_get_irq_byname(dwc3_pdev, "dwc_usb3");
> + if (irq > 0)
> + goto out;
> +
> + if (irq == -EPROBE_DEFER)
> + goto out;
> +
> + irq = platform_get_irq(dwc3_pdev, 0);
> + if (irq > 0)
> + goto out;
> +
> + if (irq != -EPROBE_DEFER)
> + dev_err(dwc->dev, "missing host IRQ\n");
> +
> + if (!irq)
> + irq = -EINVAL;
> +
> +out:
> + return irq;
> +}
> +
>  int dwc3_host_init(struct dwc3 *dwc)
>  {
>   struct property_entry   props[2];
>   struct platform_device  *xhci;
>   int ret, irq;
>   struct resource *res;
> - struct platform_device  *dwc3_pdev = to_platform_device(dwc->dev);
>  
> - irq = platform_get_irq_byname(dwc3_pdev, "host");
> - if (irq == -EPROBE_DEFER)
> + irq = dwc3_host_get_irq(dwc);
> + if (irq < 0)
>   return irq;
>  
> - if (irq <= 0) {
> - irq = platform_get_irq_byname(dwc3_pdev, "dwc_usb3");
> - if (irq == -EPROBE_DEFER)
> - return irq;
> -
> - if (irq <= 0) {
> - irq = platform_get_irq(dwc3_pdev, 0);
> - if (irq <= 0) {
> - if (irq != -EPROBE_DEFER) {
> - dev_err(dwc->dev,
> - "missing host IRQ\n");
> - }
> - if (!irq)
> - irq = -EINVAL;
> - return irq;
> - } else {
> - res = platform_get_resource(dwc3_pdev,
> - IORESOURCE_IRQ, 0);
> - }
> - } else {
> - res = platform_get_resource_byname(dwc3_pdev,
> -IORESOURCE_IRQ,
> -"dwc_usb3");
> - }
> -
> - } else {
> - res = platform_get_resource_byname(dwc3_pdev, IORESOURCE_IRQ,
> -"host");
> - }
> -
>   dwc->xhci_resources[1].start = irq;
>   dwc->xhci_resources[1].end = irq;
>   dwc->xhci_resources[1].flags = res->flags;

Similar to patch 51.

Lost the initialization of 'res' and then used uninitialized
here.

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 52/82] usb: dwc3: host: extract dwc3_host_get_irq()

2016-10-31 Thread Felipe Balbi
Cleanup only, no functional changes.

Signed-off-by: Felipe Balbi 
---
 drivers/usb/dwc3/host.c | 68 +
 1 file changed, 35 insertions(+), 33 deletions(-)

diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
index f6533c68fed1..ed824647ead8 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -19,48 +19,50 @@
 
 #include "core.h"
 
+static int dwc3_host_get_irq(struct dwc3 *dwc)
+{
+   struct platform_device  *dwc3_pdev = to_platform_device(dwc->dev);
+   int irq;
+
+   irq = platform_get_irq_byname(dwc3_pdev, "host");
+   if (irq > 0)
+   goto out;
+
+   if (irq == -EPROBE_DEFER)
+   goto out;
+
+   irq = platform_get_irq_byname(dwc3_pdev, "dwc_usb3");
+   if (irq > 0)
+   goto out;
+
+   if (irq == -EPROBE_DEFER)
+   goto out;
+
+   irq = platform_get_irq(dwc3_pdev, 0);
+   if (irq > 0)
+   goto out;
+
+   if (irq != -EPROBE_DEFER)
+   dev_err(dwc->dev, "missing host IRQ\n");
+
+   if (!irq)
+   irq = -EINVAL;
+
+out:
+   return irq;
+}
+
 int dwc3_host_init(struct dwc3 *dwc)
 {
struct property_entry   props[2];
struct platform_device  *xhci;
int ret, irq;
struct resource *res;
-   struct platform_device  *dwc3_pdev = to_platform_device(dwc->dev);
 
-   irq = platform_get_irq_byname(dwc3_pdev, "host");
-   if (irq == -EPROBE_DEFER)
+   irq = dwc3_host_get_irq(dwc);
+   if (irq < 0)
return irq;
 
-   if (irq <= 0) {
-   irq = platform_get_irq_byname(dwc3_pdev, "dwc_usb3");
-   if (irq == -EPROBE_DEFER)
-   return irq;
-
-   if (irq <= 0) {
-   irq = platform_get_irq(dwc3_pdev, 0);
-   if (irq <= 0) {
-   if (irq != -EPROBE_DEFER) {
-   dev_err(dwc->dev,
-   "missing host IRQ\n");
-   }
-   if (!irq)
-   irq = -EINVAL;
-   return irq;
-   } else {
-   res = platform_get_resource(dwc3_pdev,
-   IORESOURCE_IRQ, 0);
-   }
-   } else {
-   res = platform_get_resource_byname(dwc3_pdev,
-  IORESOURCE_IRQ,
-  "dwc_usb3");
-   }
-
-   } else {
-   res = platform_get_resource_byname(dwc3_pdev, IORESOURCE_IRQ,
-  "host");
-   }
-
dwc->xhci_resources[1].start = irq;
dwc->xhci_resources[1].end = irq;
dwc->xhci_resources[1].flags = res->flags;
-- 
2.10.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