All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Simek <michal.simek@xilinx.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 06/17] cmd: fpga: Move parameter checking for loadfs/loads
Date: Wed,  8 Aug 2018 13:37:32 +0200	[thread overview]
Message-ID: <923934b01b9c57a61bddcac28e3ded8ea8f3155d.1533728254.git.michal.simek@xilinx.com> (raw)
In-Reply-To: <cover.1533728254.git.michal.simek@xilinx.com>

There is no reason to check parameters in separate switch before main
one. This patch is simplifying error path and checking parameters right
after assignment.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

Changes in v2: None
Changes in v1: None

 cmd/fpga.c | 44 +++++++++++++++++++++-----------------------
 1 file changed, 21 insertions(+), 23 deletions(-)

diff --git a/cmd/fpga.c b/cmd/fpga.c
index af2f514dca00..48902286f1d5 100644
--- a/cmd/fpga.c
+++ b/cmd/fpga.c
@@ -123,6 +123,14 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 		fpga_fsinfo.interface = argv[6];
 		fpga_fsinfo.dev_part = argv[7];
 		fpga_fsinfo.filename = argv[8];
+
+		/* Blocksize can be zero */
+		if (!fpga_fsinfo.interface || !fpga_fsinfo.dev_part ||
+		    !fpga_fsinfo.filename) {
+			puts("ERR: Wrong interface, dev_part or filename\n");
+			return CMD_RET_USAGE;
+		}
+
 		argc = 5;
 		break;
 #endif
@@ -136,6 +144,19 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 								     NULL, 16);
 		fpga_sec_info.encflag = (u8)simple_strtoul(argv[6], NULL, 16);
 		fpga_sec_info.authflag = (u8)simple_strtoul(argv[5], NULL, 16);
+
+		if (fpga_sec_info.authflag >= FPGA_NO_ENC_OR_NO_AUTH &&
+		    fpga_sec_info.encflag >= FPGA_NO_ENC_OR_NO_AUTH) {
+			puts("ERR: Use <fpga load> for NonSecure bitstream\n");
+			return CMD_RET_USAGE;
+		}
+
+		if (fpga_sec_info.encflag == FPGA_ENC_USR_KEY &&
+		    !fpga_sec_info.userkey_addr) {
+			puts("ERR: User key not provided\n");
+			return CMD_RET_USAGE;
+		}
+
 		argc = 5;
 		break;
 #endif
@@ -177,29 +198,6 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 	switch (op) {
 	case FPGA_INFO:
 		break;
-#if defined(CONFIG_CMD_FPGA_LOADFS)
-	case FPGA_LOADFS:
-		/* Blocksize can be zero */
-		if (!fpga_fsinfo.interface || !fpga_fsinfo.dev_part ||
-		    !fpga_fsinfo.filename)
-			wrong_parms = 1;
-		break;
-#endif
-#if defined(CONFIG_CMD_FPGA_LOAD_SECURE)
-	case FPGA_LOADS:
-		if (fpga_sec_info.authflag >= FPGA_NO_ENC_OR_NO_AUTH &&
-		    fpga_sec_info.encflag >= FPGA_NO_ENC_OR_NO_AUTH) {
-			puts("ERR: use <fpga load> for NonSecure bitstream\n");
-			wrong_parms = 1;
-		}
-
-		if (fpga_sec_info.encflag == FPGA_ENC_USR_KEY &&
-		    !fpga_sec_info.userkey_addr) {
-			wrong_parms = 1;
-			puts("ERR:User key not provided\n");
-		}
-		break;
-#endif
 	case FPGA_LOAD:
 	case FPGA_LOADP:
 	case FPGA_LOADB:
-- 
1.9.1

  parent reply	other threads:[~2018-08-08 11:37 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-08 11:37 [U-Boot] [PATCH v2 00/17] cmd: fpga: Fix fpga command handling and add some fpga tests Michal Simek
2018-08-08 11:37 ` [U-Boot] [PATCH v2 01/17] cmd: fpga: Remove fit image support passed without fpga device Michal Simek
2018-08-08 11:37 ` [U-Boot] [PATCH v2 02/17] test/py: Extend fpga command to test all fpga load types Michal Simek
2018-08-08 11:37 ` [U-Boot] [PATCH v2 03/17] cmd: fpga: Move error handling to do_fpga() Michal Simek
2018-08-08 11:37 ` [U-Boot] [PATCH v2 04/17] cmd: fpga: Move fpga_get_op to avoid local function declaration Michal Simek
2018-08-08 11:37 ` [U-Boot] [PATCH v2 05/17] cmd: fpga: Cleanup error handling in connection to FPGA_NONE Michal Simek
2018-08-08 11:37 ` Michal Simek [this message]
2018-08-08 11:37 ` [U-Boot] [PATCH v2 07/17] cmd: fpga: Remove parameter checking from fpga loadfs command Michal Simek
2018-08-08 11:37 ` [U-Boot] [PATCH v2 08/17] cmd: fpga: Clean wrong_parms handling Michal Simek
2018-08-08 11:37 ` [U-Boot] [PATCH v2 09/17] cmd: fpga: Create new do_fpga_wrapper for using u-boot subcommands Michal Simek
2018-08-08 11:37 ` [U-Boot] [PATCH v2 10/17] cmd: fpga: Extract fpga info command to separate function Michal Simek
2018-08-08 11:37 ` [U-Boot] [PATCH v2 11/17] cmd: fpga: Fix dump and all direct fpga load commands Michal Simek
2018-08-08 11:37 ` [U-Boot] [PATCH v2 12/17] cmd: fpga: Fix loadfs command Michal Simek
2018-08-08 11:37 ` [U-Boot] [PATCH v2 13/17] cmd: fpga: Fix loadmk command Michal Simek
2018-08-08 11:37 ` [U-Boot] [PATCH v2 14/17] cmd: fpga: Add support for missing fpga loadmk commands Michal Simek
2018-08-09 11:20   ` Simon Glass
2018-08-08 11:37 ` [U-Boot] [PATCH v2 15/17] cmd: fpga: Use CMD_RET_FAILURE instead of simple 1 Michal Simek
2018-08-08 11:37 ` [U-Boot] [PATCH v2 16/17] cmd: fpga: Fix loads command Michal Simek
2018-08-08 11:37 ` [U-Boot] [PATCH v2 17/17] MAINTAINERS: Add myself as the FPGA maintainer Michal Simek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=923934b01b9c57a61bddcac28e3ded8ea8f3155d.1533728254.git.michal.simek@xilinx.com \
    --to=michal.simek@xilinx.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.