Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C4359C43334 for ; Fri, 8 Jul 2022 14:14:56 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 855D08458F; Fri, 8 Jul 2022 16:14:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="oEuVJkFe"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 361E98458F; Fri, 8 Jul 2022 16:14:47 +0200 (CEST) Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id EF98E8447D for ; Fri, 8 Jul 2022 16:14:44 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=michael@amarulasolutions.com Received: by mail-ej1-x636.google.com with SMTP id u15so13517789ejx.9 for ; Fri, 08 Jul 2022 07:14:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=noSRT8Q0yAZJZaXA/1jRBZjtJWtmRPAt4HnjHk6RmL0=; b=oEuVJkFeH0THtVK6uQRLU9nVRLs0eNzNgWuvZVKWPK8Q96An3ga6Qf8QttyPH7eQLx axhOiyz0U/KX23aRMLjnZkBtN95vqY+PMY0eIBDRiHXbYgpnqV/UFj/hqWKhEVaOIAKK gfwE91ly2cAxUWSFnFYSjHzmPLiFRfot96DOA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=noSRT8Q0yAZJZaXA/1jRBZjtJWtmRPAt4HnjHk6RmL0=; b=CvGYz4murVAHu1xJrmlxWS3IweHWdFKclygpUioS4jYJ1kC1GTZKB5d6j0NkmrI45E chfKaY5BUfQnpr3z1Tj0dMG11YYq5aE2eustpjQELzyh8n82KNYQ7qoUBDvAoxIxMxdg gQatW7ANA0huoi6YEvU50RRl5oYpIHNsxlMyxbGrLQws91QnyHRZMziaDlqtouSCX0Ss JusK9G/Ei9jN+qVwWSBfbXM+E6OzuZjyNGs2JMdIqNxVxcNC+fecRufAFRE9BurQyHQN S9neTXgql0Ud5fkMj1R3E32r+37spj8nqZZUWedhIEzWwM5Nc8CTLyYb2CGXAwOSXxUF ed2w== X-Gm-Message-State: AJIora9dCmixkgCdUwbYQZgcTXFNMqbfyA8HAcNm8YQheIZuXne5lf51 spLml6SI8iTd0ewe/w2Zq92CPzyfeSp8ag== X-Google-Smtp-Source: AGRyM1sMyQ1E3n20at9uMg/51Yge2wuSZDPHvi382hEhl5UNH5anO4mc9F8VgMgKXwJKnOt/vCBjtw== X-Received: by 2002:a17:906:dc93:b0:726:a75b:f60f with SMTP id cs19-20020a170906dc9300b00726a75bf60fmr3769606ejc.564.1657289684498; Fri, 08 Jul 2022 07:14:44 -0700 (PDT) Received: from panicking.amarulasolutions.com ([62.18.232.106]) by smtp.gmail.com with ESMTPSA id s3-20020a1709067b8300b0070efa110afcsm20419074ejo.83.2022.07.08.07.14.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 07:14:43 -0700 (PDT) From: Michael Trimarchi To: linux-amarula@amarulasolutions.com, Dario Binacchi , u-boot@lists.denx.de (open list) Cc: u-boot@lists.denx.de (open list) Subject: [PATCH 2/2] mtd: nand: mxs_nand_spl Fix loop exit condition Date: Fri, 8 Jul 2022 16:14:39 +0200 Message-Id: <20220708141439.164394-2-michael@amarulasolutions.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708141439.164394-1-michael@amarulasolutions.com> References: <20220708141439.164394-1-michael@amarulasolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.6 at phobos.denx.de X-Virus-Status: Clean When size is 0 we need to stop the inner loop or we just waste time to load all the block of the eraseblock Signed-off-by: Michael Trimarchi --- drivers/mtd/nand/raw/mxs_nand_spl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/nand/raw/mxs_nand_spl.c b/drivers/mtd/nand/raw/mxs_nand_spl.c index 683071c1cb..05886fa025 100644 --- a/drivers/mtd/nand/raw/mxs_nand_spl.c +++ b/drivers/mtd/nand/raw/mxs_nand_spl.c @@ -263,7 +263,7 @@ int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst) while (block <= lastblock && size > 0) { if (!is_badblock(mtd, mtd->erasesize * block, 1)) { /* Skip bad blocks */ - while (page < nand_page_per_block) { + while (page < nand_page_per_block && size > 0) { int curr_page = nand_page_per_block * block + page; if (mxs_read_page_ecc(mtd, page_buf, curr_page) < 0) { -- 2.34.1