Author: rmilecki Date: 2015-04-24 16:28:57 +0200 (Fri, 24 Apr 2015) New Revision: 45578
Modified: trunk/package/utils/nvram/src/nvram.c trunk/package/utils/nvram/src/nvram.h Log: nvram: fix regression in finding NVRAM beginning The loop was giving up too early as it never expected NVRAM smaller than 0x10000. Signed-off-by: Rafa?\197?\130 Mi?\197?\130ecki <[email protected]> Modified: trunk/package/utils/nvram/src/nvram.c =================================================================== --- trunk/package/utils/nvram/src/nvram.c 2015-04-24 10:53:11 UTC (rev 45577) +++ trunk/package/utils/nvram/src/nvram.c 2015-04-24 14:28:57 UTC (rev 45578) @@ -364,7 +364,12 @@ if( mmap_area != MAP_FAILED ) { - for( i = 0; i <= ((nvram_part_size - NVRAM_SPACE) / sizeof(uint32_t)); i++ ) + /* + * Start looking for NVRAM_MAGIC at beginning of MTD + * partition. Stop if there is less than NVRAM_MIN_SPACE + * to check, that was the lowest used size. + */ + for( i = 0; i <= ((nvram_part_size - NVRAM_MIN_SPACE) / sizeof(uint32_t)); i++ ) { if( ((uint32_t *)mmap_area)[i] == NVRAM_MAGIC ) { Modified: trunk/package/utils/nvram/src/nvram.h =================================================================== --- trunk/package/utils/nvram/src/nvram.h 2015-04-24 10:53:11 UTC (rev 45577) +++ trunk/package/utils/nvram/src/nvram.h 2015-04-24 14:28:57 UTC (rev 45578) @@ -113,6 +113,7 @@ #define NVRAM_ROUNDUP(x, y) ((((x)+((y)-1))/(y))*(y)) /* NVRAM constants */ +#define NVRAM_MIN_SPACE 0x8000 #define NVRAM_SPACE 0x10000 #define NVRAM_MAGIC 0x48534C46 /* 'FLSH' */ #define NVRAM_VERSION 1 _______________________________________________ openwrt-commits mailing list [email protected] https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-commits
