From patchwork Tue Mar 24 15:17:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niel Fourie X-Patchwork-Id: 1260778 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=otU32is+; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48mvyN1gCfz9sP7 for ; Wed, 25 Mar 2020 02:18:04 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6787A81829; Tue, 24 Mar 2020 16:18:00 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1585063080; bh=kT3hx4byXXxrBQGuzg97jjP3w96ldDDtu7vaYmu5pR8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=otU32is+bNzgnY7qMKHapRbTLzYJUPEJjUCCKAQ0DJLSjiLZHm10wkjJ5m5YbjTGu PlSyM5bW1rHUOqakAoRFwgYb1lQNqwmwV3do4NW5OEEo8X6/1bfVhCJPL375qHpwI9 cuSa3B/bxvf3K72h0e/gqFjHE5r3zsekeAIPXbQaWCw5hIJo/pxFBighbPQrA4AeMJ spEZfVGpV/Tt3MMADFUSrBFiUZPcNj1xxh0ggKmzwvc1Why8aj/7FCafhD6pwnOcKN 8mO/cVxjMqukU/WMsnnfeZjwYR9A8aCpntXBkpvR8UP3sZJZUHbEoFZfyxDhb2UWzJ 19T5vj5hVQb0g== Received: by phobos.denx.de (Postfix, from userid 109) id 3D43C81829; Tue, 24 Mar 2020 16:17:55 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E1AB1817C3 for ; Tue, 24 Mar 2020 16:17:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=lusus@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 48mvy24Wt2z1qs3t; Tue, 24 Mar 2020 16:17:46 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 48mvy2463Yz1r0by; Tue, 24 Mar 2020 16:17:46 +0100 (CET) Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id 1MT11LrOIHKx; Tue, 24 Mar 2020 16:17:45 +0100 (CET) X-Auth-Info: w+Izy8RMEBgbOy4+B4urXEH0XSwW6/en6nyjN0uYWzo= Received: from aldebaran.denx.de (unknown [62.91.23.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Tue, 24 Mar 2020 16:17:45 +0100 (CET) From: Niel Fourie To: u-boot@lists.denx.de Cc: sjg@chromium.org, seanga2@gmail.com, Niel Fourie Subject: [PATCH v3 1/3] cmd: part: Add subcommand to list supported partition tables Date: Tue, 24 Mar 2020 16:17:03 +0100 Message-Id: <20200324151705.1798021-2-lusus@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200324151705.1798021-1-lusus@denx.de> References: <20200324151705.1798021-1-lusus@denx.de> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean Add a subcommand "types" to the part command, which lists the supported partition table types. Signed-off-by: Niel Fourie Cc: Simon Glass Reviewed-by: Simon Glass --- Changes in v2: - Add Python test Changes in v3: - none 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(": "); + 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 \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@denx.de + +import pytest + +@pytest.mark.buildconfigspec('cmd_part') +@pytest.mark.buildconfigspec('partitions') +@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 From patchwork Tue Mar 24 15:17:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niel Fourie X-Patchwork-Id: 1260779 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=WQ+8YjKz; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48mvyl5j5Rz9sQt for ; Wed, 25 Mar 2020 02:18:23 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D0526817D0; Tue, 24 Mar 2020 16:18:19 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1585063100; bh=ZPYsCv3t/lRykkZvMN+2EMvyOhPkUuaBgEkEC4rkvbc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=WQ+8YjKzM98yaO3HEcnWwS0785rN+XFkHVyTjnQldnBkR65g6B4eZxOtsIViRxBaX S4XpLZlz7wBbJzMmogPSGH2Vk4IKgoizykX/f/MIKk9oJZTn1huPrHnggxUpwvqa8V WTb5xNlpL7uY+Dx7UYxFPueEYkFoUXjuZoaynFC0AohmsblRYtlW/c9eLlip8LA64w KMGx27DCitoASUpdRCBR/3O22QJoaqySE767w20Ph2A8STyvQ3PA/Ao/68vvVINlRd pISgfRcs2lpZWknyFC4c/LLUSPbb037TWuvli9I5P/KTarncTpn6qvw2I/DDL17YVA H6VHp1vshxkig== Received: by phobos.denx.de (Postfix, from userid 109) id 80F9881827; Tue, 24 Mar 2020 16:18:15 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-out.m-online.net (mail-out.m-online.net [IPv6:2001:a60:0:28:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 148B381795 for ; Tue, 24 Mar 2020 16:18:05 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=lusus@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 48mvyN62Drz1tBxJ; Tue, 24 Mar 2020 16:18:04 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 48mvyN5Qvyz1r0c0; Tue, 24 Mar 2020 16:18:04 +0100 (CET) Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id v8XJndm-RvRq; Tue, 24 Mar 2020 16:18:03 +0100 (CET) X-Auth-Info: BtuHGRh2y5vWNZ0GYU4Co+mJu+boL43q0ETHBRoaNdU= Received: from aldebaran.denx.de (unknown [62.91.23.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Tue, 24 Mar 2020 16:18:03 +0100 (CET) From: Niel Fourie To: u-boot@lists.denx.de Cc: sjg@chromium.org, seanga2@gmail.com, Niel Fourie Subject: [PATCH v3 2/3] cmd: fs: Add command to list supported fs types Date: Tue, 24 Mar 2020 16:17:04 +0100 Message-Id: <20200324151705.1798021-3-lusus@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200324151705.1798021-1-lusus@denx.de> References: <20200324151705.1798021-1-lusus@denx.de> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean Added command "fstypes" to list supported/included filesystems. Signed-off-by: Niel Fourie Cc: Simon Glass Reviewed-by: Simon Glass --- Changes in v2: - Add Python test Changes in v3: - Rewrote comment for do_fs_types() in fs.h cmd/fs.c | 11 +++++++++++ fs/fs.c | 20 ++++++++++++++++++++ include/fs.h | 11 +++++++++++ test/py/tests/test_fs/test_fs_cmd.py | 12 ++++++++++++ 4 files changed, 54 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 : \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(": "); + puts("\n"); + return CMD_RET_SUCCESS; +} diff --git a/include/fs.h b/include/fs.h index 37e35c2120..514c248e50 100644 --- a/include/fs.h +++ b/include/fs.h @@ -254,4 +254,15 @@ 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[]); +/** + * do_fs_types - List supported filesystems. + * + * @cmdtp: Command information for fstypes + * @flag: Command flags (CMD_FLAG_...) + * @argc: Number of arguments + * @argv: List of arguments + * @return result (see enum command_ret_t) + */ +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@denx.de + +import pytest + +@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 From patchwork Tue Mar 24 15:17:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niel Fourie X-Patchwork-Id: 1260780 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=Ut7LPAIM; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48mvz32f8Gz9sP7 for ; Wed, 25 Mar 2020 02:18:39 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2565481827; Tue, 24 Mar 2020 16:18:36 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1585063116; bh=v8XK2LT5OQ5ygR41tO/MLmtnf13+HEf9YM3c5t742ZY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Ut7LPAIM35ZbLqo39GUNO3pAtXdETEF0huK+c19bVTFgOtfnbWMM9I9mJeSYGvyd9 MPYgTuzSnAKEcr5hGgJ6Eg5BIqFryG8RgBrm3IjUXEVs0uaxdLb93uTpXZQG7NZHIl wGok19G/A/MQ/kuIToyjjdzrfo3x2vYoFOeitmvAwQBsVgbXAZyjxADgSX+GLODFPV X+484lgWBQOVYKZmgLMeQFTC8RK1kqogQn+8W8YANYV5Rvhk0kEA5tmHpJpYMzGFPY /nLH5vFQPFUz+seYEmfaIobMhDd5nWlPFKk/QaOm8kYtk90q/S5mRyDls+Ne8uR11i oTxfh7cxdrAyg== Received: by phobos.denx.de (Postfix, from userid 109) id B271681850; Tue, 24 Mar 2020 16:18:27 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-out.m-online.net (mail-out.m-online.net [IPv6:2001:a60:0:28:0:1:25:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E6F7981836 for ; Tue, 24 Mar 2020 16:18:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=lusus@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 48mvyc3xkSz1rlhx; Tue, 24 Mar 2020 16:18:16 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 48mvyc3XcLz1r0c0; Tue, 24 Mar 2020 16:18:16 +0100 (CET) Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id vM-6ZnbdeTaf; Tue, 24 Mar 2020 16:18:14 +0100 (CET) X-Auth-Info: cCwAAW+Tq0rZe6CXzK0N92vXI/+usjUt2/pfHt65tEQ= Received: from aldebaran.denx.de (unknown [62.91.23.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Tue, 24 Mar 2020 16:18:14 +0100 (CET) From: Niel Fourie To: u-boot@lists.denx.de Cc: sjg@chromium.org, seanga2@gmail.com, Niel Fourie Subject: [PATCH v3 3/3] cmd: dm: Fixed/Added DM driver listing subcommands Date: Tue, 24 Mar 2020 16:17:05 +0100 Message-Id: <20200324151705.1798021-4-lusus@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200324151705.1798021-1-lusus@denx.de> References: <20200324151705.1798021-1-lusus@denx.de> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean 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 Cc: Simon Glass Cc: Sean Anderson Reviewed-by: Simon Glass --- 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 : ""); + + 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("\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 + +@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 + +@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