The EFI boot menu only shows entries like "usb 0" or "scsi 0", which is
of little help when several drives of the same type are attached. Append
the capacity and the vendor/product strings of the drive so that the
entries read:

    usb 0 (29.7 GiB, Generic Ultra HS-COMBO)
    usb 1 (28.6 GiB, USB SanDisk 3.2Gen1)
    scsi 0 (1 GiB, MICRON MT064GBCAV1U31AA)

As Heinrich suggested in the v2 review, patch 1 adds a Z suffix to the
%u printf() conversion, which prints a size with a binary unit, instead
of adding an snprint_size() helper:

    printf("%lluZ\n", 0x113000ULL);      /* 1 MiB */
    printf("%.3lluZ\n", 0x113000ULL);    /* 1.074 MiB */

"%.1lluZ" prints the same as print_size(), which a test checks. Patch 2
uses it for the capacity in the boot menu.

The roughly 100 callers of print_size() could then use the new format,
and print_size() be removed, but that is left for a separate series.
print_size() also works with the SPL and TPL tiny printf(), which does
not support the new format.

Changes in v3:
- Replace the snprint_size() helper with a %uZ printf() format, as
  suggested by Heinrich Schuchardt, with documentation and tests
- Print the capacity in the boot menu with "%.1lluZ"

Changes in v2:
- Address Heinrich Schuchardt review comments
- Reuse the print_size() formatting
- Add a new snprint_size() helper
- Build the suffix with a single snprintf() instead of a chain of
  strlcat() calls.
- Limit the name to 64 instead of 128 characters.
- Document the limitation in the commit message.

Link to v2: https://patchwork.ozlabs.org/project/uboot/list/?series=520652

Padmarao Begari (2):
  lib: vsprintf: add %uZ to print sizes
  efi_loader: expand disk device names with drive details

 doc/develop/printf.rst    | 30 ++++++++++++
 include/efi_loader.h      | 13 +++++-
 lib/efi_loader/efi_disk.c | 66 +++++++++++++++++++++++++-
 lib/vsprintf.c            | 98 +++++++++++++++++++++++++++++++++++++++
 test/common/print.c       | 97 ++++++++++++++++++++++++++++++++++++++
 5 files changed, 301 insertions(+), 3 deletions(-)

-- 
2.34.1

Reply via email to