From: Aristo Chen <aristo.chen@canonical.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Neill Kapron <nkapron@google.com>
Cc: Alan Stern <stern@rowland.harvard.edu>,
Krishna Kurapati <krishna.kurapati@oss.qualcomm.com>,
Jassi Brar <jassisinghbrar@gmail.com>,
linux-usb@vger.kernel.org,
Aristo Chen <aristo.chen@canonical.com>,
stable@vger.kernel.org
Subject: [PATCH 2/2] usb: gadget: udc: do not fail bind when the UDC has no pullup callback
Date: Wed, 25 Nov 2026 09:05:30 +0000 [thread overview]
Message-ID: <20261125092004.15562-3-aristo.chen@canonical.com> (raw)
In-Reply-To: <20261125092004.15562-1-aristo.chen@canonical.com>
Commit 0ea39e030a80 ("usb: gadget: udc: Handle gadget_connect failure
during bind operation") made gadget_bind_driver() fail when
usb_udc_connect_control_locked() returns an error. Before that commit
the return value was ignored.
usb_gadget_connect_locked() and usb_gadget_disconnect_locked() return
-EOPNOTSUPP when the UDC driver has no pullup callback. So since that
commit, no gadget driver can bind to such a UDC. max3420_udc,
fotg210-udc, fsl_qe_udc, goku_udc and snps_udc_core have no pullup
callback.
The core cannot control the pullup of such a UDC, so there is nothing
for it to do in this step. Skip the step during bind when there is no
pullup callback. If the step runs and returns an error, the bind still
fails, which is what the commit above wanted.
I do not have hardware for any of these drivers. I found the problem
with a KUnit test under User Mode Linux that emulates a MAX3420 on a
fake SPI controller. There the bind failed with -EOPNOTSUPP:
udc spi0.0: failed to start max3420-kunit: -95
With this patch the bind works and the emulated controller answers
SETUP packets. I did not test on hardware or with the other drivers.
This patch and the test were written with an AI coding assistant.
Fixes: 0ea39e030a80 ("usb: gadget: udc: Handle gadget_connect failure during bind operation")
Cc: stable@vger.kernel.org
Signed-off-by: Aristo Chen <aristo.chen@canonical.com>
---
drivers/usb/gadget/udc/core.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
index 577bc15f61a1..aa6226666eb5 100644
--- a/drivers/usb/gadget/udc/core.c
+++ b/drivers/usb/gadget/udc/core.c
@@ -1680,9 +1680,12 @@ static int gadget_bind_driver(struct device *dev)
}
usb_gadget_enable_async_callbacks(udc);
udc->allow_connect = true;
- ret = usb_udc_connect_control_locked(udc);
- if (ret)
- goto err_connect_control;
+ /* Without a pullup callback the core cannot control the pullup */
+ if (gadget->ops->pullup) {
+ ret = usb_udc_connect_control_locked(udc);
+ if (ret)
+ goto err_connect_control;
+ }
mutex_unlock(&udc->connect_lock);
--
2.53.0
next prev parent reply other threads:[~2026-11-25 9:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 9:05 [PATCH 0/2] usb: gadget: fix max3420_udc endpoint index and bind without pullup Aristo Chen
2026-11-25 9:05 ` [PATCH 1/2] usb: gadget: max3420_udc: fix out of bounds endpoint index from wIndex Aristo Chen
2026-11-25 9:05 ` Aristo Chen [this message]
2026-11-25 9:25 ` [PATCH 0/2] usb: gadget: fix max3420_udc endpoint index and bind without pullup sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261125092004.15562-3-aristo.chen@canonical.com \
--to=aristo.chen@canonical.com \
--cc=gregkh@linuxfoundation.org \
--cc=jassisinghbrar@gmail.com \
--cc=krishna.kurapati@oss.qualcomm.com \
--cc=linux-usb@vger.kernel.org \
--cc=nkapron@google.com \
--cc=stable@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox