* [PATCH RESEND] usb: dwc3: Remove redundant test
@ 2025-09-29 9:11 Andrew Goodbody
2025-09-29 13:27 ` Marek Vasut
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Andrew Goodbody @ 2025-09-29 9:11 UTC (permalink / raw)
To: Marek Vasut, Tom Rini
Cc: u-boot, Neil Armstrong, Mattijs Korpershoek, Anshul Dalal,
Andrew Goodbody
In dwc3_ep0_complete_data there is a test for 'r' being null and the
code will return at that point if so. After that point 'r' is guaranteed
to not be null and testing for that is redundant. Remove the test for
'r' being non-null.
This issue was found by Smatch.
Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
---
drivers/usb/dwc3/ep0.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index c656cbe25ce6fad9ca1ef07aba131d30018db19d..680756532f0db16f7e6598df19f71bf2ab410820 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -799,10 +799,7 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,
status = DWC3_TRB_SIZE_TRBSTS(trb->size);
if (status == DWC3_TRBSTS_SETUP_PENDING) {
dev_dbg(dwc->dev, "Setup Pending received");
-
- if (r)
- dwc3_gadget_giveback(ep0, r, -ECONNRESET);
-
+ dwc3_gadget_giveback(ep0, r, -ECONNRESET);
return;
}
---
base-commit: 44c4919e9dd6c162b237633ba689441eca9a149c
change-id: 20250925-dwc3_ep0-47c99180480d
Best regards,
--
Andrew Goodbody <andrew.goodbody@linaro.org>
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH RESEND] usb: dwc3: Remove redundant test
2025-09-29 9:11 [PATCH RESEND] usb: dwc3: Remove redundant test Andrew Goodbody
@ 2025-09-29 13:27 ` Marek Vasut
2025-09-29 14:10 ` Tom Rini
2025-09-30 7:47 ` Mattijs Korpershoek
2025-09-30 9:55 ` Mattijs Korpershoek
2 siblings, 1 reply; 5+ messages in thread
From: Marek Vasut @ 2025-09-29 13:27 UTC (permalink / raw)
To: Andrew Goodbody, Tom Rini
Cc: u-boot, Neil Armstrong, Mattijs Korpershoek, Anshul Dalal
On 9/29/25 11:11 AM, Andrew Goodbody wrote:
> In dwc3_ep0_complete_data there is a test for 'r' being null and the
> code will return at that point if so. After that point 'r' is guaranteed
> to not be null and testing for that is redundant. Remove the test for
> 'r' being non-null.
If you really want to make this obvious, use git send-email -U20 or some
such, this will add more context into the diff and include the relevant
part:
793 r = next_request(&ep0->request_list);
794 if (!r)
795 return;
^^^^^^^^^^^^^^^
796
797 dwc3_flush_cache((uintptr_t)trb, sizeof(*trb));
798
799 status = DWC3_TRB_SIZE_TRBSTS(trb->size);
800 if (status == DWC3_TRBSTS_SETUP_PENDING) {
801 dev_dbg(dwc->dev, "Setup Pending received");
802
803 if (r)
804 dwc3_gadget_giveback(ep0, r, -ECONNRESET);
Reviewed-by: Marek Vasut <marek.vasut@mailbox.org>
Thanks !
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH RESEND] usb: dwc3: Remove redundant test
2025-09-29 13:27 ` Marek Vasut
@ 2025-09-29 14:10 ` Tom Rini
0 siblings, 0 replies; 5+ messages in thread
From: Tom Rini @ 2025-09-29 14:10 UTC (permalink / raw)
To: Marek Vasut
Cc: Andrew Goodbody, u-boot, Neil Armstrong, Mattijs Korpershoek,
Anshul Dalal
[-- Attachment #1: Type: text/plain, Size: 1455 bytes --]
On Mon, Sep 29, 2025 at 03:27:19PM +0200, Marek Vasut wrote:
> On 9/29/25 11:11 AM, Andrew Goodbody wrote:
> > In dwc3_ep0_complete_data there is a test for 'r' being null and the
> > code will return at that point if so. After that point 'r' is guaranteed
> > to not be null and testing for that is redundant. Remove the test for
> > 'r' being non-null.
>
> If you really want to make this obvious, use git send-email -U20 or some
> such, this will add more context into the diff and include the relevant
> part:
>
> 793 r = next_request(&ep0->request_list);
> 794 if (!r)
> 795 return;
> ^^^^^^^^^^^^^^^
> 796
> 797 dwc3_flush_cache((uintptr_t)trb, sizeof(*trb));
> 798
> 799 status = DWC3_TRB_SIZE_TRBSTS(trb->size);
> 800 if (status == DWC3_TRBSTS_SETUP_PENDING) {
> 801 dev_dbg(dwc->dev, "Setup Pending received");
> 802
> 803 if (r)
> 804 dwc3_gadget_giveback(ep0, r, -ECONNRESET);
>
> Reviewed-by: Marek Vasut <marek.vasut@mailbox.org>
FWIW, to me updating the amount of context in a sent patch is a style
choice. Yes, just a few more lines in this case would make it clear but
in lots of other cases to review you need to look at the whole function
anyhow (and sometimes catch other issues / places to refactor things for
clarity, ie the pfuze100 patch thread).
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH RESEND] usb: dwc3: Remove redundant test
2025-09-29 9:11 [PATCH RESEND] usb: dwc3: Remove redundant test Andrew Goodbody
2025-09-29 13:27 ` Marek Vasut
@ 2025-09-30 7:47 ` Mattijs Korpershoek
2025-09-30 9:55 ` Mattijs Korpershoek
2 siblings, 0 replies; 5+ messages in thread
From: Mattijs Korpershoek @ 2025-09-30 7:47 UTC (permalink / raw)
To: Andrew Goodbody, Marek Vasut, Tom Rini
Cc: u-boot, Neil Armstrong, Mattijs Korpershoek, Anshul Dalal,
Andrew Goodbody
Hi Andrew,
Thank you for the patch.
On Mon, Sep 29, 2025 at 10:11, Andrew Goodbody <andrew.goodbody@linaro.org> wrote:
> In dwc3_ep0_complete_data there is a test for 'r' being null and the
> code will return at that point if so. After that point 'r' is guaranteed
> to not be null and testing for that is redundant. Remove the test for
> 'r' being non-null.
>
> This issue was found by Smatch.
>
> Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
> ---
> drivers/usb/dwc3/ep0.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
> index c656cbe25ce6fad9ca1ef07aba131d30018db19d..680756532f0db16f7e6598df19f71bf2ab410820 100644
> --- a/drivers/usb/dwc3/ep0.c
> +++ b/drivers/usb/dwc3/ep0.c
> @@ -799,10 +799,7 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,
> status = DWC3_TRB_SIZE_TRBSTS(trb->size);
> if (status == DWC3_TRBSTS_SETUP_PENDING) {
> dev_dbg(dwc->dev, "Setup Pending received");
> -
> - if (r)
> - dwc3_gadget_giveback(ep0, r, -ECONNRESET);
> -
> + dwc3_gadget_giveback(ep0, r, -ECONNRESET);
> return;
> }
>
>
> ---
> base-commit: 44c4919e9dd6c162b237633ba689441eca9a149c
> change-id: 20250925-dwc3_ep0-47c99180480d
>
> Best regards,
> --
> Andrew Goodbody <andrew.goodbody@linaro.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH RESEND] usb: dwc3: Remove redundant test
2025-09-29 9:11 [PATCH RESEND] usb: dwc3: Remove redundant test Andrew Goodbody
2025-09-29 13:27 ` Marek Vasut
2025-09-30 7:47 ` Mattijs Korpershoek
@ 2025-09-30 9:55 ` Mattijs Korpershoek
2 siblings, 0 replies; 5+ messages in thread
From: Mattijs Korpershoek @ 2025-09-30 9:55 UTC (permalink / raw)
To: Marek Vasut, Tom Rini, Andrew Goodbody
Cc: u-boot, Neil Armstrong, Anshul Dalal
Hi,
On Mon, 29 Sep 2025 10:11:57 +0100, Andrew Goodbody wrote:
> In dwc3_ep0_complete_data there is a test for 'r' being null and the
> code will return at that point if so. After that point 'r' is guaranteed
> to not be null and testing for that is redundant. Remove the test for
> 'r' being non-null.
>
> This issue was found by Smatch.
>
> [...]
Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-dfu (u-boot-dfu-next)
[1/1] usb: dwc3: Remove redundant test
https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/8cd4a5e94ba2ab73fde3301d6314549dd5a25cb4
--
Mattijs
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-09-30 9:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-29 9:11 [PATCH RESEND] usb: dwc3: Remove redundant test Andrew Goodbody
2025-09-29 13:27 ` Marek Vasut
2025-09-29 14:10 ` Tom Rini
2025-09-30 7:47 ` Mattijs Korpershoek
2025-09-30 9:55 ` Mattijs Korpershoek
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.