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

From: Greg KH

Date: Wed Nov 19 2025 - 10:25:49 EST


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@xxxxxxxxx>
> ---
> 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