Re: [PATCH] usb: gadget: udc: skip pullup() if already connected

From: Bjørn Mork

Date: Tue Apr 21 2026 - 11:37:09 EST


Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> writes:

> This patch is wrong. To see why, read the comments just below the end
> of the patch and see also usb_gadget_activate().


Made me look...

Must say. This strikes me as a nice way to filter out humans from the
rest of the submitters:

gadget->connected = true;
goto out;
}

ret = gadget->ops->pullup(gadget, 1);
if (!ret)
gadget->connected = 1;


The indecisiveness looks strange. There's a nice symmetry with
usb_gadget_disconnect_locked() though:

gadget->connected = false;
goto out;
}

ret = gadget->ops->pullup(gadget, 0);
if (!ret)
gadget->connected = 0;




What surprised me most was that the different variants were added by the
same commit
ccdf138fe3e2 ("usb: gadget: add usb_gadget_activate/deactivate functions").


Bjørn