From c19c0da71caaeb2dc6f53e7d53d9ebad24e46c09 Mon Sep 17 00:00:00 2001 From: Holger Schurig Date: Fri, 30 May 2014 11:07:27 +0200 Subject: [PATCH] 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 Signed-off-by: Sascha Hauer --- commands/Kconfig | 9 ++++++++- commands/Makefile | 1 + commands/devinfo.c | 9 ++------- commands/drvinfo.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 8 deletions(-) create mode 100644 commands/drvinfo.c diff --git a/commands/Kconfig b/commands/Kconfig index 6043cb676..c3b40079f 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 030a9061a..a84d3339e 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 c229984c5..71c9bd4b9 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 000000000..161118a63 --- /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 +#include +#include + +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