linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] usb: dwc3: host: remove dead code in dwc3_host_get_irq()
@ 2023-03-24  6:09 Mingxuan Xiang
  2023-03-24  6:20 ` Dan Carpenter
  2023-03-24 18:30 ` Thinh Nguyen
  0 siblings, 2 replies; 3+ messages in thread
From: Mingxuan Xiang @ 2023-03-24  6:09 UTC (permalink / raw)
  To: Thinh Nguyen, Greg Kroah-Hartman
  Cc: hust-os-kernel-patches, Dongliang Mu, Mingxuan Xiang, linux-usb,
	linux-kernel

According to the description of platform_get_irq()
 * Return: non-zero IRQ number on success, 
 			negative error number on failure.
and the code, platform_get_irq() will return -EINVAL
instead of IRQ0.

So platform_get_irq() no longer returns 0, there is no
need to check whether the return value is 0.

Found by Smatch:
drivers/usb/dwc3/host.c:60 dwc3_host_get_irq() 
	warn: platform_get_irq() does not return zero

Signed-off-by: Mingxuan Xiang <mx_xiang@hust.edu.cn>
---
v2->v3: remove curly braces
v1->v2: remove redundant goto
Only compile tested.
---
 drivers/usb/dwc3/host.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
index f6f13e7f1ba1..61f57fe5bb78 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -52,13 +52,8 @@ static int dwc3_host_get_irq(struct dwc3 *dwc)
 		goto out;
 
 	irq = platform_get_irq(dwc3_pdev, 0);
-	if (irq > 0) {
+	if (irq > 0)
 		dwc3_host_fill_xhci_irq_res(dwc, irq, NULL);
-		goto out;
-	}
-
-	if (!irq)
-		irq = -EINVAL;
 
 out:
 	return irq;
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] usb: dwc3: host: remove dead code in dwc3_host_get_irq()
  2023-03-24  6:09 [PATCH v3] usb: dwc3: host: remove dead code in dwc3_host_get_irq() Mingxuan Xiang
@ 2023-03-24  6:20 ` Dan Carpenter
  2023-03-24 18:30 ` Thinh Nguyen
  1 sibling, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2023-03-24  6:20 UTC (permalink / raw)
  To: Mingxuan Xiang
  Cc: Thinh Nguyen, Greg Kroah-Hartman, hust-os-kernel-patches,
	Dongliang Mu, linux-usb, linux-kernel

On Fri, Mar 24, 2023 at 02:09:34PM +0800, Mingxuan Xiang wrote:
> According to the description of platform_get_irq()
>  * Return: non-zero IRQ number on success, 
>  			negative error number on failure.
> and the code, platform_get_irq() will return -EINVAL
> instead of IRQ0.
> 
> So platform_get_irq() no longer returns 0, there is no
> need to check whether the return value is 0.
> 
> Found by Smatch:
> drivers/usb/dwc3/host.c:60 dwc3_host_get_irq() 
> 	warn: platform_get_irq() does not return zero
> 
> Signed-off-by: Mingxuan Xiang <mx_xiang@hust.edu.cn>
> ---
> v2->v3: remove curly braces
> v1->v2: remove redundant goto
> Only compile tested.

Reviewed-by: Dan Carpenter <error27@gmail.com>

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] usb: dwc3: host: remove dead code in dwc3_host_get_irq()
  2023-03-24  6:09 [PATCH v3] usb: dwc3: host: remove dead code in dwc3_host_get_irq() Mingxuan Xiang
  2023-03-24  6:20 ` Dan Carpenter
@ 2023-03-24 18:30 ` Thinh Nguyen
  1 sibling, 0 replies; 3+ messages in thread
From: Thinh Nguyen @ 2023-03-24 18:30 UTC (permalink / raw)
  To: Mingxuan Xiang
  Cc: Thinh Nguyen, Greg Kroah-Hartman,
	hust-os-kernel-patches@googlegroups.com, Dongliang Mu,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org

On Fri, Mar 24, 2023, Mingxuan Xiang wrote:
> According to the description of platform_get_irq()
>  * Return: non-zero IRQ number on success, 
>  			negative error number on failure.
> and the code, platform_get_irq() will return -EINVAL
> instead of IRQ0.
> 
> So platform_get_irq() no longer returns 0, there is no
> need to check whether the return value is 0.
> 
> Found by Smatch:
> drivers/usb/dwc3/host.c:60 dwc3_host_get_irq() 
> 	warn: platform_get_irq() does not return zero
> 
> Signed-off-by: Mingxuan Xiang <mx_xiang@hust.edu.cn>
> ---
> v2->v3: remove curly braces
> v1->v2: remove redundant goto
> Only compile tested.
> ---
>  drivers/usb/dwc3/host.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
> index f6f13e7f1ba1..61f57fe5bb78 100644
> --- a/drivers/usb/dwc3/host.c
> +++ b/drivers/usb/dwc3/host.c
> @@ -52,13 +52,8 @@ static int dwc3_host_get_irq(struct dwc3 *dwc)
>  		goto out;
>  
>  	irq = platform_get_irq(dwc3_pdev, 0);
> -	if (irq > 0) {
> +	if (irq > 0)
>  		dwc3_host_fill_xhci_irq_res(dwc, irq, NULL);
> -		goto out;
> -	}
> -
> -	if (!irq)
> -		irq = -EINVAL;
>  
>  out:
>  	return irq;
> -- 
> 2.39.2
> 

Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>

Thanks,
Thinh

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-24 18:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-24  6:09 [PATCH v3] usb: dwc3: host: remove dead code in dwc3_host_get_irq() Mingxuan Xiang
2023-03-24  6:20 ` Dan Carpenter
2023-03-24 18:30 ` Thinh Nguyen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).