From patchwork Wed Oct 28 10:06:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick DELAUNAY X-Patchwork-Id: 1389219 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=pass (p=none dis=none) header.from=st.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=st.com header.i=@st.com header.a=rsa-sha256 header.s=STMicroelectronics header.b=dmoeerXU; 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 4CLkkv6y3bz9sVW for ; Wed, 28 Oct 2020 21:06:59 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 381A0823E3; Wed, 28 Oct 2020 11:06:49 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=st.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=st.com header.i=@st.com header.b="dmoeerXU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B234C82423; Wed, 28 Oct 2020 11:06:47 +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=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) (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 1471B823DD for ; Wed, 28 Oct 2020 11:06:44 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=st.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=patrick.delaunay@st.com Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 09SA2wOE011277; Wed, 28 Oct 2020 11:06:43 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=STMicroelectronics; bh=qHyNyTmdfmzMzPseac1jxTVeZEXhfbkiAk8XFbCF1fI=; b=dmoeerXUG3qUWsGNUH8dR4fk8PCfRXxffWGayFAEOWDZNjlU670B6DwVTBvSDXqL2NOW nm0C1Hdt0MuWNZxjM0L/RaqoODxUVAH6RXLahQS+A7sqtoEtpcXOfbL3faNymZB4K8yT k2R+RW3/peUG+ie8tq1getw6Ellut1FTT0/I+9yL6mnAx5FTqEOB0+oF77H1/2dm7bl7 5TWk3TJVY0XJVZgk0+I109xyoXomwbKQvWsOcSIO+nqi6oqF24QOL2kDVBT4WH0Qd1+Y ZoBuMgY5Vm4HTxnjpC6U7qRVlCErxk6/We58dnx4ED6ipl1CwMeIi7cUrmuSolpALteN JQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 34ccffh2th-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Oct 2020 11:06:43 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 8F1EE10002A; Wed, 28 Oct 2020 11:06:42 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 801D12A69C7; Wed, 28 Oct 2020 11:06:42 +0100 (CET) Received: from localhost (10.75.127.49) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 28 Oct 2020 11:06:42 +0100 From: Patrick Delaunay To: CC: Patrick Delaunay , Sean Anderson , Simon Glass , U-Boot STM32 Subject: [PATCH 1/2] cmd: pinmux: update result of do_status Date: Wed, 28 Oct 2020 11:06:39 +0100 Message-ID: <20201028100640.13876-1-patrick.delaunay@st.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.75.127.49] X-ClientProxiedBy: SFHDAG7NODE2.st.com (10.75.127.20) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312, 18.0.737 definitions=2020-10-28_04:2020-10-26, 2020-10-28 signatures=0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.3 at phobos.denx.de X-Virus-Status: Clean Update the result of do_status and alway returns a CMD_RET_ value (-ENOSYS was a possible result of show_pinmux). This patch also adds pincontrol name in error messages (dev->name) and treats correctly the status sub command when pin-controller device is not selected. Signed-off-by: Patrick Delaunay Signed-off-by: Patrick Delaunay Reviewed-by: Patrice Chotard --- cmd/pinmux.c | 44 +++++++++++++++++++----------------- test/py/tests/test_pinmux.py | 4 ++-- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/cmd/pinmux.c b/cmd/pinmux.c index 9942b15419..af04c95a46 100644 --- a/cmd/pinmux.c +++ b/cmd/pinmux.c @@ -41,7 +41,7 @@ static int do_dev(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_SUCCESS; } -static int show_pinmux(struct udevice *dev) +static void show_pinmux(struct udevice *dev) { char pin_name[PINNAME_SIZE]; char pin_mux[PINMUX_SIZE]; @@ -51,54 +51,56 @@ static int show_pinmux(struct udevice *dev) pins_count = pinctrl_get_pins_count(dev); - if (pins_count == -ENOSYS) { - printf("Ops get_pins_count not supported\n"); - return pins_count; + if (pins_count < 0) { + printf("Ops get_pins_count not supported by %s\n", dev->name); + return; } for (i = 0; i < pins_count; i++) { ret = pinctrl_get_pin_name(dev, i, pin_name, PINNAME_SIZE); - if (ret == -ENOSYS) { - printf("Ops get_pin_name not supported\n"); - return ret; + if (ret) { + printf("Ops get_pin_name error (%d) by %s\n", + ret, dev->name); + return; } ret = pinctrl_get_pin_muxing(dev, i, pin_mux, PINMUX_SIZE); if (ret) { - printf("Ops get_pin_muxing error (%d)\n", ret); - return ret; + printf("Ops get_pin_muxing error (%d) by %s in %s\n", + ret, pin_name, dev->name); + return; } printf("%-*s: %-*s\n", PINNAME_SIZE, pin_name, PINMUX_SIZE, pin_mux); } - - return 0; } static int do_status(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { struct udevice *dev; - int ret = CMD_RET_USAGE; - if (currdev && (argc < 2 || strcmp(argv[1], "-a"))) - return show_pinmux(currdev); + if (argc < 2) { + if (!currdev) { + printf("pin-controller device not selected\n"); + return CMD_RET_FAILURE; + } + show_pinmux(currdev); + return CMD_RET_SUCCESS; + } - if (argc < 2 || strcmp(argv[1], "-a")) - return ret; + if (strcmp(argv[1], "-a")) + return CMD_RET_USAGE; uclass_foreach_dev_probe(UCLASS_PINCTRL, dev) { /* insert a separator between each pin-controller display */ printf("--------------------------\n"); printf("%s:\n", dev->name); - ret = show_pinmux(dev); - if (ret < 0) - printf("Can't display pin muxing for %s\n", - dev->name); + show_pinmux(dev); } - return ret; + return CMD_RET_SUCCESS; } static int do_list(struct cmd_tbl *cmdtp, int flag, int argc, diff --git a/test/py/tests/test_pinmux.py b/test/py/tests/test_pinmux.py index 0cbbae000c..b3ae2ab024 100644 --- a/test/py/tests/test_pinmux.py +++ b/test/py/tests/test_pinmux.py @@ -13,9 +13,9 @@ def test_pinmux_usage_1(u_boot_console): @pytest.mark.buildconfigspec('cmd_pinmux') def test_pinmux_usage_2(u_boot_console): """Test that 'pinmux status' executed without previous "pinmux dev" - command displays pinmux usage.""" + command displays error message.""" output = u_boot_console.run_command('pinmux status') - assert 'Usage:' in output + assert 'pin-controller device not selected' in output @pytest.mark.buildconfigspec('cmd_pinmux') @pytest.mark.boardspec('sandbox')