mtd: bcm47xxpart: fix parsing first block after aligned TRX
authorRafał Miłecki <rafal@milecki.pl>
Sun, 20 Nov 2016 15:09:30 +0000 (16:09 +0100)
committerJiri Slaby <jslaby@suse.cz>
Fri, 28 Apr 2017 17:30:38 +0000 (19:30 +0200)
commit bd5d21310133921021d78995ad6346f908483124 upstream.

After parsing TRX we should skip to the first block placed behind it.
Our code was working only with TRX with length not aligned to the
blocksize. In other cases (length aligned) it was missing the block
places right after TRX.

This fixes calculation and simplifies the comment.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
drivers/mtd/bcm47xxpart.c

index 9279a9174f84ad9cd3a2ae2c7117c29cc8134e9e..04e2e430889005609754c10269148d88ba298645 100644 (file)
@@ -159,12 +159,10 @@ static int bcm47xxpart_parse(struct mtd_info *master,
 
                        last_trx_part = curr_part - 1;
 
-                       /*
-                        * We have whole TRX scanned, skip to the next part. Use
-                        * roundown (not roundup), as the loop will increase
-                        * offset in next step.
-                        */
-                       offset = rounddown(offset + trx->length, blocksize);
+                       /* Jump to the end of TRX */
+                       offset = roundup(offset + trx->length, blocksize);
+                       /* Next loop iteration will increase the offset */
+                       offset -= blocksize;
                        continue;
                }
        }