9
0
Fork 0

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>
This commit is contained in:
Holger Schurig 2014-05-30 11:07:27 +02:00 committed by Sascha Hauer
parent 4d1ebec9da
commit c19c0da71c
4 changed files with 58 additions and 8 deletions

View File

@ -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

View File

@ -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

View File

@ -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)

47
commands/drvinfo.c Normal file
View File

@ -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