Lines Matching refs:cfg

18     LFS1_ASSERT(block < lfs1->cfg->block_count);  in lfs1_cache_read()
22 off < pcache->off + lfs1->cfg->prog_size) { in lfs1_cache_read()
25 lfs1->cfg->prog_size - (off-pcache->off)); in lfs1_cache_read()
35 off < rcache->off + lfs1->cfg->read_size) { in lfs1_cache_read()
38 lfs1->cfg->read_size - (off-rcache->off)); in lfs1_cache_read()
47 if (off % lfs1->cfg->read_size == 0 && size >= lfs1->cfg->read_size) { in lfs1_cache_read()
49 lfs1_size_t diff = size - (size % lfs1->cfg->read_size); in lfs1_cache_read()
50 int err = lfs1->cfg->read(lfs1->cfg, block, off, data, diff); in lfs1_cache_read()
63 rcache->off = off - (off % lfs1->cfg->read_size); in lfs1_cache_read()
64 int err = lfs1->cfg->read(lfs1->cfg, rcache->block, in lfs1_cache_read()
65 rcache->off, rcache->buffer, lfs1->cfg->read_size); in lfs1_cache_read()
121 memset(pcache->buffer, 0xff, lfs1->cfg->prog_size); in lfs1_cache_zero()
128 int err = lfs1->cfg->prog(lfs1->cfg, pcache->block, in lfs1_cache_flush()
129 pcache->off, pcache->buffer, lfs1->cfg->prog_size); in lfs1_cache_flush()
136 pcache->off, pcache->buffer, lfs1->cfg->prog_size); in lfs1_cache_flush()
156 LFS1_ASSERT(block < lfs1->cfg->block_count); in lfs1_cache_prog()
160 off < pcache->off + lfs1->cfg->prog_size) { in lfs1_cache_prog()
163 lfs1->cfg->prog_size - (off-pcache->off)); in lfs1_cache_prog()
170 if (off % lfs1->cfg->prog_size == 0) { in lfs1_cache_prog()
185 if (off % lfs1->cfg->prog_size == 0 && in lfs1_cache_prog()
186 size >= lfs1->cfg->prog_size) { in lfs1_cache_prog()
188 lfs1_size_t diff = size - (size % lfs1->cfg->prog_size); in lfs1_cache_prog()
189 int err = lfs1->cfg->prog(lfs1->cfg, block, off, data, diff); in lfs1_cache_prog()
214 pcache->off = off - (off % lfs1->cfg->prog_size); in lfs1_cache_prog()
247 return lfs1->cfg->erase(lfs1->cfg, block); in lfs1_bd_erase()
258 return lfs1->cfg->sync(lfs1->cfg); in lfs1_bd_sync()
278 + lfs1->cfg->block_count) % lfs1->cfg->block_count; in lfs1_alloc_lookahead()
296 *block = (lfs1->free.off + off) % lfs1->cfg->block_count; in lfs1_alloc()
319 % lfs1->cfg->block_count; in lfs1_alloc()
320 lfs1->free.size = lfs1_min(lfs1->cfg->lookahead, lfs1->free.ack); in lfs1_alloc()
324 memset(lfs1->free.buffer, 0, lfs1->cfg->lookahead/8); in lfs1_alloc()
333 lfs1->free.ack = lfs1->cfg->block_count; in lfs1_alloc_ack()
462 (0x7fffffff & test.size) > lfs1->cfg->block_size) { in lfs1_dir_fetch()
673 if (dir->d.size + lfs1_entry_size(entry) <= lfs1->cfg->block_size) { in lfs1_dir_append()
1109 lfs1_off_t b = lfs1->cfg->block_size - 2*4; in lfs1_ctz_index()
1144 LFS1_ASSERT(head >= 2 && head <= lfs1->cfg->block_count); in lfs1_ctz_find()
1164 LFS1_ASSERT(nblock >= 2 && nblock <= lfs1->cfg->block_count); in lfs1_ctz_extend()
1186 if (size != lfs1->cfg->block_size) { in lfs1_ctz_extend()
1235 LFS1_ASSERT(head >= 2 && head <= lfs1->cfg->block_count); in lfs1_ctz_extend()
1296 const struct lfs1_file_config *cfg) { in lfs1_file_opencfg() argument
1336 file->cfg = cfg; in lfs1_file_opencfg()
1355 if (file->cfg && file->cfg->buffer) { in lfs1_file_opencfg()
1356 file->cache.buffer = file->cfg->buffer; in lfs1_file_opencfg()
1357 } else if (lfs1->cfg->file_buffer) { in lfs1_file_opencfg()
1362 file->cache.buffer = lfs1->cfg->file_buffer; in lfs1_file_opencfg()
1364 file->cache.buffer = lfs1_malloc(lfs1->cfg->read_size); in lfs1_file_opencfg()
1369 file->cache.buffer = lfs1_malloc(lfs1->cfg->prog_size); in lfs1_file_opencfg()
1405 if (!(file->cfg && file->cfg->buffer) && !lfs1->cfg->file_buffer) { in lfs1_file_close()
1451 memcpy(file->cache.buffer, lfs1->pcache.buffer, lfs1->cfg->prog_size); in lfs1_file_relocate()
1598 file->off == lfs1->cfg->block_size) { in lfs1_file_read()
1610 lfs1_size_t diff = lfs1_min(nsize, lfs1->cfg->block_size - file->off); in lfs1_file_read()
1668 file->off == lfs1->cfg->block_size) { in lfs1_file_write()
1697 lfs1_size_t diff = lfs1_min(nsize, lfs1->cfg->block_size - file->off); in lfs1_file_write()
2025 if (!lfs1->cfg->read_buffer) { in lfs1_deinit()
2029 if (!lfs1->cfg->prog_buffer) { in lfs1_deinit()
2033 if (!lfs1->cfg->lookahead_buffer) { in lfs1_deinit()
2038 static int lfs1_init(lfs1_t *lfs1, const struct lfs1_config *cfg) { in lfs1_init() argument
2039 lfs1->cfg = cfg; in lfs1_init()
2042 if (lfs1->cfg->read_buffer) { in lfs1_init()
2043 lfs1->rcache.buffer = lfs1->cfg->read_buffer; in lfs1_init()
2045 lfs1->rcache.buffer = lfs1_malloc(lfs1->cfg->read_size); in lfs1_init()
2052 if (lfs1->cfg->prog_buffer) { in lfs1_init()
2053 lfs1->pcache.buffer = lfs1->cfg->prog_buffer; in lfs1_init()
2055 lfs1->pcache.buffer = lfs1_malloc(lfs1->cfg->prog_size); in lfs1_init()
2066 LFS1_ASSERT(lfs1->cfg->lookahead % 32 == 0); in lfs1_init()
2067 LFS1_ASSERT(lfs1->cfg->lookahead > 0); in lfs1_init()
2068 if (lfs1->cfg->lookahead_buffer) { in lfs1_init()
2069 lfs1->free.buffer = lfs1->cfg->lookahead_buffer; in lfs1_init()
2071 lfs1->free.buffer = lfs1_malloc(lfs1->cfg->lookahead/8); in lfs1_init()
2078 LFS1_ASSERT(lfs1->cfg->prog_size % lfs1->cfg->read_size == 0); in lfs1_init()
2079 LFS1_ASSERT(lfs1->cfg->block_size % lfs1->cfg->prog_size == 0); in lfs1_init()
2082 LFS1_ASSERT(4*lfs1_npw2(0xffffffff / (lfs1->cfg->block_size-2*4)) in lfs1_init()
2083 <= lfs1->cfg->block_size); in lfs1_init()
2100 int lfs1_format(lfs1_t *lfs1, const struct lfs1_config *cfg) { in lfs1_format() argument
2103 err = lfs1_init(lfs1, cfg); in lfs1_format()
2109 memset(lfs1->free.buffer, 0, lfs1->cfg->lookahead/8); in lfs1_format()
2111 lfs1->free.size = lfs1_min(lfs1->cfg->lookahead, lfs1->cfg->block_count); in lfs1_format()
2145 .d.block_size = lfs1->cfg->block_size, in lfs1_format()
2146 .d.block_count = lfs1->cfg->block_count, in lfs1_format()
2187 int lfs1_mount(lfs1_t *lfs1, const struct lfs1_config *cfg) { in lfs1_mount() argument
2190 err = lfs1_init(lfs1, cfg); in lfs1_mount()
2486 for (lfs1_size_t i = 0; i < lfs1->cfg->block_count; i++) { in lfs1_deorphan()