mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Sascha Hauer" <s.hauer@pengutronix.de>
To: "Fabian Pflug" <f.pflug@pengutronix.de>
Cc: BAREBOX <barebox@lists.infradead.org>,
	Fabian Pflug <f.pflug@pengutronix.de>
Subject: Re: [PATCH 3/5] drivers: usb: host: efi: add efi io driver
Date: Mon, 17 Aug 2026 06:39:54 +0000	[thread overview]
Message-ID: <20260817063954.fxcgWrDICKv5KALxXru98Wjc2MtN3ffYN3QgxvtdXt8@z> (raw)
In-Reply-To: <20260812-v2026-06-0-topic-efi_usb-v1-3-9d2573c29f21@pengutronix.de>

On 2026-08-12 18:36, Fabian Pflug wrote:
> +static int efi_get_usb_string(struct efi_usb_io_protocol *protocol, u16 lang_id,
> +			      int index, char *buf, size_t size)
> +{
> +	char *efi_name;
> +	efi_status_t efiret;
> +	unsigned int u, idx;
> +
> +	memset(buf, 0, size);
> +
> +	if (!index)
> +		return 0;
> +
> +	efiret = protocol->get_string_descriptor(protocol, lang_id, index,
> +						 &efi_name);

Should this be declared with wchar_t * as last argument? That's how it's
declared in EDK2 and the below code easier to follow.

> +	if (EFI_ERROR(efiret))
> +		return -efi_errno(efiret);
> +
> +	size--; /* leave room for trailing NULL char in output buffer */
> +	for (idx = 0, u = 2;; u += 2) {

It's surprising to have u = 2 here. What's in the first character?

> +		if (idx >= size)
> +			break;
> +		if (efi_name[u + 1]) /* high byte */
> +			buf[idx++] = '?'; /* non-ASCII character */
> +		else if (efi_name[u])
> +			buf[idx++] = efi_name[u];
> +		else
> +			break;
> +	}
> +	buf[idx] = 0;
> +
> +	return 0;
> +}
> +

...

> +
> +	efiret = priv->protocol->get_supported_languages(priv->protocol,
> +							 &lang_ids, &num_langs);
> +	if (EFI_ERROR(efiret)) {
> +		err = -efi_errno(efiret);
> +		goto out_err;
> +	}
> +
> +	num_langs = num_langs / sizeof(u16);

Pass a table_size variable to get_supported_languages() and calculate
num_langs_from it, makes it easier to follow without looking at the
prototype.

> +	if (num_langs == 0) {
> +		err = -EPROTO;
> +		goto out_err;
> +	}
> +

Sascha

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




  reply	other threads:[~2026-08-17  6:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-12 16:36 [PATCH 0/5] Add support for USB-EFI devices in EFI Playload Fabian Pflug
2026-08-12 16:36 ` [PATCH 1/5] efi: usb: add header for usb-efi Fabian Pflug
2026-08-12 16:36 ` [PATCH 2/5] usb: core: make usb_set_maxpacket_ep public Fabian Pflug
2026-08-12 16:36 ` [PATCH 3/5] drivers: usb: host: efi: add efi io driver Fabian Pflug
2026-08-17  6:39   ` Sascha Hauer [this message]
2026-08-12 16:36 ` [PATCH 4/5] efi: guid: add guid for usb host controller 2 Fabian Pflug
2026-08-12 16:36 ` [PATCH 5/5] test: x86: add test for uefi usb io Fabian Pflug

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=20260817063954.fxcgWrDICKv5KALxXru98Wjc2MtN3ffYN3QgxvtdXt8@z \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=f.pflug@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