Lines Matching refs:bd
30 lfs_testbd_t *bd = cfg->context; in lfs_testbd_createcfg() local
31 bd->cfg = bdcfg; in lfs_testbd_createcfg()
34 bd->persist = path; in lfs_testbd_createcfg()
35 bd->power_cycles = bd->cfg->power_cycles; in lfs_testbd_createcfg()
37 if (bd->cfg->erase_cycles) { in lfs_testbd_createcfg()
38 if (bd->cfg->wear_buffer) { in lfs_testbd_createcfg()
39 bd->wear = bd->cfg->wear_buffer; in lfs_testbd_createcfg()
41 bd->wear = lfs_malloc(sizeof(lfs_testbd_wear_t)*cfg->block_count); in lfs_testbd_createcfg()
42 if (!bd->wear) { in lfs_testbd_createcfg()
48 memset(bd->wear, 0, sizeof(lfs_testbd_wear_t) * cfg->block_count); in lfs_testbd_createcfg()
52 if (bd->persist) { in lfs_testbd_createcfg()
53 bd->u.file.cfg = (struct lfs_filebd_config){ in lfs_testbd_createcfg()
54 .erase_value = bd->cfg->erase_value, in lfs_testbd_createcfg()
56 int err = lfs_filebd_createcfg(cfg, path, &bd->u.file.cfg); in lfs_testbd_createcfg()
60 bd->u.ram.cfg = (struct lfs_rambd_config){ in lfs_testbd_createcfg()
61 .erase_value = bd->cfg->erase_value, in lfs_testbd_createcfg()
62 .buffer = bd->cfg->buffer, in lfs_testbd_createcfg()
64 int err = lfs_rambd_createcfg(cfg, &bd->u.ram.cfg); in lfs_testbd_createcfg()
89 lfs_testbd_t *bd = cfg->context; in lfs_testbd_destroy() local
90 if (bd->cfg->erase_cycles && !bd->cfg->wear_buffer) { in lfs_testbd_destroy()
91 lfs_free(bd->wear); in lfs_testbd_destroy()
94 if (bd->persist) { in lfs_testbd_destroy()
108 lfs_testbd_t *bd = cfg->context; in lfs_testbd_rawread() local
109 if (bd->persist) { in lfs_testbd_rawread()
118 lfs_testbd_t *bd = cfg->context; in lfs_testbd_rawprog() local
119 if (bd->persist) { in lfs_testbd_rawprog()
128 lfs_testbd_t *bd = cfg->context; in lfs_testbd_rawerase() local
129 if (bd->persist) { in lfs_testbd_rawerase()
137 lfs_testbd_t *bd = cfg->context; in lfs_testbd_rawsync() local
138 if (bd->persist) { in lfs_testbd_rawsync()
151 lfs_testbd_t *bd = cfg->context; in lfs_testbd_read() local
159 if (bd->cfg->erase_cycles && bd->wear[block] >= bd->cfg->erase_cycles && in lfs_testbd_read()
160 bd->cfg->badblock_behavior == LFS_TESTBD_BADBLOCK_READERROR) { in lfs_testbd_read()
176 lfs_testbd_t *bd = cfg->context; in lfs_testbd_prog() local
184 if (bd->cfg->erase_cycles && bd->wear[block] >= bd->cfg->erase_cycles) { in lfs_testbd_prog()
185 if (bd->cfg->badblock_behavior == in lfs_testbd_prog()
189 } else if (bd->cfg->badblock_behavior == in lfs_testbd_prog()
191 bd->cfg->badblock_behavior == in lfs_testbd_prog()
206 if (bd->power_cycles > 0) { in lfs_testbd_prog()
207 bd->power_cycles -= 1; in lfs_testbd_prog()
208 if (bd->power_cycles == 0) { in lfs_testbd_prog()
222 lfs_testbd_t *bd = cfg->context; in lfs_testbd_erase() local
228 if (bd->cfg->erase_cycles) { in lfs_testbd_erase()
229 if (bd->wear[block] >= bd->cfg->erase_cycles) { in lfs_testbd_erase()
230 if (bd->cfg->badblock_behavior == in lfs_testbd_erase()
234 } else if (bd->cfg->badblock_behavior == in lfs_testbd_erase()
241 bd->wear[block] += 1; in lfs_testbd_erase()
253 if (bd->power_cycles > 0) { in lfs_testbd_erase()
254 bd->power_cycles -= 1; in lfs_testbd_erase()
255 if (bd->power_cycles == 0) { in lfs_testbd_erase()
279 lfs_testbd_t *bd = cfg->context; in lfs_testbd_getwear() local
282 LFS_ASSERT(bd->cfg->erase_cycles); in lfs_testbd_getwear()
285 LFS_TESTBD_TRACE("lfs_testbd_getwear -> %"PRIu32, bd->wear[block]); in lfs_testbd_getwear()
286 return bd->wear[block]; in lfs_testbd_getwear()
292 lfs_testbd_t *bd = cfg->context; in lfs_testbd_setwear() local
295 LFS_ASSERT(bd->cfg->erase_cycles); in lfs_testbd_setwear()
298 bd->wear[block] = wear; in lfs_testbd_setwear()