From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Fabian Pflug <f.pflug@pengutronix.de>,
Sascha Hauer <s.hauer@pengutronix.de>,
BAREBOX <barebox@lists.infradead.org>
Subject: Re: [PATCH v2 3/5] drivers: usb: host: efi: add efi io driver
Date: Wed, 19 Aug 2026 13:04:20 +0200 [thread overview]
Message-ID: <18abca76-bd8d-4c26-b16a-98865f147f9e@pengutronix.de> (raw)
In-Reply-To: <20260817-v2026-06-0-topic-efi_usb-v2-3-3d45c1782ccc@pengutronix.de>
Hi,
On 8/17/26 10:47 AM, Fabian Pflug wrote:
> +config USB_EFI_IO_PROTOCOL
> + bool "EFI USB I/O Protocol"
> + depends on EFI_PAYLOAD
> + depends on USB_HOST
This depends is redundant, because the whole file is only included when
USB_HOST is selected.
> +static int efi_usb_error_check(efi_status_t efiret, int status)
> +{
> + if (efiret == EFI_DEVICE_ERROR) {
> + if (status & EFI_USB_ERR_TIMEOUT)
> + return -ETIMEDOUT;
> + if (status & EFI_USB_ERR_STALL)
> + return -ETIMEDOUT;
return -EPIPE
> +
> + interface->no_of_ep = interface->desc.bNumEndpoints;
> +
> + if (interface->no_of_ep > USB_MAXENDPOINTS) {
> + err = -EPROTO;
> + goto out_err;
> + }
> +
> + for (int i = 0; i < interface->no_of_ep; i++) {
> + efiret = priv->protocol->get_endpoint_descriptor(
> + priv->protocol, i, &interface->ep_desc[i]);
> + if (EFI_ERROR(efiret))
> + return -efi_errno(efiret);
Should be goto.
> + usb_set_maxpacket_ep(dev, &interface->ep_desc[i]);
> + }
> +
> + efiret = priv->protocol->get_supported_languages(priv->protocol,
> + &lang_ids, &table_size);
> + if (EFI_ERROR(efiret)) {
> + err = -efi_errno(efiret);
> + goto out_err;
> + }
> +
> + /* table size is given in bytes, not entries */
> + if (table_size < sizeof(*lang_ids)) {
> + err = -EPROTO;
> + goto out_err;
> + }
> +
> + dev->string_langid = lang_ids[0];
> + dev->have_langid = true;
Set this to false when table_size == 0 instead of an error?
> +
> + dev_info(&dev->dev, "new device: Mfr=%d, Product=%d, SerialNumber=%d\n",
> + dev->descriptor->iManufacturer, dev->descriptor->iProduct,
> + dev->descriptor->iSerialNumber);
> +
> + err = efi_get_usb_string(priv->protocol, dev->string_langid,
> + dev->descriptor->iManufacturer, dev->mf,
> + sizeof(dev->mf));
> + if (err)
> + goto out_err;
> + err = efi_get_usb_string(priv->protocol, dev->string_langid,
> + dev->descriptor->iProduct, dev->prod,
> + sizeof(dev->prod));
> + if (err)
> + goto out_err;
> + err = efi_get_usb_string(priv->protocol, dev->string_langid,
> + dev->descriptor->iSerialNumber, dev->serial,
> + sizeof(dev->serial));
> + if (err)
> + goto out_err;
> +
> + dev_info(&dev->dev, "Bus %03d Device %03d: ID %04x:%04x %s\n",
> + dev->host->busnum, dev->devnum, dev->descriptor->idVendor,
> + dev->descriptor->idProduct, dev->prod);
> +
> + err = register_device(&dev->dev);
> + if (err) {
> + dev_err(&dev->dev, "Failed to register device: %pe\n",
> + ERR_PTR(err));
> + goto out_err;
> + }
> +
> + // register as root device for host
> + host->root_dev = dev;
> +
> + return 0;
> +
> +out_err:
> + dev_err(&dev->dev, "Failed to create UEFI-USB-IO device: %pe\n",
> + ERR_PTR(err));
> + usb_free_device(dev);
> + return err;
> +}
> +
> +static int efi_usb_io_probe(struct efi_device *efidev)
> +{
> + struct device *dev = &efidev->dev;
> + struct efi_usb_io_priv *priv;
> + struct usb_host *host;
> +
> + priv = xzalloc(sizeof(*priv));
> +
> + BS->handle_protocol(efidev->handle, &efi_usb_io_protocol_guid,
> + (void **)&priv->protocol);
> + if (!priv->protocol)
> + return -ENODEV;
> +
> + dev->priv = priv;
> + priv->dev = dev;
> +
> + // EFI has one device per probe, which now needs its own host controller,
> + // since there is no shared host controller resource.
> +
> + host = &priv->host;
> + host->submit_int_msg = efi_usb_int_msg;
> + host->submit_control_msg = efi_usb_control_msg;
> + host->submit_bulk_msg = efi_usb_bulk_msg;
host->hw_dev must be set.
Cheers,
Ahmad
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2026-08-19 11:04 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-17 8:47 [PATCH v2 0/5] Add support for USB-EFI devices in EFI Playload Fabian Pflug
2026-08-17 8:47 ` [PATCH v2 1/5] efi: usb: add header for usb-efi Fabian Pflug
2026-08-19 10:01 ` Ahmad Fatoum
2026-08-19 13:32 ` Fabian Pflug
2026-08-19 14:03 ` Ahmad Fatoum
2026-08-19 14:11 ` Fabian Pflug
2026-08-17 8:47 ` [PATCH v2 2/5] usb: core: make usb_set_maxpacket_ep public Fabian Pflug
2026-08-19 9:15 ` Ahmad Fatoum
2026-08-17 8:47 ` [PATCH v2 3/5] drivers: usb: host: efi: add efi io driver Fabian Pflug
2026-08-19 11:04 ` Ahmad Fatoum [this message]
2026-08-17 8:47 ` [PATCH v2 4/5] efi: guid: add guid for usb host controller 2 Fabian Pflug
2026-08-19 9:18 ` Ahmad Fatoum
2026-08-17 8:47 ` [PATCH v2 5/5] test: x86: add test for uefi usb io Fabian Pflug
2026-08-19 9:18 ` Ahmad Fatoum
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=18abca76-bd8d-4c26-b16a-98865f147f9e@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=f.pflug@pengutronix.de \
--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