7eed77775aad32ae533d16808f33f0d945099a51
[oweals/openwrt.git] /
1 From bd5d21310133921021d78995ad6346f908483124 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
3 Date: Sun, 20 Nov 2016 16:09:30 +0100
4 Subject: [PATCH] mtd: bcm47xxpart: fix parsing first block after aligned TRX
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 After parsing TRX we should skip to the first block placed behind it.
10 Our code was working only with TRX with length not aligned to the
11 blocksize. In other cases (length aligned) it was missing the block
12 places right after TRX.
13
14 This fixes calculation and simplifies the comment.
15
16 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
17 Signed-off-by: Brian Norris <computersforpeace@gmail.com>
18 ---
19  drivers/mtd/bcm47xxpart.c | 10 ++++------
20  1 file changed, 4 insertions(+), 6 deletions(-)
21
22 --- a/drivers/mtd/bcm47xxpart.c
23 +++ b/drivers/mtd/bcm47xxpart.c
24 @@ -229,12 +229,10 @@ static int bcm47xxpart_parse(struct mtd_
25  
26                         last_trx_part = curr_part - 1;
27  
28 -                       /*
29 -                        * We have whole TRX scanned, skip to the next part. Use
30 -                        * roundown (not roundup), as the loop will increase
31 -                        * offset in next step.
32 -                        */
33 -                       offset = rounddown(offset + trx->length, blocksize);
34 +                       /* Jump to the end of TRX */
35 +                       offset = roundup(offset + trx->length, blocksize);
36 +                       /* Next loop iteration will increase the offset */
37 +                       offset -= blocksize;
38                         continue;
39                 }
40