diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2023-11-09 13:25:51 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2023-11-21 08:47:38 +0100 |
commit | 871d59256e151f457f147a6db600e3b28959bc7e (patch) | |
tree | 68c228fa015f0fa08c9cf20bffe747945ff3837e /commands/drvinfo.c | |
parent | cbee6ccd7a38f43c07ddd8f826b67fd52f3c69d2 (diff) | |
download | barebox-871d59256e151f457f147a6db600e3b28959bc7e.tar.gz barebox-871d59256e151f457f147a6db600e3b28959bc7e.tar.xz |
commands: drvinfo: support filtering by driver
drvinfo can be very long especially for the in-tree defconfigs.
Make it more convenient to use by add optional filtering support:
barebox@board:/ drvinfo '*imx7d*'
Driver Device(s)
--------------------
imx7d-src
30390000.reset-controller@30390000.of
imx7d_adc
30610000.adc@30610000.of
30620000.adc@30620000.of
Use 'devinfo DEVICE' for more information
Furthermore, tab completion for driver names is now supported as well.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20231109122551.1486020-3-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/drvinfo.c')
-rw-r--r-- | commands/drvinfo.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/commands/drvinfo.c b/commands/drvinfo.c index b984b94725..e13b04870e 100644 --- a/commands/drvinfo.c +++ b/commands/drvinfo.c @@ -5,15 +5,21 @@ #include <common.h> #include <command.h> #include <driver.h> +#include <complete.h> +#include <fnmatch.h> static int do_drvinfo(int argc, char *argv[]) { + char *pattern = argv[1]; struct driver *drv; struct device *dev; printf("Driver\tDevice(s)\n"); printf("--------------------\n"); for_each_driver(drv) { + if (pattern && fnmatch(pattern, drv->name, 0)) + continue; + printf("%s\n",drv->name); for_each_device(dev) { if (dev->driver == drv) @@ -31,5 +37,7 @@ static int do_drvinfo(int argc, char *argv[]) BAREBOX_CMD_START(drvinfo) .cmd = do_drvinfo, BAREBOX_CMD_DESC("list compiled-in device drivers") + BAREBOX_CMD_OPTS("[DRIVER]") BAREBOX_CMD_GROUP(CMD_GRP_INFO) + BAREBOX_CMD_COMPLETE(driver_complete) BAREBOX_CMD_END |