drivers/usb/dwc3/dwc3-qcom-legacy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
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 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.
Signed-off-by: Zeeshan Ahmad <zeeshanahmad022019@gmail.com>
---
drivers/usb/dwc3/dwc3-qcom-legacy.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/dwc3/dwc3-qcom-legacy.c b/drivers/usb/dwc3/dwc3-qcom-legacy.c
index d3fad0fcfdac..34c578309802 100644
--- a/drivers/usb/dwc3/dwc3-qcom-legacy.c
+++ b/drivers/usb/dwc3/dwc3-qcom-legacy.c
@@ -620,14 +620,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;
}
--
2.43.0
On Wed, Feb 18, 2026, Zeeshan Ahmad wrote:
> 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 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.
>
> Signed-off-by: Zeeshan Ahmad <zeeshanahmad022019@gmail.com>
> ---
> drivers/usb/dwc3/dwc3-qcom-legacy.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/dwc3/dwc3-qcom-legacy.c b/drivers/usb/dwc3/dwc3-qcom-legacy.c
> index d3fad0fcfdac..34c578309802 100644
> --- a/drivers/usb/dwc3/dwc3-qcom-legacy.c
> +++ b/drivers/usb/dwc3/dwc3-qcom-legacy.c
> @@ -620,14 +620,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;
> }
>
> --
> 2.43.0
>
Since this is not a fix, I prefer new development to be on the dwc3-qcom
and not the dwc3-qcom-legacy glue.
Thanks,
Thinh
On Thu, Feb 19, 2026 at 10:55:29PM +0000, Thinh Nguyen wrote:
> On Wed, Feb 18, 2026, Zeeshan Ahmad wrote:
> > diff --git a/drivers/usb/dwc3/dwc3-qcom-legacy.c b/drivers/usb/dwc3/dwc3-qcom-legacy.c
> > index d3fad0fcfdac..34c578309802 100644
> > --- a/drivers/usb/dwc3/dwc3-qcom-legacy.c
> > +++ b/drivers/usb/dwc3/dwc3-qcom-legacy.c
> > @@ -620,14 +620,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;
> > }
> >
> > --
> > 2.43.0
> >
>
> Since this is not a fix, I prefer new development to be on the dwc3-qcom
> and not the dwc3-qcom-legacy glue.
There might be some static checker warnings for these? Smatch only
warns if people do an explicit zero check since
platform_get_irq_byname_optional() can never return zero.
regards,
dan carpenter
On Fri, Feb 20, 2026, Dan Carpenter wrote:
> On Thu, Feb 19, 2026 at 10:55:29PM +0000, Thinh Nguyen wrote:
> > On Wed, Feb 18, 2026, Zeeshan Ahmad wrote:
> > > diff --git a/drivers/usb/dwc3/dwc3-qcom-legacy.c b/drivers/usb/dwc3/dwc3-qcom-legacy.c
> > > index d3fad0fcfdac..34c578309802 100644
> > > --- a/drivers/usb/dwc3/dwc3-qcom-legacy.c
> > > +++ b/drivers/usb/dwc3/dwc3-qcom-legacy.c
> > > @@ -620,14 +620,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;
> > > }
> > >
> > > --
> > > 2.43.0
> > >
> >
> > Since this is not a fix, I prefer new development to be on the dwc3-qcom
> > and not the dwc3-qcom-legacy glue.
>
> There might be some static checker warnings for these? Smatch only
> warns if people do an explicit zero check since
> platform_get_irq_byname_optional() can never return zero.
>
But that aside, since this is new development rather than a fix, I'd
prefer to see it go into dwc3-qcom instead of the legacy driver. We
should be pushing new features to the main driver to keep things
consolidated and encourage people to migrate away from the legacy code.
BR,
Thinh
Hi Thinh, Thank you for the suggestion. I have audited the modern drivers/usb/dwc3/dwc3-qcom.c driver on the latest usb-next branch and confirmed that it contains the same redundant IRQ error checks. I will drop the previous patch for the legacy driver and submit a new patch targeting the main dwc3-qcom driver shortly. Regards, Zeeshan
On Tue, Feb 24, 2026, Zeeshan Ahmad wrote: > Hi Thinh, > > Thank you for the suggestion. I have audited the modern > drivers/usb/dwc3/dwc3-qcom.c driver on the latest usb-next branch > and confirmed that it contains the same redundant IRQ error checks. > > I will drop the previous patch for the legacy driver and submit a > new patch targeting the main dwc3-qcom driver shortly. > Hi Zeeshan, Sure. Could you also keep some relevant context from the previous email thread in your reply? This will help us follow the conversation more easily. Thanks, Thinh
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 <zeeshanahmad022019@gmail.com>
---
drivers/usb/dwc3/dwc3-qcom.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index 9ac75547820d..f43f73ac36ff 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -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;
}
--
2.43.0
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 <zeeshanahmad022019@gmail.com>
---
v3:
- Fix missing version changelog in the v2 submission.
v2:
- Targeted the modern dwc3-qcom.c driver instead of the legacy one
as suggested by Thinh Nguyen.
- Audited the modern driver to confirm the same redundant error
check exists there.
- Updated the commit message to specifically mention the modern
dwc3-qcom driver.
drivers/usb/dwc3/dwc3-qcom.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index 9ac75547820d..f43f73ac36ff 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -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;
}
--
2.43.0
On Wed, Feb 25, 2026, Zeeshan Ahmad wrote:
> 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 <zeeshanahmad022019@gmail.com>
> ---
> v3:
> - Fix missing version changelog in the v2 submission.
> v2:
> - Targeted the modern dwc3-qcom.c driver instead of the legacy one
> as suggested by Thinh Nguyen.
> - Audited the modern driver to confirm the same redundant error
> check exists there.
> - Updated the commit message to specifically mention the modern
> dwc3-qcom driver.
>
> drivers/usb/dwc3/dwc3-qcom.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index 9ac75547820d..f43f73ac36ff 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
> @@ -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;
> }
>
> --
> 2.43.0
>
Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
BR,
Thinh
Hi Dan, You are correct. I ran Smatch on dwc3-qcom-legacy.c and it did not produce a warning for these lines. I identified this issue through a manual grep search for the pattern 'platform_get_irq.* <= 0' across the drivers directory. It appears there are several dozen instances of this pattern that Smatch currently misses because the '<= 0' check includes a valid negative error check alongside the redundant zero check. Thank you for the technical background on why Smatch handles it this way. Regards, Zeeshan
© 2016 - 2026 Red Hat, Inc.