Skip to contentSkip to conversation

mmc-utils: improve lsmmc usability

PATCH Superseded Torstein Eide 2 participants 7 messages Jun 17 – Jun 19

Subsystems (2)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v3 cover mmc-utils: improve lsmmc usability

This series improves lsmmc in four areas: external manufacturer ID files, accepting /dev and /sys/block paths for register reads, an mmc list command, and bash completion for mmc-utils.

Changes since v2:
- Patch 1 (now also includes the v2 "refactor CID parsing" patch, squashed in since it had no independent value on its own):
- get_manufacturer: return strdup("0x%02x", manid) instead of NULL for unknown manufacturer IDs, so callers always get a printable string
- Patch 2 (Accept /dev and /sys/block paths for register reads):
- resolve_dev_path: use snprintf() instead of strncpy()+manual NUL termination to copy basedev
- Patch 3 (Add mmc list command):
- print_list_entry: new helper, split out of do_list() to format one table row per device
- do_list: probe both SD and MMC ids files once up front so any "ids file not found" warning is printed before the table, not interleaved with it
- do_list: skip sysfs entries whose type is neither "MMC" nor "SD" instead of relying on a missing cid file to filter them out
- Patch 4: unchanged from v2

Torstein Eide (4):
mmc-utils: lsmmc: Use external .ids files for manufacturer lookup
mmc-utils: lsmmc: Accept /dev and /sys/block paths for register reads
mmc-utils: lsmmc: Add mmc list command
mmc-utils: Add bash completion

 Makefile           |  11 +-
 completion/mmc     |  62 +++++
 docs/HOWTO.rst     |  77 +++++-
 lsmmc.c            | 621 ++++++++++++++++++++++++++-------------------
 mmc.c              |   6 +-
 mmc_cmds.h         |   1 +
 multimediacard.ids |  16 ++
 sdcard.ids         |  23 ++
 8 files changed, 543 insertions(+), 274 deletions(-)
 create mode 100644 completion/mmc
 create mode 100644 multimediacard.ids
 create mode 100644 sdcard.ids
Signature · 1 line
2.53.0
#1 lore raw

PATCH v3 1/4 mmc-utils: lsmmc: Use external .ids files for manufacturer lookup

Similar to pci.ids and usb.ids, move the statically defined manufacturer ID arrays out of the source and into external sdcard.ids and multimediacard.ids files. This allows other programs to use the same database without an API, ABI, or cmd interface.

Make the program able to read from the base directory to test without installing.

Make it possible from the Makefile to change the install directory of the database.

---
 Makefile           |   8 +-
 lsmmc.c            | 490 +++++++++++++++++++++------------------------
 multimediacard.ids |  16 ++
 sdcard.ids         |  23 +++
 4 files changed, 272 insertions(+), 265 deletions(-)
 create mode 100644 multimediacard.ids
 create mode 100644 sdcard.ids
Makefile +7 -1
index 7631524..bf8c006 100644
@@ -3,7 +3,9 @@ CC ?= gcc
 # e.g., v1.0-5-2023-10-01
 GIT_VERSION := "$(shell git describe --abbrev=0 --tags)-$$(git rev-list --count $$(git describe --abbrev=0 --tags)..HEAD)-$$(git log -1 --format=%cd --date=short)"
 AM_CFLAGS = -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 \
-	    -DVERSION=\"$(GIT_VERSION)\"
+	    -DVERSION=\"$(GIT_VERSION)\" \
+	    -DSD_IDS_PATH=\"$(idsdir)/sdcard.ids\" \
+	    -DMMC_IDS_PATH=\"$(idsdir)/multimediacard.ids\"
 CFLAGS ?= -g -O2
 objects = \
 	mmc.o \
@@ -21,6 +23,7 @@ override CFLAGS := $(CHECKFLAGS) $(AM_CFLAGS) $(CFLAGS)
 INSTALL = install
 prefix ?= /usr/local
 bindir = $(prefix)/bin
+idsdir ?= /usr/share/misc
 LIBS=
 RESTORE_LIBS=
 mandir = /usr/share/man
@@ -57,6 +60,9 @@ install: $(progs)
 	$(INSTALL) $(progs) $(DESTDIR)$(bindir)
 	$(INSTALL) -m755 -d $(DESTDIR)$(mandir)/man1
 	$(INSTALL) -m 644 mmc.1 $(DESTDIR)$(mandir)/man1
+	$(INSTALL) -m755 -d $(DESTDIR)$(idsdir)
+	$(INSTALL) -m 644 sdcard.ids $(DESTDIR)$(idsdir)
+	$(INSTALL) -m 644 multimediacard.ids $(DESTDIR)$(idsdir)
 
 -include $(foreach obj,$(objects), $(dir $(obj))/.$(notdir $(obj)).d)
 
lsmmc.c +226 -264

631 lines not on this page · raw message

multimediacard.ids new file +16 -0
new file mode 100644
index 0000000..0c91118
@@ -0,0 +1,16 @@
+# MMC manufacturer IDs
+# This file is maintained at: https://git.kernel.org/pub/scm/utils/mmc/mmc-utils.git
+0x00 SanDisk
+0x02 Kingston/SanDisk
+0x03 Toshiba
+0x05 Unknown
+0x06 Unknown
+0x11 Toshiba
+0x13 Micron
+0x15 Samsung/SanDisk/LG
+0x37 KingMax
+0x44 ATP
+0x45 SanDisk Corporation
+0x2c Kingston
+0x70 Kingston
+0xfe Micron
sdcard.ids new file +23 -0
new file mode 100644
index 0000000..cbddcae
@@ -0,0 +1,23 @@
+# SD card (secure digital) manufacturer IDs
+# This file is maintained at: https://git.kernel.org/pub/scm/utils/mmc/mmc-utils.git
+0x01 Panasonic
+0x02 Toshiba/Kingston/Viking
+0x03 SanDisk
+0x08 Silicon Power
+0x18 Infineon
+0x1b Transcend/Samsung
+0x1c Transcend
+0x1d Corsair/AData
+0x1e Transcend
+0x1f Kingston
+0x27 Delkin/Phison
+0x28 Lexar
+0x30 SanDisk
+0x31 Silicon Power
+0x33 STMicroelectronics
+0x41 Kingston
+0x6f STMicroelectronics
+0x74 Transcend
+0x76 Patriot
+0x82 Gobe/Sony
+0x89 Unknown
Signature · 1 line
2.53.0
#2 lore raw

PATCH v3 2/4 mmc-utils: lsmmc: Accept /dev and /sys/block paths for register reads

In reply to Torstein Eide

Commands like 'cid read' previously required a raw sysfs device path such as /sys/bus/mmc/devices/mmc0:0001/. Most users know their block device as /dev/mmcblk0 or /sys/block/mmcblk0.

Add resolve_dev_path() which follows /sys/class/block/<dev>/device via realpath() to reach the canonical sysfs device directory. Paths that start with /dev/ or /sys/block/ are resolved automatically in do_read_reg() before processing, and the resolved sysfs path is printed so the caller can see which device was matched.

---
 docs/HOWTO.rst | 59 ++++++++++++++++++++++++++++++++++++++++++--------
 lsmmc.c        | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 109 insertions(+), 9 deletions(-)
docs/HOWTO.rst +50 -9
index d454d8c..3739a0a 100644
@@ -35,19 +35,60 @@ Running mmc-utils
         Set user area write protection.
 
     ``csd read  [-h] [-v] [-b bus_type] [-r register]  <device path>``
-        Print CSD data from <device path>. The device path should specify the csd sysfs file directory.
-        if [bus_type] is passed (mmc or sd) the [register] content must be passed as well, and no need for device path.
-        it is useful for cases we are getting the register value without having the actual platform.
+        Print CSD data from <device path>. The device path may be one of the following:
+          - sysfs device directory  (/sys/devices/platform/fe310000.mmc/mmc_host/mmc0/mmc0:0001)
+          - device node (/dev/mmcblkN)
+          - sysfs block device entry (/sys/block/mmcblkN)
+        /dev/ and /sys/block/ paths are resolved to the sysfs device
+        directory automatically and the resolved path is printed.
+        If [-b bus_type] is passed (mmc or sd) the [-r register] content must
+        be passed as well, and no device path is required. Useful when the
+        register value is known without access to the actual hardware.
+
+        Example::
+
+            $ mmc csd read /dev/mmcblk0
+            sysfs: /sys/devices/platform/fe310000.mmc/mmc_host/mmc0/mmc0:0001
+            CSD Register: 00000000...
 
     ``cid read <device path>``
-        Print CID data from <device path>. The device path should specify the cid sysfs file directory.
-        if [bus_type] is passed (mmc or sd) the [register] content must be passed as well, and no need for device path.
-        it is useful for cases we are getting the register value without having the actual platform.
+        Print CID data from <device path>. The device path may be one of the following:
+          - sysfs device directory  (/sys/devices/platform/fe310000.mmc/mmc_host/mmc0/mmc0:0001)
+          - device node (/dev/mmcblkN)
+          - sysfs block device entry (/sys/block/mmcblkN)
+        /dev/ and /sys/block/ paths are resolved to the sysfs device
+        directory automatically and the resolved path is printed.
+        If [-b bus_type] is passed (mmc or sd) the [-r register] content must
+        be passed as well, and no device path is required. Useful when the
+        register value is known without access to the actual hardware.
+
+        Example::
+
+            $ mmc cid read /dev/mmcblk0
+            sysfs: /sys/devices/platform/fe310000.mmc/mmc_host/mmc0/mmc0:0001
+            Manufacturer ID: 0x15
+            OEM ID: 0x0100
+            Product name: MAG4FA
+            Product revision: 1.0
+            Serial number: 0x1a2b3c4d
+            Manufacturing date: 01/2021
 
     ``scr read <device path>``
-        Print SCR data from <device path>. The device path should specify the scr sysfs file directory.
-        if [bus_type] is passed (mmc or sd) the [register] content must be passed as well, and no need for device path.
-        it is useful for cases we are getting the register value without having the actual platform.
+        Print SCR data from <device path>. The device path may be one of the following:
+          - sysfs device directory  (/sys/devices/platform/fe320000.mmc/mmc_host/mmc1/mmc1:aaaa)
+          - device node (/dev/mmcblkN)
+          - sysfs block device entry (/sys/block/mmcblkN)
+        /dev/ and /sys/block/ paths are resolved to the sysfs device
+        directory automatically and the resolved path is printed.
+        If [-b bus_type] is passed (mmc or sd) the [-r register] content must
+        be passed as well, and no device path is required. Useful when the
+        register value is known without access to the actual hardware.
+
+        Example::
+
+            $ mmc scr read /dev/mmcblk1
+            sysfs: /sys/devices/platform/fe320000.mmc/mmc_host/mmc1/mmc1:aaaa
+            SCR Register: 0235800000000000
 
     ``ffu <image name> <device> [chunk-bytes]``
       Default mode.  Run Field Firmware Update with `<image name>` on `<device>`. `[chunk-bytes]` is optional and defaults to its max - 512k. Should be in decimal bytes and sector aligned.
lsmmc.c +59 -0

71 lines not on this page · raw message

Signature · 1 line
2.53.0
#3 lore raw

PATCH v3 3/4 mmc-utils: lsmmc: Add mmc list command

In reply to Torstein Eide

Add a 'mmc list' command that scans /sys/bus/mmc/devices/, resolves each card's sysfs path, and prints a one-line summary per device.

find_block_devname() maps a sysfs device path back to its mmcblkN name by scanning /sys/class/block/mmcblkN/device symlinks.

print_list_entry() parses the CID register and formats a fixed-width table row with device name, /dev path, bus type, manufacturer, product, revision, serial number, and manufacturing date.

The header is printed once before the first result. Devices without a readable cid file are skipped silently via access() so unrelated sysfs entries do not produce spurious error messages.

---
 docs/HOWTO.rst | 12 ++++++++
 lsmmc.c        | 76 +++++++++++++++++++++++++++++++++++++++++++++++++-
 mmc.c          |  6 +++-
 mmc_cmds.h     |  1 +
 4 files changed, 93 insertions(+), 2 deletions(-)
docs/HOWTO.rst +12 -0
index 3739a0a..0b486e4 100644
@@ -90,6 +90,18 @@ Running mmc-utils
             sysfs: /sys/devices/platform/fe320000.mmc/mmc_host/mmc1/mmc1:aaaa
             SCR Register: 0235800000000000
 
+    ``list``
+        List all MMC/SD devices present on the system. Output is a table with
+        columns: DEVICE (sysfs name), DEV (/dev path), TYPE (MMC or SD),
+        MANUFACTURER, PRODUCT, REV, SERIAL, and DATE.
+
+        Example::
+
+            $ mmc list
+            DEVICE          DEV            TYPE  MANUFACTURER         PRODUCT    REV   SERIAL      DATE
+            mmc0:0001       /dev/mmcblk0   MMC   Samsung              MAG4FA     1.0   0x1a2b3c4d  2021-jan
+            mmc1:aaaa       /dev/mmcblk1   SD    SanDisk              SP32G      8.0   0x5e6f7a8b  2020-mar
+
     ``ffu <image name> <device> [chunk-bytes]``
       Default mode.  Run Field Firmware Update with `<image name>` on `<device>`. `[chunk-bytes]` is optional and defaults to its max - 512k. Should be in decimal bytes and sector aligned.
 
lsmmc.c +75 -1

106 lines not on this page · raw message

mmc.c +5 -1
index fce7eef..b0f1f9b 100644
@@ -306,6 +306,11 @@ static struct Command commands[] = {
 	  "3. Only up to 512K bytes of boot data will be transferred.\n"
 	  "4. The MMC will perform a soft reset, if your system cannot handle that do not use the boot operation from mmc-utils.\n",
 	},
+	{ do_list, 0,
+	  "list", "\n"
+		"List all MMC/SD devices with their /dev path and CID info.",
+	  NULL
+	},
 	{ NULL, 0, NULL, NULL }
 };
 
@@ -590,4 +595,3 @@ int main(int ac, char **av )
 
 	exit(func(nargs, args));
 }
-
mmc_cmds.h +1 -0
index 9d5f944..033cc09 100644
@@ -62,6 +62,7 @@ int do_opt_ffu4(int nargs, char **argv);
 int do_read_scr(int argc, char **argv);
 int do_read_cid(int argc, char **argv);
 int do_read_csd(int argc, char **argv);
+int do_list(int nargs, char **argv);
 int do_erase(int nargs, char **argv);
 int do_general_cmd_read(int nargs, char **argv);
 int do_softreset(int nargs, char **argv);
Signature · 1 line
2.53.0
#4 lore raw

PATCH v3 4/4 mmc-utils: Add bash completion

In reply to Torstein Eide

Add a bash completion script in completion/mmc that completes subcommands and /dev/mmcblkN device paths for all mmc commands.

The completion directory is named 'completion/' rather than 'bash-completion/' so shell-specific scripts for other shells (zsh, fish, etc.) can be placed alongside it without renaming.

Add bashcompletiondir variable to the Makefile (defaulting to the standard /usr/share/bash-completion/completions) and install the script as part of 'make install'. The install path can be overridden at build time with make bashcompletiondir=<path>.

---
 Makefile       |  5 +++-
 completion/mmc | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++
 docs/HOWTO.rst |  6 +++++
 3 files changed, 72 insertions(+), 1 deletion(-)
 create mode 100644 completion/mmc
Makefile +4 -1
index bf8c006..607d372 100644
@@ -7,6 +7,8 @@ AM_CFLAGS = -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 \
 	    -DSD_IDS_PATH=\"$(idsdir)/sdcard.ids\" \
 	    -DMMC_IDS_PATH=\"$(idsdir)/multimediacard.ids\"
 CFLAGS ?= -g -O2
+idsdir = /usr/share/misc
+bashcompletiondir = /usr/share/bash-completion/completions
 objects = \
 	mmc.o \
 	mmc_cmds.o \
@@ -23,7 +25,6 @@ override CFLAGS := $(CHECKFLAGS) $(AM_CFLAGS) $(CFLAGS)
 INSTALL = install
 prefix ?= /usr/local
 bindir = $(prefix)/bin
-idsdir ?= /usr/share/misc
 LIBS=
 RESTORE_LIBS=
 mandir = /usr/share/man
@@ -63,6 +64,8 @@ install: $(progs)
 	$(INSTALL) -m755 -d $(DESTDIR)$(idsdir)
 	$(INSTALL) -m 644 sdcard.ids $(DESTDIR)$(idsdir)
 	$(INSTALL) -m 644 multimediacard.ids $(DESTDIR)$(idsdir)
+	$(INSTALL) -m755 -d $(DESTDIR)$(bashcompletiondir)
+	$(INSTALL) -m 644 completion/mmc $(DESTDIR)$(bashcompletiondir)/mmc
 
 -include $(foreach obj,$(objects), $(dir $(obj))/.$(notdir $(obj)).d)
 
completion/mmc new file +62 -0

62 lines not on this page · raw message

docs/HOWTO.rst +6 -0
index 0b486e4..3aba86f 100644
@@ -2,6 +2,12 @@
 
 Running mmc-utils
 -----------------
+**Bash completion**
+    Source ``completion/mmc`` to enable tab-completion for all subcommands and
+    device paths. When installed via ``make install``, the file is placed in
+    ``$(bashcompletiondir)`` (default: ``/usr/share/bash-completion/completions/mmc``)
+    and loaded automatically by bash-completion.
+
 **Name**
     mmc - a tool for configuring MMC storage devices
 **Synopsis**
Signature · 1 line
2.53.0
#5 lore raw

RE: [PATCH v3 4/4] mmc-utils: Add bash completion

Quoted 53 lines

Add a bash completion script in completion/mmc that completes subcommands and /dev/mmcblkN device paths for all mmc commands.

The completion directory is named 'completion/' rather than 'bash-completion/' so shell-specific scripts for other shells (zsh, fish, etc.) can be placed alongside it without renaming.

Add bashcompletiondir variable to the Makefile (defaulting to the standard /usr/share/bash-completion/completions) and install the script as part of 'make install'. The install path can be overridden at build time with make bashcompletiondir=<path>.

---
 Makefile       |  5 +++-
 completion/mmc | 62
++++++++++++++++++++++++++++++++++++++++++++++++++
 docs/HOWTO.rst |  6 +++++
 3 files changed, 72 insertions(+), 1 deletion(-)  create mode 100644

completion/mmc

Makefile +2 -0
index bf8c006..607d372 100644
@@ -7,6 +7,8 @@ AM_CFLAGS = -D_FILE_OFFSET_BITS=64 -
 D_FORTIFY_SOURCE=2 \
            -DSD_IDS_PATH=\"$(idsdir)/sdcard.ids\" \
            -DMMC_IDS_PATH=\"$(idsdir)/multimediacard.ids\"
 CFLAGS ?= -g -O2
+idsdir = /usr/share/misc
+bashcompletiondir = /usr/share/bash-completion/completions
 objects = \
        mmc.o \
        mmc_cmds.o \
Makefile +0 -0
@@ -23,7 +25,6 @@ override CFLAGS := $(CHECKFLAGS) $(AM_CFLAGS)

$(CFLAGS) INSTALL = install prefix ?= /usr/local bindir = $(prefix)/bin -idsdir ?= /usr/share/misc LIBS= RESTORE_LIBS= mandir = /usr/share/man @@ -63,6 +64,8 @@ install: $(progs)

        $(INSTALL) -m755 -d $(DESTDIR)$(idsdir)
        $(INSTALL) -m 644 sdcard.ids $(DESTDIR)$(idsdir)
        $(INSTALL) -m 644 multimediacard.ids $(DESTDIR)$(idsdir)
Makefile +3 -0
+       $(INSTALL) -m755 -d $(DESTDIR)$(bashcompletiondir)
+       $(INSTALL) -m 644 completion/mmc
+ $(DESTDIR)$(bashcompletiondir)/mmc
 
 -include $(foreach obj,$(objects), $(dir $(obj))/.$(notdir $(obj)).d)
completion/mmc new file mode 100644 index renamed from completion/mmc +0 -0

0000000..c759972

completion/mmc line 1

Quoted 1 line
completion/mmc new file +1 -0
@@ -0,0 +1,62 @@
+_mmc_complete() {

Instead of hardcoding the entire command and sub-command list (I think you already drifted out of sync), And since mmc help already enumerates every command from that table,
maybe you can drive the completion from its output instead of maintaining a parallel hardcoded list.

Thanks,
Avri

Quoted 88 lines
completion/mmc new file +32 -0
+       local cur prev words cword
+       _init_completion || return
+
+       local devices
+       devices=$(compgen -G "/dev/mmcblk*" 2>/dev/null | grep -E
+ '^/dev/mmcblk[0-9]+$')
+
+       case $cword in
+       1)
+               local verbs="extcsd writeprotect disable gp enh_area \
+                       write_reliability status bootpart bootbus hwreset bkops \
+                       sanitize rpmb cache csd cid scr ffu opt_ffu1 opt_ffu2 \
+                       opt_ffu3 opt_ffu4 erase gen_cmd softreset preidle \
+                       boot_operation list"
+               COMPREPLY=($(compgen -W "$verbs" -- "$cur"))
+               ;;
+       2)
+               case $prev in
+               extcsd)
+                       COMPREPLY=($(compgen -W "read write" -- "$cur")) ;;
+               writeprotect)
+                       COMPREPLY=($(compgen -W "boot user" -- "$cur")) ;;
+               bootpart)
+                       COMPREPLY=($(compgen -W "enable" -- "$cur")) ;;
+               bootbus)
+                       COMPREPLY=($(compgen -W "set" -- "$cur")) ;;
+               hwreset)
+                       COMPREPLY=($(compgen -W "enable disable" -- "$cur")) ;;
+               bkops)
+                       COMPREPLY=($(compgen -W "enable" -- "$cur")) ;;
+               rpmb)
+                       COMPREPLY=($(compgen -W "read-counter read-block write-block

write-key" -- "$cur")) ;;

completion/mmc new file +13 -0
+               cache)
+                       COMPREPLY=($(compgen -W "enable disable" -- "$cur")) ;;
+               csd|cid|scr)
+                       COMPREPLY=($(compgen -W "read" -- "$cur")) ;;
+               gen_cmd)
+                       COMPREPLY=($(compgen -W "read" -- "$cur")) ;;
+               status)
+                       COMPREPLY=($(compgen -W "get" -- "$cur")) ;;
+               gp)
+                       COMPREPLY=($(compgen -W "create" -- "$cur")) ;;
+               enh_area|write_reliability)
+                       COMPREPLY=($(compgen -W "set" -- "$cur")) ;;
+

sanitize|softreset|preidle|ffu|opt_ffu1|opt_ffu2|opt_ffu3|opt_ffu4|erase|boot _operation)

completion/mmc new file +8 -0
+                       COMPREPLY=($(compgen -W "$devices" -- "$cur")) ;;
+               esac
+               ;;
+       3)
+               case ${words[1]} in
+               writeprotect)
+                       COMPREPLY=($(compgen -W "get set" -- "$cur")) ;;
+

csd|cid|scr|extcsd|gen_cmd|status|bootpart|bootbus|hwreset|bkops|cache|g p|enh_area|write_reliability)

completion/mmc new file +9 -0
+                       COMPREPLY=($(compgen -W "$devices" -- "$cur")) ;;
+               esac
+               ;;
+       *)
+               COMPREPLY=($(compgen -W "$devices" -- "$cur")) ;;
+       esac
+}
+
+complete -F _mmc_complete mmc
docs/HOWTO.rst +2 -0
@@ -2,6 +2,12 @@
 
 Running mmc-utils
 -----------------
+**Bash completion**
+    Source ``completion/mmc`` to enable tab-completion for all subcommands

and

docs/HOWTO.rst +2 -0
+    device paths. When installed via ``make install``, the file is placed in
+    ``$(bashcompletiondir)`` (default: ``/usr/share/bash-

completion/completions/mmc``)

docs/HOWTO.rst +2 -1
+    and loaded automatically by bash-completion.
+
 **Name**
     mmc - a tool for configuring MMC storage devices
 **Synopsis**
--

2.53.0

#6 lore raw
In reply to Torstein Eide
Quoted 22 lines

This series improves lsmmc in four areas: external manufacturer ID files, accepting /dev and /sys/block paths for register reads, an mmc list command, and bash completion for mmc-utils.

Changes since v2:
- Patch 1 (now also includes the v2 "refactor CID parsing" patch, squashed in since it had no independent value on its own):
- get_manufacturer: return strdup("0x%02x", manid) instead of NULL for unknown manufacturer IDs, so callers always get a printable string
- Patch 2 (Accept /dev and /sys/block paths for register reads):
- resolve_dev_path: use snprintf() instead of strncpy()+manual NUL termination to copy basedev
- Patch 3 (Add mmc list command):
- print_list_entry: new helper, split out of do_list() to format one table row per device
- do_list: probe both SD and MMC ids files once up front so any "ids file not found" warning is printed before the table, not interleaved with it
- do_list: skip sysfs entries whose type is neither "MMC" nor "SD" instead of relying on a missing cid file to filter them out
- Patch 4: unchanged from v2

Quoted 2 lines

Torstein Eide (4):
mmc-utils: lsmmc: Use external .ids files for manufacturer lookup

Your first patch doesn't compile on its own.
I think you need to move all of the mmc list code into patch 3.

Thanks,
Avri

Quoted 19 lines

mmc-utils: lsmmc: Accept /dev and /sys/block paths for register reads
mmc-utils: lsmmc: Add mmc list command
mmc-utils: Add bash completion

 Makefile           |  11 +-
 completion/mmc     |  62 +++++
 docs/HOWTO.rst     |  77 +++++-
 lsmmc.c            | 621 ++++++++++++++++++++++++++-------------------
 mmc.c              |   6 +-
 mmc_cmds.h         |   1 +
 multimediacard.ids |  16 ++
 sdcard.ids         |  23 ++
 8 files changed, 543 insertions(+), 274 deletions(-)  create mode 100644

completion/mmc create mode 100644 multimediacard.ids create mode 100644 sdcard.ids

--
2.53.0