All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] cmd: add driver, fs and part type listing commands
@ 2020-03-19 16:13 Niel Fourie
  2020-03-19 16:13 ` [PATCH v2 1/3] cmd: part: Add subcommand to list supported partition tables Niel Fourie
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Niel Fourie @ 2020-03-19 16:13 UTC (permalink / raw)
  To: u-boot

This series adds commands for listing the supported partition tables,
listing supported filesystems and expands Driver Model listing commands.

The existing "dm drivers" command, which lists the DM drivers and their
compatibility strings, segmentation faulted on drivers for which of_match
was unpopulated (which appears to not be uncommon). This was fixed, and
the command was renamed "dm compat", and a new more extensive "dm drivers"
command was added, which list all DM drivers and for each, their uclass
id, uclass driver and the device names for active driver instances. The
purpose is show available drivers, but also to highlight unused drivers
or drivers with uclass ids without uclass drivers, etc.

The following commands were added:
-"part types", lists partition tables supported
-"fstypes", lists filesystem types supported
-"dm compat", lists drivers and their compatibility strings (equivalent
  to existing "dm drivers" command)
-"dm drivers", lists all DM drivers, and for each their uclass id,
  uclass driver and the device names for active driver instances.
-"dm static", lists all DM drivers which use static platform data
  (instead of the device tree).

These patches were tested in the Sandbox and on the Wandboard
i.MX6Quad Board rev B1.

Changes in v2:
- Rebased on https://patchwork.ozlabs.org/patch/1234460/
- Added Python tests
- Fixed minor typographical errors

Niel Fourie (3):
  cmd: part: Add subcommand to list supported partition tables
  cmd: fs: Add command to list supported fs types
  cmd: dm: Fixed/Added DM driver listing subcommands

 cmd/dm.c                             | 22 ++++++++++-
 cmd/fs.c                             | 11 ++++++
 cmd/part.c                           | 27 +++++++++++++-
 drivers/core/dump.c                  | 55 +++++++++++++++++++++++++++-
 fs/fs.c                              | 20 ++++++++++
 include/dm/util.h                    |  6 +++
 include/fs.h                         |  5 +++
 test/py/tests/test_dm.py             | 22 ++++++++++-
 test/py/tests/test_fs/test_fs_cmd.py | 12 ++++++
 test/py/tests/test_part.py           | 14 +++++++
 10 files changed, 188 insertions(+), 6 deletions(-)
 create mode 100644 test/py/tests/test_fs/test_fs_cmd.py
 create mode 100644 test/py/tests/test_part.py

-- 
2.25.1

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

* [PATCH v2 1/3] cmd: part: Add subcommand to list supported partition tables
  2020-03-19 16:13 [PATCH v2 0/3] cmd: add driver, fs and part type listing commands Niel Fourie
@ 2020-03-19 16:13 ` Niel Fourie
  2020-03-23 15:37   ` Simon Glass
  2020-03-19 16:13 ` [PATCH v2 2/3] cmd: fs: Add command to list supported fs types Niel Fourie
  2020-03-19 16:13 ` [PATCH v2 3/3] cmd: dm: Fixed/Added DM driver listing subcommands Niel Fourie
  2 siblings, 1 reply; 9+ messages in thread
From: Niel Fourie @ 2020-03-19 16:13 UTC (permalink / raw)
  To: u-boot

Add a subcommand "types" to the part command, which lists the supported
partition table types.

Signed-off-by: Niel Fourie <lusus@denx.de>
CC: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Add Python test

 cmd/part.c                 | 27 +++++++++++++++++++++++++--
 test/py/tests/test_part.py | 14 ++++++++++++++
 2 files changed, 39 insertions(+), 2 deletions(-)
 create mode 100644 test/py/tests/test_part.py

diff --git a/cmd/part.c b/cmd/part.c
index 5e4e45ca6d..fae5df7b71 100644
--- a/cmd/part.c
+++ b/cmd/part.c
@@ -182,6 +182,26 @@ static int do_part_number(int argc, char * const argv[])
 	return do_part_info(argc, argv, CMD_PART_INFO_NUMBER);
 }
 
+static int do_part_types(int argc, char * const argv[])
+{
+	struct part_driver *drv = ll_entry_start(struct part_driver,
+						 part_driver);
+	const int n_ents = ll_entry_count(struct part_driver, part_driver);
+	struct part_driver *entry;
+	int i = 0;
+
+	puts("Supported partition tables");
+
+	for (entry = drv; entry != drv + n_ents; entry++) {
+		printf("%c %s", i ? ',' : ':', entry->name);
+		i++;
+	}
+	if (!i)
+		puts(": <none>");
+	puts("\n");
+	return CMD_RET_SUCCESS;
+}
+
 static int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	if (argc < 2)
@@ -197,7 +217,8 @@ static int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		return do_part_size(argc - 2, argv + 2);
 	else if (!strcmp(argv[1], "number"))
 		return do_part_number(argc - 2, argv + 2);
-
+	else if (!strcmp(argv[1], "types"))
+		return do_part_types(argc - 2, argv + 2);
 	return CMD_RET_USAGE;
 }
 
@@ -221,5 +242,7 @@ U_BOOT_CMD(
 	"      part can be either partition number or partition name\n"
 	"part number <interface> <dev> <part> <varname>\n"
 	"    - set environment variable to the partition number using the partition name\n"
-	"      part must be specified as partition name"
+	"      part must be specified as partition name\n"
+	"part types\n"
+	"    - list supported partition table types"
 );
diff --git a/test/py/tests/test_part.py b/test/py/tests/test_part.py
new file mode 100644
index 0000000000..cba9804510
--- /dev/null
+++ b/test/py/tests/test_part.py
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2020
+# Niel Fourie, DENX Software Engineering, lusus at denx.de
+
+import pytest
+
+ at pytest.mark.buildconfigspec('cmd_part')
+ at pytest.mark.buildconfigspec('partitions')
+ at pytest.mark.buildconfigspec('efi_partition')
+def test_dm_compat(u_boot_console):
+    """Test that `part types` prints a result which includes `EFI`."""
+    output = u_boot_console.run_command('part types')
+    assert "Supported partition tables:" in output
+    assert "EFI" in output
-- 
2.25.1

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

* [PATCH v2 2/3] cmd: fs: Add command to list supported fs types
  2020-03-19 16:13 [PATCH v2 0/3] cmd: add driver, fs and part type listing commands Niel Fourie
  2020-03-19 16:13 ` [PATCH v2 1/3] cmd: part: Add subcommand to list supported partition tables Niel Fourie
@ 2020-03-19 16:13 ` Niel Fourie
  2020-03-23 15:37   ` Simon Glass
  2020-03-19 16:13 ` [PATCH v2 3/3] cmd: dm: Fixed/Added DM driver listing subcommands Niel Fourie
  2 siblings, 1 reply; 9+ messages in thread
From: Niel Fourie @ 2020-03-19 16:13 UTC (permalink / raw)
  To: u-boot

Added command "fstypes" to list supported/included filesystems.

Signed-off-by: Niel Fourie <lusus@denx.de>
CC: Simon Glass <sjg@chromium.org>
---
Changes in v2:
- Add Python test

 cmd/fs.c                             | 11 +++++++++++
 fs/fs.c                              | 20 ++++++++++++++++++++
 include/fs.h                         |  5 +++++
 test/py/tests/test_fs/test_fs_cmd.py | 12 ++++++++++++
 4 files changed, 48 insertions(+)
 create mode 100644 test/py/tests/test_fs/test_fs_cmd.py

diff --git a/cmd/fs.c b/cmd/fs.c
index db74767b7b..26b47bd001 100644
--- a/cmd/fs.c
+++ b/cmd/fs.c
@@ -99,3 +99,14 @@ U_BOOT_CMD(
 	"fstype <interface> <dev>:<part> <varname>\n"
 	"- set environment variable to filesystem type\n"
 );
+
+static int do_fstypes_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
+			      char * const argv[])
+{
+	return do_fs_types(cmdtp, flag, argc, argv);
+}
+
+U_BOOT_CMD(
+	fstypes, 1, 1, do_fstypes_wrapper,
+	"List supported filesystem types", ""
+);
diff --git a/fs/fs.c b/fs/fs.c
index 0c66d60477..3e38b2e27a 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -900,3 +900,23 @@ int do_ln(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
 
 	return 0;
 }
+
+int do_fs_types(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	struct fstype_info *drv = fstypes;
+	const int n_ents = ARRAY_SIZE(fstypes);
+	struct fstype_info *entry;
+	int i = 0;
+
+	puts("Supported filesystems");
+	for (entry = drv; entry != drv + n_ents; entry++) {
+		if (entry->fstype != FS_TYPE_ANY) {
+			printf("%c %s", i ? ',' : ':', entry->name);
+			i++;
+		}
+	}
+	if (!i)
+		puts(": <none>");
+	puts("\n");
+	return CMD_RET_SUCCESS;
+}
diff --git a/include/fs.h b/include/fs.h
index 37e35c2120..b3fd0b179d 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -254,4 +254,9 @@ int do_fs_uuid(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
  */
 int do_fs_type(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 
+/*
+ * List supported filesystems.
+ */
+int do_fs_types(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
+
 #endif /* _FS_H */
diff --git a/test/py/tests/test_fs/test_fs_cmd.py b/test/py/tests/test_fs/test_fs_cmd.py
new file mode 100644
index 0000000000..86ba92e025
--- /dev/null
+++ b/test/py/tests/test_fs/test_fs_cmd.py
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2020
+# Niel Fourie, DENX Software Engineering, lusus at denx.de
+
+import pytest
+
+ at pytest.mark.buildconfigspec('cmd_fs_generic')
+def test_dm_compat(u_boot_console):
+    """Test that `fstypes` prints a result which includes `sandbox`."""
+    output = u_boot_console.run_command('fstypes')
+    assert "Supported filesystems:" in output
+    assert "sandbox" in output
-- 
2.25.1

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

* [PATCH v2 3/3] cmd: dm: Fixed/Added DM driver listing subcommands
  2020-03-19 16:13 [PATCH v2 0/3] cmd: add driver, fs and part type listing commands Niel Fourie
  2020-03-19 16:13 ` [PATCH v2 1/3] cmd: part: Add subcommand to list supported partition tables Niel Fourie
  2020-03-19 16:13 ` [PATCH v2 2/3] cmd: fs: Add command to list supported fs types Niel Fourie
@ 2020-03-19 16:13 ` Niel Fourie
  2020-03-19 18:37   ` Sean Anderson
  2020-03-23 15:37   ` Simon Glass
  2 siblings, 2 replies; 9+ messages in thread
From: Niel Fourie @ 2020-03-19 16:13 UTC (permalink / raw)
  To: u-boot

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>
---
Depends on: https://patchwork.ozlabs.org/patch/1234460/

Changes in v2:
- Add/extend Python tests
- Fixed minor formatting/typographical errors

 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

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

* [PATCH v2 3/3] cmd: dm: Fixed/Added DM driver listing subcommands
  2020-03-19 16:13 ` [PATCH v2 3/3] cmd: dm: Fixed/Added DM driver listing subcommands Niel Fourie
@ 2020-03-19 18:37   ` Sean Anderson
  2020-03-20  9:53     ` Niel Fourie
  2020-03-23 15:37   ` Simon Glass
  1 sibling, 1 reply; 9+ messages in thread
From: Sean Anderson @ 2020-03-19 18:37 UTC (permalink / raw)
  To: u-boot

On 3/19/20 12:13 PM, Niel Fourie wrote:
> 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>
> ---
> Depends on: https://patchwork.ozlabs.org/patch/1234460/
> 
> Changes in v2:
> - Add/extend Python tests
> - Fixed minor formatting/typographical errors
> 
>  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
> +

Why is the above marked as being added? These lines are present in the
patch which adds the original test.

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

--Sean

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

* [PATCH v2 3/3] cmd: dm: Fixed/Added DM driver listing subcommands
  2020-03-19 18:37   ` Sean Anderson
@ 2020-03-20  9:53     ` Niel Fourie
  0 siblings, 0 replies; 9+ messages in thread
From: Niel Fourie @ 2020-03-20  9:53 UTC (permalink / raw)
  To: u-boot

Hi Sean,

On 3/19/20 7:37 PM, Sean Anderson wrote:
<snip>
>> 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
>> +
> 
> Why is the above marked as being added? These lines are present in the
> patch which adds the original test.
> 

Well spotted! I had to give it a second look before I grasped what 
happened there... My tests were all based on yours, and it turns out 
that the last 4 lines of my last test, test_dm_static(), exactly matches 
those 4 lines in your original patch. And as I had changed the command 
to run in your test from "dm driver" to "dm compat", git decided to just 
insert all of my changes in one block in the middle of what was 
originally your test. At the bottom of the patch you can still see your 
original code:

+ 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

Best regards,
Niel Fourie

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-21 Fax: +49-8142-66989-80  Email: lusus at denx.de

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

* [PATCH v2 1/3] cmd: part: Add subcommand to list supported partition tables
  2020-03-19 16:13 ` [PATCH v2 1/3] cmd: part: Add subcommand to list supported partition tables Niel Fourie
@ 2020-03-23 15:37   ` Simon Glass
  0 siblings, 0 replies; 9+ messages in thread
From: Simon Glass @ 2020-03-23 15:37 UTC (permalink / raw)
  To: u-boot

On Thu, 19 Mar 2020 at 10:14, Niel Fourie <lusus@denx.de> wrote:
>
> Add a subcommand "types" to the part command, which lists the supported
> partition table types.
>
> Signed-off-by: Niel Fourie <lusus@denx.de>
> CC: Simon Glass <sjg@chromium.org>
> ---
> Changes in v2:
> - Add Python test
>
>  cmd/part.c                 | 27 +++++++++++++++++++++++++--
>  test/py/tests/test_part.py | 14 ++++++++++++++
>  2 files changed, 39 insertions(+), 2 deletions(-)
>  create mode 100644 test/py/tests/test_part.py

Reviewed-by: Simon Glass <sjg@chromium.org>

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

* [PATCH v2 2/3] cmd: fs: Add command to list supported fs types
  2020-03-19 16:13 ` [PATCH v2 2/3] cmd: fs: Add command to list supported fs types Niel Fourie
@ 2020-03-23 15:37   ` Simon Glass
  0 siblings, 0 replies; 9+ messages in thread
From: Simon Glass @ 2020-03-23 15:37 UTC (permalink / raw)
  To: u-boot

Hi Neil,

On Thu, 19 Mar 2020 at 10:14, Niel Fourie <lusus@denx.de> wrote:
>
> Added command "fstypes" to list supported/included filesystems.
>
> Signed-off-by: Niel Fourie <lusus@denx.de>
> CC: Simon Glass <sjg@chromium.org>
> ---
> Changes in v2:
> - Add Python test
>
>  cmd/fs.c                             | 11 +++++++++++
>  fs/fs.c                              | 20 ++++++++++++++++++++
>  include/fs.h                         |  5 +++++
>  test/py/tests/test_fs/test_fs_cmd.py | 12 ++++++++++++
>  4 files changed, 48 insertions(+)
>  create mode 100644 test/py/tests/test_fs/test_fs_cmd.py

Reviewed-by: Simon Glass <sjg@chromium.org>

But please see below

>
> diff --git a/cmd/fs.c b/cmd/fs.c
> index db74767b7b..26b47bd001 100644
> --- a/cmd/fs.c
> +++ b/cmd/fs.c
> @@ -99,3 +99,14 @@ U_BOOT_CMD(
>         "fstype <interface> <dev>:<part> <varname>\n"
>         "- set environment variable to filesystem type\n"
>  );
> +
> +static int do_fstypes_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
> +                             char * const argv[])
> +{
> +       return do_fs_types(cmdtp, flag, argc, argv);
> +}
> +
> +U_BOOT_CMD(
> +       fstypes, 1, 1, do_fstypes_wrapper,
> +       "List supported filesystem types", ""
> +);
> diff --git a/fs/fs.c b/fs/fs.c
> index 0c66d60477..3e38b2e27a 100644
> --- a/fs/fs.c
> +++ b/fs/fs.c
> @@ -900,3 +900,23 @@ int do_ln(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
>
>         return 0;
>  }
> +
> +int do_fs_types(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> +{
> +       struct fstype_info *drv = fstypes;
> +       const int n_ents = ARRAY_SIZE(fstypes);
> +       struct fstype_info *entry;
> +       int i = 0;
> +
> +       puts("Supported filesystems");
> +       for (entry = drv; entry != drv + n_ents; entry++) {
> +               if (entry->fstype != FS_TYPE_ANY) {
> +                       printf("%c %s", i ? ',' : ':', entry->name);
> +                       i++;
> +               }
> +       }
> +       if (!i)
> +               puts(": <none>");
> +       puts("\n");
> +       return CMD_RET_SUCCESS;
> +}
> diff --git a/include/fs.h b/include/fs.h
> index 37e35c2120..b3fd0b179d 100644
> --- a/include/fs.h
> +++ b/include/fs.h
> @@ -254,4 +254,9 @@ int do_fs_uuid(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
>   */
>  int do_fs_type(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
>
> +/*
> + * List supported filesystems.
> + */
> +int do_fs_types(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);

Please add a full function comment - see do_ext2load()

Regards,
Simon

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

* [PATCH v2 3/3] cmd: dm: Fixed/Added DM driver listing subcommands
  2020-03-19 16:13 ` [PATCH v2 3/3] cmd: dm: Fixed/Added DM driver listing subcommands Niel Fourie
  2020-03-19 18:37   ` Sean Anderson
@ 2020-03-23 15:37   ` Simon Glass
  1 sibling, 0 replies; 9+ messages in thread
From: Simon Glass @ 2020-03-23 15:37 UTC (permalink / raw)
  To: u-boot

On Thu, 19 Mar 2020 at 10:14, Niel Fourie <lusus@denx.de> wrote:
>
> 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>
> ---
> Depends on: https://patchwork.ozlabs.org/patch/1234460/
>
> Changes in v2:
> - Add/extend Python tests
> - Fixed minor formatting/typographical errors
>
>  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(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

I'm not quite sold on the name 'static' here, but I suppose it makes sense.

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

end of thread, other threads:[~2020-03-23 15:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-19 16:13 [PATCH v2 0/3] cmd: add driver, fs and part type listing commands Niel Fourie
2020-03-19 16:13 ` [PATCH v2 1/3] cmd: part: Add subcommand to list supported partition tables Niel Fourie
2020-03-23 15:37   ` Simon Glass
2020-03-19 16:13 ` [PATCH v2 2/3] cmd: fs: Add command to list supported fs types Niel Fourie
2020-03-23 15:37   ` Simon Glass
2020-03-19 16:13 ` [PATCH v2 3/3] cmd: dm: Fixed/Added DM driver listing subcommands Niel Fourie
2020-03-19 18:37   ` Sean Anderson
2020-03-20  9:53     ` Niel Fourie
2020-03-23 15:37   ` 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.