From: Niel Fourie <lusus@denx.de>
To: u-boot@lists.denx.de
Subject: [PATCH v3 3/3] cmd: dm: Fixed/Added DM driver listing subcommands
Date: Tue, 24 Mar 2020 16:17:05 +0100 [thread overview]
Message-ID: <20200324151705.1798021-4-lusus@denx.de> (raw)
In-Reply-To: <20200324151705.1798021-1-lusus@denx.de>
Renamed dm "drivers" subcommand to "compat" (as it listed
compatibility strings) and prevent it from segfaulting when
drivers have no of_match populated.
Added a new "drivers" subcommand to dump a list of all known DM
drivers and for each, their uclass id, uclass driver and names of
attached devices.
Added a new "static" subcommand to dump a list of DM drivers with
statically defined platform data.
Signed-off-by: Niel Fourie <lusus@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
Depends on: https://patchwork.ozlabs.org/patch/1234460/
Changes in v2:
- Add/extend Python tests
- Fixed minor formatting/typographical errors
Changes in v3:
- none
cmd/dm.c | 22 +++++++++++++++-
drivers/core/dump.c | 55 +++++++++++++++++++++++++++++++++++++++-
include/dm/util.h | 6 +++++
test/py/tests/test_dm.py | 22 ++++++++++++++--
4 files changed, 101 insertions(+), 4 deletions(-)
diff --git a/cmd/dm.c b/cmd/dm.c
index 7a90685f8b..fa7eba6a17 100644
--- a/cmd/dm.c
+++ b/cmd/dm.c
@@ -48,11 +48,29 @@ static int do_dm_dump_drivers(cmd_tbl_t *cmdtp, int flag, int argc,
return 0;
}
+static int do_dm_dump_driver_compat(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
+{
+ dm_dump_driver_compat();
+
+ return 0;
+}
+
+static int do_dm_dump_static_driver_info(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
+{
+ dm_dump_static_driver_info();
+
+ return 0;
+}
+
static cmd_tbl_t test_commands[] = {
U_BOOT_CMD_MKENT(tree, 0, 1, do_dm_dump_all, "", ""),
U_BOOT_CMD_MKENT(uclass, 1, 1, do_dm_dump_uclass, "", ""),
U_BOOT_CMD_MKENT(devres, 1, 1, do_dm_dump_devres, "", ""),
U_BOOT_CMD_MKENT(drivers, 1, 1, do_dm_dump_drivers, "", ""),
+ U_BOOT_CMD_MKENT(compat, 1, 1, do_dm_dump_driver_compat, "", ""),
+ U_BOOT_CMD_MKENT(static, 1, 1, do_dm_dump_static_driver_info, "", ""),
};
static __maybe_unused void dm_reloc(void)
@@ -94,5 +112,7 @@ U_BOOT_CMD(
"tree Dump driver model tree ('*' = activated)\n"
"dm uclass Dump list of instances for each uclass\n"
"dm devres Dump list of device resources for each device\n"
- "dm drivers Dump list of drivers and their compatible strings"
+ "dm drivers Dump list of drivers with uclass and instances\n"
+ "dm compat Dump list of drivers with compatibility strings\n"
+ "dm static Dump list of drivers with static platform data"
);
diff --git a/drivers/core/dump.c b/drivers/core/dump.c
index b5046398d4..e96d59f861 100644
--- a/drivers/core/dump.c
+++ b/drivers/core/dump.c
@@ -97,7 +97,7 @@ void dm_dump_uclass(void)
}
}
-void dm_dump_drivers(void)
+void dm_dump_driver_compat(void)
{
struct driver *d = ll_entry_start(struct driver, driver);
const int n_ents = ll_entry_count(struct driver, driver);
@@ -116,3 +116,56 @@ void dm_dump_drivers(void)
printf("%-20.20s\n", entry->name);
}
}
+
+void dm_dump_drivers(void)
+{
+ struct driver *d = ll_entry_start(struct driver, driver);
+ const int n_ents = ll_entry_count(struct driver, driver);
+ struct driver *entry;
+ struct udevice *udev;
+ struct uclass *uc;
+ int i;
+
+ puts("Driver uid uclass Devices\n");
+ puts("----------------------------------------------------------\n");
+
+ for (entry = d; entry < d + n_ents; entry++) {
+ uclass_get(entry->id, &uc);
+
+ printf("%-25.25s %-3.3d %-20.20s ", entry->name, entry->id,
+ uc ? uc->uc_drv->name : "<no uclass>");
+
+ if (!uc) {
+ puts("\n");
+ continue;
+ }
+
+ i = 0;
+ uclass_foreach_dev(udev, uc) {
+ if (udev->driver != entry)
+ continue;
+ if (i)
+ printf("%-51.51s", "");
+
+ printf("%-25.25s\n", udev->name);
+ i++;
+ }
+ if (!i)
+ puts("<none>\n");
+ }
+}
+
+void dm_dump_static_driver_info(void)
+{
+ struct driver_info *drv = ll_entry_start(struct driver_info,
+ driver_info);
+ const int n_ents = ll_entry_count(struct driver_info, driver_info);
+ struct driver_info *entry;
+
+ puts("Driver Address\n");
+ puts("---------------------------------\n");
+ for (entry = drv; entry != drv + n_ents; entry++) {
+ printf("%-25.25s @%08lx\n", entry->name,
+ (ulong)map_to_sysmem(entry->platdata));
+ }
+}
diff --git a/include/dm/util.h b/include/dm/util.h
index 0ccb3fbadf..974347ce0b 100644
--- a/include/dm/util.h
+++ b/include/dm/util.h
@@ -42,6 +42,12 @@ static inline void dm_dump_devres(void)
/* Dump out a list of drivers */
void dm_dump_drivers(void);
+/* Dump out a list with each driver's compatibility strings */
+void dm_dump_driver_compat(void);
+
+/* Dump out a list of drivers with static platform data */
+void dm_dump_static_driver_info(void);
+
/**
* Check if an of node should be or was bound before relocation.
*
diff --git a/test/py/tests/test_dm.py b/test/py/tests/test_dm.py
index f6fbf8ba4c..97203b536e 100644
--- a/test/py/tests/test_dm.py
+++ b/test/py/tests/test_dm.py
@@ -4,14 +4,32 @@
import pytest
@pytest.mark.buildconfigspec('cmd_dm')
-def test_dm_drivers(u_boot_console):
- """Test that each driver in `dm tree` is also listed in `dm drivers`."""
+def test_dm_compat(u_boot_console):
+ """Test that each driver in `dm tree` is also listed in `dm compat`."""
response = u_boot_console.run_command('dm tree')
driver_index = response.find('Driver')
assert driver_index != -1
drivers = (line[driver_index:].split()[0]
for line in response[:-1].split('\n')[2:])
+ response = u_boot_console.run_command('dm compat')
+ for driver in drivers:
+ assert driver in response
+
+ at pytest.mark.buildconfigspec('cmd_dm')
+def test_dm_drivers(u_boot_console):
+ """Test that each driver in `dm compat` is also listed in `dm drivers`."""
+ response = u_boot_console.run_command('dm compat')
+ drivers = (line[:20].rstrip() for line in response[:-1].split('\n')[2:])
+ response = u_boot_console.run_command('dm drivers')
+ for driver in drivers:
+ assert driver in response
+
+ at pytest.mark.buildconfigspec('cmd_dm')
+def test_dm_static(u_boot_console):
+ """Test that each driver in `dm static` is also listed in `dm drivers`."""
+ response = u_boot_console.run_command('dm static')
+ drivers = (line[:25].rstrip() for line in response[:-1].split('\n')[2:])
response = u_boot_console.run_command('dm drivers')
for driver in drivers:
assert driver in response
--
2.25.1
next prev parent reply other threads:[~2020-03-24 15:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-24 15:17 [PATCH v3 0/3] cmd: add driver, fs and part type listing commands Niel Fourie
2020-03-24 15:17 ` [PATCH v3 1/3] cmd: part: Add subcommand to list supported partition tables Niel Fourie
2020-07-08 3:01 ` Tom Rini
2020-03-24 15:17 ` [PATCH v3 2/3] cmd: fs: Add command to list supported fs types Niel Fourie
2020-07-08 3:02 ` Tom Rini
2020-03-24 15:17 ` Niel Fourie [this message]
2020-07-08 3:02 ` [PATCH v3 3/3] cmd: dm: Fixed/Added DM driver listing subcommands Tom Rini
2020-05-26 7:57 ` [PATCH v3 0/3] cmd: add driver, fs and part type listing commands Wolfgang Denk
2020-05-26 19:24 ` Tom Rini
2020-05-31 14:07 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200324151705.1798021-4-lusus@denx.de \
--to=lusus@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.