summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorHolger Schurig <holgerschurig@gmail.com>2014-05-30 11:07:27 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2014-06-02 09:06:45 +0200
commitc19c0da71caaeb2dc6f53e7d53d9ebad24e46c09 (patch)
tree98d246535fea8aecddf511b732af485a2733234e /commands
parent4d1ebec9dac6b8b6b10fc1b3ce1a899df1fca1a1 (diff)
downloadbarebox-c19c0da71caaeb2dc6f53e7d53d9ebad24e46c09.tar.gz
barebox-c19c0da71caaeb2dc6f53e7d53d9ebad24e46c09.tar.xz
drvlist: factor the driver list out of 'devinfo'
The command 'devinfo' was first spitting out all devices, and then also all drivers. This patch separates them into two commands, 'devinfo' as before, and also the new command 'drvinfo' Signed-off-by: Holger Schurig <holgerschurig@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r--commands/Kconfig9
-rw-r--r--commands/Makefile1
-rw-r--r--commands/devinfo.c9
-rw-r--r--commands/drvinfo.c47
4 files changed, 58 insertions, 8 deletions
diff --git a/commands/Kconfig b/commands/Kconfig
index 6043cb6762..c3b40079ff 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -79,11 +79,18 @@ config CMD_DEVINFO
devinfo [DEVICE]
If called without arguments, devinfo shows a summary of the known
- devices and drivers.
+ devices.
If called with a device path being the argument, devinfo shows more
default information about this device and its parameters.
+config CMD_DRVINFO
+ tristate
+ default y
+ prompt "drvinfo"
+ help
+ List compiled-in device drivers and the devices they support.
+
config CMD_HELP
tristate
default y
diff --git a/commands/Makefile b/commands/Makefile
index 030a9061ab..a84d3339ed 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -94,6 +94,7 @@ obj-$(CONFIG_CMD_MIITOOL) += miitool.o
obj-$(CONFIG_CMD_DETECT) += detect.o
obj-$(CONFIG_CMD_BOOT) += boot.o
obj-$(CONFIG_CMD_DEVINFO) += devinfo.o
+obj-$(CONFIG_CMD_DRVINFO) += drvinfo.o
obj-$(CONFIG_CMD_READF) += readf.o
obj-$(CONFIG_CMD_MENUTREE) += menutree.o
obj-$(CONFIG_CMD_2048) += 2048.o
diff --git a/commands/devinfo.c b/commands/devinfo.c
index c229984c5e..71c9bd4b97 100644
--- a/commands/devinfo.c
+++ b/commands/devinfo.c
@@ -54,7 +54,6 @@ static int do_devinfo_subtree(struct device_d *dev, int depth)
static int do_devinfo(int argc, char *argv[])
{
struct device_d *dev;
- struct driver_d *drv;
struct param_d *param;
int i;
struct resource *res;
@@ -66,10 +65,6 @@ static int do_devinfo(int argc, char *argv[])
if (!dev->parent)
do_devinfo_subtree(dev, 0);
}
-
- printf("\ndrivers:\n");
- for_each_driver(drv)
- printf("%s\n",drv->name);
} else {
dev = get_device_by_name(argv[1]);
@@ -148,7 +143,7 @@ Example from an MPC5200 based system:
BAREBOX_CMD_HELP_START(devinfo)
BAREBOX_CMD_HELP_TEXT("If called without arguments, devinfo shows a summary of the known")
-BAREBOX_CMD_HELP_TEXT("devices and drivers.")
+BAREBOX_CMD_HELP_TEXT("devices.")
BAREBOX_CMD_HELP_TEXT("")
BAREBOX_CMD_HELP_TEXT("If called with a device path being the argument, devinfo shows more")
BAREBOX_CMD_HELP_TEXT("default information about this device and its parameters.")
@@ -157,7 +152,7 @@ BAREBOX_CMD_HELP_END
BAREBOX_CMD_START(devinfo)
.cmd = do_devinfo,
- BAREBOX_CMD_DESC("show information about devices and drivers")
+ BAREBOX_CMD_DESC("show information about devices")
BAREBOX_CMD_OPTS("[DEVICE]")
BAREBOX_CMD_GROUP(CMD_GRP_INFO)
BAREBOX_CMD_HELP(cmd_devinfo_help)
diff --git a/commands/drvinfo.c b/commands/drvinfo.c
new file mode 100644
index 0000000000..161118a63e
--- /dev/null
+++ b/commands/drvinfo.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2013 Sascha Hauer, Pengutronix
+ * Copyright (C) 2014 Holger Schurig
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <common.h>
+#include <command.h>
+#include <driver.h>
+
+int do_drvinfo(int argc, char *argv[])
+{
+ struct driver_d *drv;
+ struct device_d *dev;
+
+ printf("Driver\tDevice(s)\n");
+ printf("--------------------\n");
+ for_each_driver(drv) {
+ printf("%s\n",drv->name);
+ for_each_device(dev) {
+ if (dev->driver == drv)
+ printf("\t%s\n", dev_name(dev));
+ }
+ }
+
+ if (IS_ENABLED(CONFIG_CMD_DEVINFO))
+ printf("\nUse 'devinfo DEVICE' for more information\n");
+
+ return 0;
+}
+
+
+BAREBOX_CMD_START(drvinfo)
+ .cmd = do_drvinfo,
+ BAREBOX_CMD_DESC("list compiled-in device drivers")
+ BAREBOX_CMD_GROUP(CMD_GRP_INFO)
+BAREBOX_CMD_END