
Hi,
On Wed, 30 Aug 2023 at 22:34, AKASHI Takahiro takahiro.akashi@linaro.org wrote:
On Wed, Aug 30, 2023 at 09:48:48PM -0600, Simon Glass wrote:
Hi AKASHI,
On Tue, 22 Aug 2023 at 19:50, AKASHI Takahiro takahiro.akashi@linaro.org wrote:
The output from "dm tree" or "dm uclass" is a bit annoying if the number of devices available on the system is huge. (This is especially true on sandbox when I debug some DM code.)
With this patch, we can specify the uclass name or the device name that we are interested in in order to limit the output.
For instance,
=> dm uclass usb uclass 121: usb 0 usb@1 @ 0bcff8b0, seq 1
uclass 124: usb
=> dm tree usb:usb@1 Class Index Probed Driver Name
usb 0 [ ] usb_sandbox usb@1 usb_hub 0 [ ] usb_hub `-- hub usb_emul 0 [ ] usb_sandbox_hub `-- hub-emul usb_emul 1 [ ] usb_sandbox_flash |-- flash-stick@0 usb_emul 2 [ ] usb_sandbox_flash |-- flash-stick@1 usb_emul 3 [ ] usb_sandbox_flash |-- flash-stick@2 usb_emul 4 [ ] usb_sandbox_keyb `-- keyb@3
If you want forward-matching against a uclass or udevice name, you can specify "-e" option.
I don't really know what 'forward matching' means.
Really? I believed that forward-matching was a common word. I meant that it searches for any string starting with a specific sub-string. In other words, it would be "^<sub-string>" in a regular expression. So, for example, "usb" should match with "usbABC", "usb-DEF", "usb_GHI" and so on, but not match with "ABCusb".
Please use forward instead of forword in the code
Well let's just go with what you have. We can always tweak it when people start using it, if needed.
=> dm uclass -e usb uclass 15: usb_emul 0 hub-emul @ 0bcffb00, seq 0 1 flash-stick@0 @ 0bcffc30, seq 1 2 flash-stick@1 @ 0bcffdc0, seq 2 3 flash-stick@2 @ 0bcfff50, seq 3 4 keyb@3 @ 0bd000e0, seq 4
uclass 64: usb_mass_storage
uclass 121: usb 0 usb@1 @ 0bcff8b0, seq 1
uclass 122: usb_dev_generic
uclass 123: usb_hub 0 hub @ 0bcff9b0, seq 0
uclass 124: usb
=> dm tree -e usb Class Index Probed Driver Name
usb 0 [ ] usb_sandbox usb@1 usb_hub 0 [ ] usb_hub `-- hub usb_emul 0 [ ] usb_sandbox_hub `-- hub-emul usb_emul 1 [ ] usb_sandbox_flash |-- flash-stick@0 usb_emul 2 [ ] usb_sandbox_flash |-- flash-stick@1 usb_emul 3 [ ] usb_sandbox_flash |-- flash-stick@2 usb_emul 4 [ ] usb_sandbox_keyb `-- keyb@3
Signed-off-by: AKASHI Takahiro takahiro.akashi@linaro.org
v2
- allow for forward-matching against the name
- update command doc
cmd/dm.c | 48 ++++++++++++++---- doc/usage/cmd/dm.rst | 30 ++++++++++- drivers/core/dump.c | 116 ++++++++++++++++++++++++++++++++----------- include/dm/util.h | 15 ++++-- 4 files changed, 165 insertions(+), 44 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
Thanks for doing this. It will be a big time-saver. I also wonder if it would be better if the default were to do a substring search and
Initially, I implemented so, but felt it is annoying to see (sometimes many) unexpected matched devices, especially when you know the exact name of device. See my example "dm uclass -e usb".
you have to add a flag to search for a single device?
Does 'single' mean the first matched word or exactly-same one?
Either way, I don't have a strong opinion here, though.
Thanks, -Takahiro Akashi
See below
Applied to u-boot-dm/next, thanks!