From: Fabian Pflug <f.pflug@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
Ahmad Fatoum <a.fatoum@pengutronix.de>,
"open list:BAREBOX" <barebox@lists.infradead.org>
Cc: Fabian Pflug <f.pflug@pengutronix.de>
Subject: [PATCH v4 6/6] drivers: usb: add usb_add_device to add a device
Date: Fri, 04 Sep 2026 15:58:30 +0200 [thread overview]
Message-ID: <20260904-v2026-06-0-topic-efi_usb-v4-6-6f3a59d8e338@pengutronix.de> (raw)
In-Reply-To: <20260904-v2026-06-0-topic-efi_usb-v4-0-6f3a59d8e338@pengutronix.de>
Before this pull request, the only one to create new USB devices was the
USB subsystem itselg, which did it in the usb_new_device function.
This function is not viable for the efi driver, as it cannot set the USB
descriptor as used by it.
Create a new header function to add a new USB device to the list of
known USB devices.
Modify the usb_new_device function to use the newly created header
instead of doing it itself and add it to efi-io-protocol for usb
devices.
---
drivers/usb/core/usb.c | 12 ++++++++++--
drivers/usb/core/usb.h | 1 +
drivers/usb/host/efi-io-protocol.c | 2 ++
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index ce10b71f40..38b0ec2595 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -557,8 +557,7 @@ int usb_new_device(struct usb_device *dev)
dev->descriptor->idVendor, "%04x");
dev_add_param_uint32_fixed(&dev->dev, "idProduct",
dev->descriptor->idProduct, "%04x");
- list_add_tail(&dev->list, &usb_device_list);
- dev_count++;
+ usb_add_device(dev);
err = 0;
@@ -575,6 +574,15 @@ void usb_free_device(struct usb_device *usbdev)
free(usbdev);
}
+void usb_add_device(struct usb_device *usbdev)
+{
+ if (!usbdev)
+ return;
+
+ list_add_tail(&usbdev->list, &usb_device_list);
+ dev_count++;
+}
+
void usb_remove_device(struct usb_device *usbdev)
{
int i;
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index b503e5b4a8..49a6938246 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -5,6 +5,7 @@
struct usb_device *usb_alloc_new_device(void);
void usb_free_device(struct usb_device *dev);
int usb_new_device(struct usb_device *dev);
+void usb_add_device(struct usb_device *dev);
void usb_remove_device(struct usb_device *dev);
void usb_set_maxpacket_ep(struct usb_device *dev,
struct usb_endpoint_descriptor *ep);
diff --git a/drivers/usb/host/efi-io-protocol.c b/drivers/usb/host/efi-io-protocol.c
index 4858d30eb9..5bc25d132f 100644
--- a/drivers/usb/host/efi-io-protocol.c
+++ b/drivers/usb/host/efi-io-protocol.c
@@ -273,6 +273,8 @@ static int create_usb_device(struct efi_usb_io_priv *priv)
/* register as root device for host */
host->root_dev = dev;
+ usb_add_device(dev);
+
return 0;
out_err:
--
2.47.3
prev parent reply other threads:[~2026-09-04 14:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 13:58 [PATCH v4 0/6] Add support for USB-EFI devices in EFI Playload Fabian Pflug
2026-09-04 13:58 ` [PATCH v4 1/6] efi: usb: add header for usb-efi Fabian Pflug
2026-09-04 13:58 ` [PATCH v4 2/6] usb: core: make usb_set_maxpacket_ep public Fabian Pflug
2026-09-04 13:58 ` [PATCH v4 3/6] drivers: usb: host: efi: add efi io driver Fabian Pflug
2026-09-04 13:58 ` [PATCH v4 4/6] efi: guid: add guid for usb host controller 2 Fabian Pflug
2026-09-04 13:58 ` [PATCH v4 5/6] test: x86: add test for uefi usb io Fabian Pflug
2026-09-04 13:58 ` Fabian Pflug [this message]
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=20260904-v2026-06-0-topic-efi_usb-v4-6-6f3a59d8e338@pengutronix.de \
--to=f.pflug@pengutronix.de \
--cc=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/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