From patchwork Wed Aug 8 11:37:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 954917 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="D7ayxF7Q"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41lqJP3BVxz9s1c for ; Wed, 8 Aug 2018 21:43:01 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 1EBDAC22024; Wed, 8 Aug 2018 11:40:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id C99B9C21FBD; Wed, 8 Aug 2018 11:38:32 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 5D9A7C2202E; Wed, 8 Aug 2018 11:38:02 +0000 (UTC) Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) by lists.denx.de (Postfix) with ESMTPS id AEB95C2200F for ; Wed, 8 Aug 2018 11:37:58 +0000 (UTC) Received: by mail-wr1-f52.google.com with SMTP id h15-v6so1719653wrs.7 for ; Wed, 08 Aug 2018 04:37:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=oSv2mPaMjFBVFGbjXqArW5+ysjggTcoIgDPczGLmJ4o=; b=D7ayxF7QAS0ugtYWfjZX+1s9Um+K/q8pEB4jKvGh8fvv9HfuDcW0wO0z5pEhL46g6x heSRBf795rb4YjZ4okB5x5Vek6JzOcYMl3xl8htyl7v3StxsTI9owxb5kOHj3dF6KAHj +y90RW7JzjdLhUgY+e6pUMqFkcaOaygztMqBJVmt7DHIsrwYXKmghwslKFhkAFmmZdYA DWYnlnoH3KzrnRFvpVLLmfrL32BoWuKH6ZV9SHK/cS8eXctgYOwmUmxu7eZNhma6p8CG i188/ImVd2eXR0HMsSwEgvlQS+4cqLDZGVxgPhkKa6NIWUzRtttsMYnpGnBzuWsDRVhG l7pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=oSv2mPaMjFBVFGbjXqArW5+ysjggTcoIgDPczGLmJ4o=; b=bo+9ArVw+IJGoG7j4gT47D5LTg30NcF7r85xKpyfB5wGvJ7reiF2DS/nyegH/UKfdg afTWHkpUaOPK8HH7Vf19y6jbvdVFdzzRW5fKRk+fCfMntGOBuSHea+J1vHzvQl58d7/2 z9Ur7fcwlQVZwVgB3ZR7jBEZnxXadqbZ077532LB/DH/VKFyh3HgKEZZCN45/AJNIUQI lOVbYbk7PQKCyqT+zh7yX6Kby3oxw+JxdxFBiunK+yQxtSad4c3XPHdkoiBy/Tf32au/ AHjXI1jDCy8/2xog3esOsKhKUs2U/U+ApkjcZ8hmmDSSdGFayHyaHuRWiYerzQWAmYQ/ t6+g== X-Gm-Message-State: AOUpUlEL/gZy8WG2sOXHJDCyt9uhGBV/DrtcfsZEedQYfbxkEYxHGUA4 H7MwirQtNsJRRZNS6xIgPtlx9x4NMj/Szw== X-Google-Smtp-Source: AA+uWPzhv7tlsSWLHQ0tesGYVYRekvxwfPhGk63YCUbMeVyz31xeedani/Nz6JMblkKzhyz9zsWesw== X-Received: by 2002:adf:c4f0:: with SMTP id o45-v6mr1660388wrf.173.1533728278117; Wed, 08 Aug 2018 04:37:58 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id 139-v6sm9295036wmp.4.2018.08.08.04.37.57 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 08 Aug 2018 04:37:57 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de, Wolfgang Denk , Stefano Babic , Marek Vasut , Simon Glass , Tom Rini Date: Wed, 8 Aug 2018 13:37:32 +0200 Message-Id: <923934b01b9c57a61bddcac28e3ded8ea8f3155d.1533728254.git.michal.simek@xilinx.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: Subject: [U-Boot] [PATCH v2 06/17] cmd: fpga: Move parameter checking for loadfs/loads X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 Reviewed-by: Simon Glass --- 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 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 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: