android: persistent_ram: Include ecc_size when calculating ecc_block
Arve Hjønnevåg [Tue, 20 Mar 2012 23:01:31 +0000 (16:01 -0700)]
Wastes less memory and allows using more memory for ecc than data.

Change-Id: I1537d28ef3e8626e2dfdc69f2e185d28b7600916
Signed-off-by: Arve Hjønnevåg <arve@android.com>

drivers/staging/android/persistent_ram.c

index 4d73d94..047b71e 100644 (file)
@@ -187,7 +187,8 @@ static int persistent_ram_init_ecc(struct persistent_ram_zone *prz,
        prz->ecc_symsize = 8;
        prz->ecc_poly = 0x11d;
 
-       ecc_blocks = DIV_ROUND_UP(prz->buffer_size, prz->ecc_block_size);
+       ecc_blocks = DIV_ROUND_UP(prz->buffer_size - prz->ecc_size,
+                                 prz->ecc_block_size + prz->ecc_size);
        prz->buffer_size -= (ecc_blocks + 1) * prz->ecc_size;
 
        if (prz->buffer_size > buffer_size) {