From patchwork Thu Feb 1 08:05:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 868154 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; 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="zhedl2iV"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3zXCNT2SWDz9t20 for ; Thu, 1 Feb 2018 19:05:45 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id E08BBC21DD9; Thu, 1 Feb 2018 08:05:43 +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=RCVD_IN_MSPIKE_H2, 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 C3FFBC21D75; Thu, 1 Feb 2018 08:05:40 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 67650C21D75; Thu, 1 Feb 2018 08:05:39 +0000 (UTC) Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by lists.denx.de (Postfix) with ESMTPS id EFA1AC21C29 for ; Thu, 1 Feb 2018 08:05:38 +0000 (UTC) Received: by mail-wr0-f196.google.com with SMTP id h9so4833668wre.12 for ; Thu, 01 Feb 2018 00:05:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id; bh=HBz9j4yZ8FaoEtEv06EFus3ZL72F2vvwa9f8S1MvTPM=; b=zhedl2iVZ7YBKREaWT+4UUfFb9aBMBJGOo1Kg4NCBJuoh+KqSn1E5s7BDX4nutDtQa kv1sV9+yS4rAjp5QAPpj2O8w1c3qu+I4HtRMdUy/LP86/DUngcb9YP54pxunytCsrx8o Yt8RLyvU3acdpRKuurHnnDZiw1ZYeLJYJm3CeZL64aP3qFmjLB71QRM2EerWNWhH3CxI nSyfHIx0hOuA/BVvMvTRRXX6Rfl+POGHd9AEKdSpifVMrbRwmBuGp9++dEV6rxRJgyuo IxjcU3LzQXRGMmhpRJE5JZBqS+0TB9h6i21UC7CiK0FzVEVyg3g/VnPWdp/rY/Y4QEcT BbrQ== 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:cc:subject:date:message-id; bh=HBz9j4yZ8FaoEtEv06EFus3ZL72F2vvwa9f8S1MvTPM=; b=tOiB2Ejv54lRfu4bV0l/iphbHaq27yoX8HqBk6iFiTToE7DrJWboEbQf2o6ldRxvOv zGqjA1JJa4EZVaUX5DVOgl6IAQSs4vF69AiCRO1uFBU4n4on86WOk1JtRQu4TaHXhk0v sFqvCiPpW5oxlcRTmXtrfzVok1d7/UBGomyLS00VwFtXh+GcmhCvyzc+zmIGlgN1hlgY L/03xgR528frI7YT7dYDRN5Q4ybsVLqPSvJooY+F03Dvgdds63JSkcKLj3ANIrcx4qNo tMagZ4e2XsVfmw5+gKvu6HxrGQXYVwQrXJGAL2Mwm7rcpAJyl3uuBb2Ep+lUJwzF9WGY SLug== X-Gm-Message-State: AKwxytd7023PlS6Cex36iYP7QXu0h6OEyGTYx30gU7w0udcTjyhSTMTh hBmMP6cIEAwhna79YluaYStfs+ko X-Google-Smtp-Source: AH8x2275hSYrPnw33XdW/7AHJplvpmt9qGxICCleTbpiGEvhENeCWh2Y0UNVGvwlA2DHiNod7sChOw== X-Received: by 10.223.182.4 with SMTP id f4mr6834460wre.11.1517472338405; Thu, 01 Feb 2018 00:05:38 -0800 (PST) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id 67sm1915062wmg.13.2018.02.01.00.05.37 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 01 Feb 2018 00:05:37 -0800 (PST) From: Michal Simek To: u-boot@lists.denx.de Date: Thu, 1 Feb 2018 09:05:36 +0100 Message-Id: <58fc99aa654f4c3babadf5b8318d5ccf4d75690a.1517472333.git.michal.simek@xilinx.com> X-Mailer: git-send-email 1.9.1 Subject: [U-Boot] [PATCH] fpga: Simplify error path in fpga_add 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" Check !desc earlier to simplify code. Signed-off-by: Michal Simek Acked-by: Simon Goldschmidt Reviewed-by: Simon Goldschmidt --- drivers/fpga/fpga.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/fpga/fpga.c b/drivers/fpga/fpga.c index 6aead27f1626..ac01612d7518 100644 --- a/drivers/fpga/fpga.c +++ b/drivers/fpga/fpga.c @@ -148,20 +148,21 @@ int fpga_add(fpga_type devtype, void *desc) { int devnum = FPGA_INVALID_DEVICE; + if (!desc) { + printf("%s: NULL device descriptor\n", __func__); + return devnum; + } + if (next_desc < 0) { printf("%s: FPGA support not initialized!\n", __func__); } else if ((devtype > fpga_min_type) && (devtype < fpga_undefined)) { - if (desc) { - if (next_desc < CONFIG_MAX_FPGA_DEVICES) { - devnum = next_desc; - desc_table[next_desc].devtype = devtype; - desc_table[next_desc++].devdesc = desc; - } else { - printf("%s: Exceeded Max FPGA device count\n", - __func__); - } + if (next_desc < CONFIG_MAX_FPGA_DEVICES) { + devnum = next_desc; + desc_table[next_desc].devtype = devtype; + desc_table[next_desc++].devdesc = desc; } else { - printf("%s: NULL device descriptor\n", __func__); + printf("%s: Exceeded Max FPGA device count\n", + __func__); } } else { printf("%s: Unsupported FPGA type %d\n", __func__, devtype);