usb: dwc3: qcom: simplify error check in dwc3_qcom_find_num_ports()
PATCH 1/1 usb: dwc3: qcom: simplify error check in dwc3_qcom_find_num_ports()
The platform_get_irq_byname_optional() function returns a non-zero IRQ number on success and a negative error code on failure. It never returns zero.
The current implementation in the modern dwc3-qcom driver checks for a return value less than or equal to zero. Since zero is not a valid return value, simplify the check to only look for negative error codes. This aligns the logic with the standard return contract of the platform IRQ APIs.
--- drivers/usb/dwc3/dwc3-qcom.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/dwc3/dwc3-qcom.c +2 -2
@@ -526,14 +526,14 @@ static int dwc3_qcom_find_num_ports(struct platform_device *pdev)int irq; irq =platform_get_irq_byname_optional (pdev,"dp_hs_phy_1" ); -if (irq <=0 ) +if (irq <0 )return 1 ;for (port_num =2 ; port_num <=DWC3_QCOM_MAX_PORTS ; port_num++) {sprintf (irq_name,"dp_hs_phy_%d" , port_num); irq =platform_get_irq_byname_optional (pdev, irq_name); -if (irq <=0 ) +if (irq <0 )return port_num -1 ; }
Signature · 1 line
2.43.0
Thinh Nguyen
maintainerQuoted 39 lines · Zeeshan Ahmad
The
platform_get_irq_byname_optional()function returns a non-zero IRQ number on success and a negative error code on failure. It never returns zero.The current implementation in the modern dwc3-qcom driver checks for a return value less than or equal to zero. Since zero is not a valid return value, simplify the check to only look for negative error codes. This aligns the logic with the standard return contract of the platform IRQ APIs.
Signed-off-by Zeeshan Ahmad <[email protected]>--- drivers/usb/dwc3/dwc3-qcom.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/usb/dwc3/dwc3-qcom.c +2
-2@@ -526,14 +526,14 @@ static int dwc3_qcom_find_num_ports(struct platform_device *pdev)int irq; irq =platform_get_irq_byname_optional (pdev,"dp_hs_phy_1" ); -if (irq <=0 ) +if (irq <0 )return 1 ;for (port_num =2 ; port_num <=DWC3_QCOM_MAX_PORTS ; port_num++) {sprintf (irq_name,"dp_hs_phy_%d" , port_num); irq =platform_get_irq_byname_optional (pdev, irq_name); -if (irq <=0 ) +if (irq <0 )return port_num -1 ; }Signature · 1 line
2.43.0
You're using the same $subject as your previous patch. This may cause some confusion. Can you send V2 with a comment on what's updated?
Thanks,
Thinh