All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] cmd: Add command to dump drivers and compatible strings
@ 2020-02-03 20:51 Sean Anderson
  2020-02-04  9:54 ` Bin Meng
  2020-02-05 17:59 ` Simon Glass
  0 siblings, 2 replies; 3+ messages in thread
From: Sean Anderson @ 2020-02-03 20:51 UTC (permalink / raw)
  To: u-boot

This adds a subcommand to dm to dump out what drivers are installed, and their
compatible strings. I have found this useful in ensuring that I have the correct
drivers compiled, and that I have put in the correct compatible strings.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
---
  Changes for v2:
  - Check if entry->of_match is NULL before accessing it

 cmd/dm.c            | 12 +++++++++++-
 drivers/core/dump.c | 20 ++++++++++++++++++++
 include/dm/util.h   |  3 +++
 3 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/cmd/dm.c b/cmd/dm.c
index 7b271db0bb..7a90685f8b 100644
--- a/cmd/dm.c
+++ b/cmd/dm.c
@@ -40,10 +40,19 @@ static int do_dm_dump_devres(cmd_tbl_t *cmdtp, int flag, int argc,
 	return 0;
 }
 
+static int do_dm_dump_drivers(cmd_tbl_t *cmdtp, int flag, int argc,
+			      char * const argv[])
+{
+	dm_dump_drivers();
+
+	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, "", ""),
 };
 
 static __maybe_unused void dm_reloc(void)
@@ -84,5 +93,6 @@ U_BOOT_CMD(
 	"Driver model low level access",
 	"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"
+	"dm devres        Dump list of device resources for each device\n"
+	"dm drivers       Dump list of drivers and their compatible strings"
 );
diff --git a/drivers/core/dump.c b/drivers/core/dump.c
index 4704049aee..b5046398d4 100644
--- a/drivers/core/dump.c
+++ b/drivers/core/dump.c
@@ -96,3 +96,23 @@ void dm_dump_uclass(void)
 		puts("\n");
 	}
 }
+
+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;
+	const struct udevice_id *match;
+
+	puts("Driver                Compatible\n");
+	puts("--------------------------------\n");
+	for (entry = d; entry < d + n_ents; entry++) {
+		for (match = entry->of_match;
+		     match && match->compatible; match++)
+			printf("%-20.20s  %s\n",
+			       match == entry->of_match ? entry->name : "",
+			       match->compatible);
+		if (match == entry->of_match)
+			printf("%-20.20s\n", entry->name);
+	}
+}
diff --git a/include/dm/util.h b/include/dm/util.h
index 348c2ace3c..0ccb3fbadf 100644
--- a/include/dm/util.h
+++ b/include/dm/util.h
@@ -39,6 +39,9 @@ static inline void dm_dump_devres(void)
 }
 #endif
 
+/* Dump out a list of drivers */
+void dm_dump_drivers(void);
+
 /**
  * Check if an of node should be or was bound before relocation.
  *
-- 
2.25.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v2] cmd: Add command to dump drivers and compatible strings
  2020-02-03 20:51 [PATCH v2] cmd: Add command to dump drivers and compatible strings Sean Anderson
@ 2020-02-04  9:54 ` Bin Meng
  2020-02-05 17:59 ` Simon Glass
  1 sibling, 0 replies; 3+ messages in thread
From: Bin Meng @ 2020-02-04  9:54 UTC (permalink / raw)
  To: u-boot

On Tue, Feb 4, 2020 at 4:51 AM Sean Anderson <seanga2@gmail.com> wrote:
>
> This adds a subcommand to dm to dump out what drivers are installed, and their
> compatible strings. I have found this useful in ensuring that I have the correct
> drivers compiled, and that I have put in the correct compatible strings.
>
> Signed-off-by: Sean Anderson <seanga2@gmail.com>
> ---
>   Changes for v2:
>   - Check if entry->of_match is NULL before accessing it
>
>  cmd/dm.c            | 12 +++++++++++-
>  drivers/core/dump.c | 20 ++++++++++++++++++++
>  include/dm/util.h   |  3 +++
>  3 files changed, 34 insertions(+), 1 deletion(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2] cmd: Add command to dump drivers and compatible strings
  2020-02-03 20:51 [PATCH v2] cmd: Add command to dump drivers and compatible strings Sean Anderson
  2020-02-04  9:54 ` Bin Meng
@ 2020-02-05 17:59 ` Simon Glass
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Glass @ 2020-02-05 17:59 UTC (permalink / raw)
  To: u-boot

Hi Sean,

On Mon, 3 Feb 2020 at 13:51, Sean Anderson <seanga2@gmail.com> wrote:
>
> This adds a subcommand to dm to dump out what drivers are installed, and their
> compatible strings. I have found this useful in ensuring that I have the correct
> drivers compiled, and that I have put in the correct compatible strings.
>
> Signed-off-by: Sean Anderson <seanga2@gmail.com>
> ---
>   Changes for v2:
>   - Check if entry->of_match is NULL before accessing it
>
>  cmd/dm.c            | 12 +++++++++++-
>  drivers/core/dump.c | 20 ++++++++++++++++++++
>  include/dm/util.h   |  3 +++
>  3 files changed, 34 insertions(+), 1 deletion(-)

Looks good. Please can you add a test?

If it helps u-boot-dm/.testing has 'test: Add a way to check each line
of console output' so you can write it in C.

Regards,
Simon

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-02-05 17:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-03 20:51 [PATCH v2] cmd: Add command to dump drivers and compatible strings Sean Anderson
2020-02-04  9:54 ` Bin Meng
2020-02-05 17:59 ` Simon Glass

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.