Hi,

John Youn <john.y...@synopsys.com> writes:
> On 10/31/2016 3:51 AM, Felipe Balbi wrote:
>> Cleanup only, no functional changes.
>> 
>> Signed-off-by: Felipe Balbi <felipe.ba...@linux.intel.com>
>> ---
>>  drivers/usb/dwc3/gadget.c | 62 
>> +++++++++++++++++++++++++++++------------------
>>  1 file changed, 38 insertions(+), 24 deletions(-)
>> 
>> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
>> index c692aafa7397..c0011174a1f1 100644
>> --- a/drivers/usb/dwc3/gadget.c
>> +++ b/drivers/usb/dwc3/gadget.c
>> @@ -2871,6 +2871,39 @@ static irqreturn_t dwc3_interrupt(int irq, void *_evt)
>>      return dwc3_check_event_buf(evt);
>>  }
>>  
>> +static int dwc3_gadget_get_irq(struct dwc3 *dwc)
>> +{
>> +    struct platform_device *dwc3_pdev = to_platform_device(dwc->dev);
>> +    int irq;
>> +
>> +    irq = platform_get_irq_byname(dwc3_pdev, "peripheral");
>> +    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 peripheral IRQ\n");
>> +
>> +    if (!irq)
>> +            irq = -EINVAL;
>> +
>> +out:
>> +    return irq;
>> +}
>> +
>>  /**
>>   * dwc3_gadget_init - Initializes gadget related registers
>>   * @dwc: pointer to our controller context structure
>> @@ -2879,31 +2912,12 @@ static irqreturn_t dwc3_interrupt(int irq, void 
>> *_evt)
>>   */
>>  int dwc3_gadget_init(struct dwc3 *dwc)
>>  {
>> -    int ret, irq;
>> -    struct platform_device *dwc3_pdev = to_platform_device(dwc->dev);
>> +    int ret;
>
> 'ret' is returned uninitialized in the error handling path.
>
> Found in coverity.

Thanks for letting me know. Here's another version:

8<------------------------------------------------------------------------------
From 6a92a7120c5b7c35e7ff8d80a8dcbd7e67ec5f09 Mon Sep 17 00:00:00 2001
From: Felipe Balbi <felipe.ba...@linux.intel.com>
Date: Mon, 3 Oct 2016 11:27:01 +0300
Subject: [PATCH] usb: dwc3: gadget: extract dwc3_gadget_get_irq()

Cleanup only, no functional changes.

Signed-off-by: Felipe Balbi <felipe.ba...@linux.intel.com>
---
 drivers/usb/dwc3/gadget.c | 62 +++++++++++++++++++++++++++++------------------
 1 file changed, 39 insertions(+), 23 deletions(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index c692aafa7397..45a3325ff5b1 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -2871,6 +2871,39 @@ static irqreturn_t dwc3_interrupt(int irq, void *_evt)
        return dwc3_check_event_buf(evt);
 }
 
+static int dwc3_gadget_get_irq(struct dwc3 *dwc)
+{
+       struct platform_device *dwc3_pdev = to_platform_device(dwc->dev);
+       int irq;
+
+       irq = platform_get_irq_byname(dwc3_pdev, "peripheral");
+       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 peripheral IRQ\n");
+
+       if (!irq)
+               irq = -EINVAL;
+
+out:
+       return irq;
+}
+
 /**
  * dwc3_gadget_init - Initializes gadget related registers
  * @dwc: pointer to our controller context structure
@@ -2879,30 +2912,13 @@ static irqreturn_t dwc3_interrupt(int irq, void *_evt)
  */
 int dwc3_gadget_init(struct dwc3 *dwc)
 {
-       int ret, irq;
-       struct platform_device *dwc3_pdev = to_platform_device(dwc->dev);
+       int ret;
+       int irq;
 
-       irq = platform_get_irq_byname(dwc3_pdev, "peripheral");
-       if (irq == -EPROBE_DEFER)
-               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 peripheral IRQ\n");
-                               }
-                               if (!irq)
-                                       irq = -EINVAL;
-                               return irq;
-                       }
-               }
+       irq = dwc3_gadget_get_irq(dwc);
+       if (irq < 0) {
+               ret = irq;
+               goto err0;
        }
 
        dwc->irq_gadget = irq;
-- 
2.10.1



-- 
balbi

Attachment: signature.asc
Description: PGP signature

Reply via email to