Take into account also the start block on trimmed devices.
authorbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 2 Feb 2011 21:00:18 +0000 (21:00 +0000)
committerbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 2 Feb 2011 21:00:18 +0000 (21:00 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4673 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/drv/eeprom.c

index 4fe444e9e0c11c1e0b0ab733c98faeb610025399..26bd90fb3d63a46c8985b483d51cbf495001eaae 100644 (file)
@@ -181,9 +181,8 @@ static size_t eeprom_write(KBlock *blk, block_idx_t idx, const void *buf, size_t
 
        STATIC_ASSERT(countof(addr_buf) <= sizeof(e2addr_t));
 
-
        /* clamp size to memory limit (otherwise may roll back) */
-       ASSERT(idx <= blk->blk_cnt);
+       ASSERT(idx < blk->priv.blk_start + blk->blk_cnt);
        size = MIN(size, blk->blk_size - offset);
 
        if (mem_info[eep->type].has_dev_addr)
@@ -230,7 +229,7 @@ static size_t eeprom_readDirect(struct KBlock *_blk, block_idx_t idx, void *_buf
        STATIC_ASSERT(countof(addr_buf) <= sizeof(e2addr_t));
 
        /* clamp size to memory limit (otherwise may roll back) */
-       ASSERT(idx <= blk->blk.blk_cnt);
+       ASSERT(idx < blk->blk.priv.blk_start + blk->blk.blk_cnt);
        size = MIN(size, blk->blk.blk_size - offset);
 
        e2dev_addr_t dev_addr;