[U-Boot] [RFC PATCH 0/4] cmd: Simplify support for sub-commands

Boris Brezillon boris.brezillon at bootlin.com
Sun Nov 18 22:30:44 UTC 2018


+Tom, Marek as I realize I only sent this to the ML, and I'm actually
expecting feedback from maintainers. Let me know if you think I should
Cc other people.

On Fri, 16 Nov 2018 23:38:08 +0100
Boris Brezillon <boris.brezillon at bootlin.com> wrote:

> Hello,
> 
> This patch series aims at simplifying the command parsing logic done in
> pretty much all the cmd/foo.c files by adding a few macros that help
> defining sub-commands attach to the main entry point.

For those who are interested, I started converting some uboot cmds to
this approach [1]. Most of them are easily converted (I'd say 3/4 or
the existing U_BOOT_CMD_MKENT() users), the remaining ones need extra
care. But before I even consider sending a v2 (possibly including
those conversion patches), I'd like to have some feedback on the general
approach (whether it's something u-boot maintainers are interested in
or not).

Thanks,

Boris

> 
> When you use those macros you also get sub-command auto-completion for
> free (the rest of the auto-completion still has to be done manually).
> 
> Support for several levels of sub commands is not supported but can
> easily be added if needed.
> 
> Some details about the patches:
> 
> - Patch 1 is a fix for the auto-completion code that I had to do have
>   auto-completion in the mtd command working correctly (I can submit it
>   separately if needed)
> - Patch 2 is exposing a function to ease support of auto-completion of
>   sub-commands
> - Patch 3 is adding a set of macros to easily declare the sub-commands
>   attached to the main command
> - Patch 4 is making use of this new infrastructure in cmd/mtd.c.
> 
> Regards,
> 
> Boris
> 
> Boris Brezillon (4):
>   common: command: Fix command auto-completion
>   common: command: Expose a generic helper to auto-complete sub commands
>   command: commands: Add macros to declare commands with subcmds
>   cmd: mtd: Use the subcmd infrastructure to declare mtd sub-commands
> 
>  cmd/mtd.c         | 475 +++++++++++++++++++++++++++-------------------
>  common/command.c  |  32 +++-
>  include/command.h |  54 ++++++
>  3 files changed, 360 insertions(+), 201 deletions(-)
> 

[1]https://github.com/bbrezillon/u-boot/commits/sub-cmds


More information about the U-Boot mailing list