]> Git Repo - J-u-boot.git/commitdiff
spl: nand: sunxi: fix second case of modulo by zero error
authorMiquel Raynal <[email protected]>
Wed, 28 Feb 2018 19:51:45 +0000 (20:51 +0100)
committerMaxime Ripard <[email protected]>
Tue, 3 Apr 2018 10:10:55 +0000 (12:10 +0200)
In the nand_read_buffer() step, the seed is calculated by doing a modulo
by conf->nseeds which is always zero when not using the randomizer (most
of SLC NANDs).

This situation turns out to lead to a run time freeze with certain
toolchains.

Derive this seed only when the randomizer is enabled (and conf->nseeds
logically not zero), exactly like what has been done before with an
identical situation, see commit ea3f750c73e3 ("nand: sunxi: Fix modulo
by zero error").

Signed-off-by: Miquel Raynal <[email protected]>
Acked-by: Boris Brezillon <[email protected]>
Signed-off-by: Maxime Ripard <[email protected]>
drivers/mtd/nand/sunxi_nand_spl.c

index eed4472bdc34b60cdb6aa2759bc961f32f70f7f0..06695fc15feef5502a32a6051010eb7004221a61 100644 (file)
@@ -475,11 +475,12 @@ static int nand_detect_config(struct nfc_config *conf, u32 offs, void *dest)
 static int nand_read_buffer(struct nfc_config *conf, uint32_t offs,
                            unsigned int size, void *dest)
 {
-       int first_seed, page, ret;
+       int first_seed = 0, page, ret;
 
        size = ALIGN(size, conf->page_size);
        page = offs / conf->page_size;
-       first_seed = page % conf->nseeds;
+       if (conf->randomize)
+               first_seed = page % conf->nseeds;
 
        for (; size; size -= conf->page_size) {
                if (nand_load_page(conf, offs))
This page took 0.039832 seconds and 4 git commands to generate.