[PATCH 7/8] usb: gadget: dummy_hcd: remove unnecessary 'else' after return

Clint George posted 8 patches 1 week, 5 days ago
Only 7 patches received!
[PATCH 7/8] usb: gadget: dummy_hcd: remove unnecessary 'else' after return
Posted by Clint George 1 week, 5 days ago
The 'else' after a return statement is redundant and unnecessary.
This patch removes the 'else' in dummy_set_halt_and_wedge(), making
the code clearer and compliant with kernel coding style:

- Return early for the -EAGAIN condition.
- Place the subsequent code at the same indentation level instead
  of inside an 'else' block.

Signed-off-by: Clint George <clintbgeorge@gmail.com>
---
 drivers/usb/gadget/udc/dummy_hcd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
index 1840dd822..1114dfe61 100644
--- a/drivers/usb/gadget/udc/dummy_hcd.c
+++ b/drivers/usb/gadget/udc/dummy_hcd.c
@@ -803,10 +803,10 @@ dummy_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedged)
 		return -ESHUTDOWN;
 	if (!value)
 		ep->halted = ep->wedged = 0;
-	else if (ep->desc && (ep->desc->bEndpointAddress & USB_DIR_IN) &&
-			!list_empty(&ep->queue))
-		return -EAGAIN;
 	else {
+		if (ep->desc && (ep->desc->bEndpointAddress & USB_DIR_IN) &&
+			!list_empty(&ep->queue))
+			return -EAGAIN;
 		ep->halted = 1;
 		if (wedged)
 			ep->wedged = 1;
-- 
2.43.0
Re: [PATCH 7/8] usb: gadget: dummy_hcd: remove unnecessary 'else' after return
Posted by Greg KH 1 week, 5 days ago
On Wed, Nov 19, 2025 at 06:38:39PM +0530, Clint George wrote:
> The 'else' after a return statement is redundant and unnecessary.
> This patch removes the 'else' in dummy_set_halt_and_wedge(), making
> the code clearer and compliant with kernel coding style:
> 
> - Return early for the -EAGAIN condition.
> - Place the subsequent code at the same indentation level instead
>   of inside an 'else' block.

When you have to list different things in a commit changelog, that is a
HUGE hint it should be multiple patches :(

> 
> Signed-off-by: Clint George <clintbgeorge@gmail.com>
> ---
>  drivers/usb/gadget/udc/dummy_hcd.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
> index 1840dd822..1114dfe61 100644
> --- a/drivers/usb/gadget/udc/dummy_hcd.c
> +++ b/drivers/usb/gadget/udc/dummy_hcd.c
> @@ -803,10 +803,10 @@ dummy_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedged)
>  		return -ESHUTDOWN;
>  	if (!value)
>  		ep->halted = ep->wedged = 0;
> -	else if (ep->desc && (ep->desc->bEndpointAddress & USB_DIR_IN) &&
> -			!list_empty(&ep->queue))
> -		return -EAGAIN;
>  	else {
> +		if (ep->desc && (ep->desc->bEndpointAddress & USB_DIR_IN) &&
> +			!list_empty(&ep->queue))
> +			return -EAGAIN;

Wait, what?  Why move this around like this, the original is best and
makes more sense.  This version is much harder to read :(

thanks,

greg k-h