Lines Matching refs:cfg
13 int lfs_filebd_createcfg(const struct lfs_config *cfg, const char *path, in lfs_filebd_createcfg() argument
21 (void*)cfg, cfg->context, in lfs_filebd_createcfg()
22 (void*)(uintptr_t)cfg->read, (void*)(uintptr_t)cfg->prog, in lfs_filebd_createcfg()
23 (void*)(uintptr_t)cfg->erase, (void*)(uintptr_t)cfg->sync, in lfs_filebd_createcfg()
24 cfg->read_size, cfg->prog_size, cfg->block_size, cfg->block_count, in lfs_filebd_createcfg()
26 lfs_filebd_t *bd = cfg->context; in lfs_filebd_createcfg()
27 bd->cfg = bdcfg; in lfs_filebd_createcfg()
41 int lfs_filebd_create(const struct lfs_config *cfg, const char *path) { in lfs_filebd_create() argument
47 (void*)cfg, cfg->context, in lfs_filebd_create()
48 (void*)(uintptr_t)cfg->read, (void*)(uintptr_t)cfg->prog, in lfs_filebd_create()
49 (void*)(uintptr_t)cfg->erase, (void*)(uintptr_t)cfg->sync, in lfs_filebd_create()
50 cfg->read_size, cfg->prog_size, cfg->block_size, cfg->block_count, in lfs_filebd_create()
53 int err = lfs_filebd_createcfg(cfg, path, &defaults); in lfs_filebd_create()
58 int lfs_filebd_destroy(const struct lfs_config *cfg) { in lfs_filebd_destroy() argument
59 LFS_FILEBD_TRACE("lfs_filebd_destroy(%p)", (void*)cfg); in lfs_filebd_destroy()
60 lfs_filebd_t *bd = cfg->context; in lfs_filebd_destroy()
71 int lfs_filebd_read(const struct lfs_config *cfg, lfs_block_t block, in lfs_filebd_read() argument
75 (void*)cfg, block, off, buffer, size); in lfs_filebd_read()
76 lfs_filebd_t *bd = cfg->context; in lfs_filebd_read()
79 LFS_ASSERT(off % cfg->read_size == 0); in lfs_filebd_read()
80 LFS_ASSERT(size % cfg->read_size == 0); in lfs_filebd_read()
81 LFS_ASSERT(block < cfg->block_count); in lfs_filebd_read()
84 if (bd->cfg->erase_value != -1) { in lfs_filebd_read()
85 memset(buffer, bd->cfg->erase_value, size); in lfs_filebd_read()
90 (off_t)block*cfg->block_size + (off_t)off, SEEK_SET); in lfs_filebd_read()
108 int lfs_filebd_prog(const struct lfs_config *cfg, lfs_block_t block, in lfs_filebd_prog() argument
111 (void*)cfg, block, off, buffer, size); in lfs_filebd_prog()
112 lfs_filebd_t *bd = cfg->context; in lfs_filebd_prog()
115 LFS_ASSERT(off % cfg->prog_size == 0); in lfs_filebd_prog()
116 LFS_ASSERT(size % cfg->prog_size == 0); in lfs_filebd_prog()
117 LFS_ASSERT(block < cfg->block_count); in lfs_filebd_prog()
120 if (bd->cfg->erase_value != -1) { in lfs_filebd_prog()
122 (off_t)block*cfg->block_size + (off_t)off, SEEK_SET); in lfs_filebd_prog()
138 LFS_ASSERT(c == bd->cfg->erase_value); in lfs_filebd_prog()
144 (off_t)block*cfg->block_size + (off_t)off, SEEK_SET); in lfs_filebd_prog()
162 int lfs_filebd_erase(const struct lfs_config *cfg, lfs_block_t block) { in lfs_filebd_erase() argument
163 LFS_FILEBD_TRACE("lfs_filebd_erase(%p, 0x%"PRIx32")", (void*)cfg, block); in lfs_filebd_erase()
164 lfs_filebd_t *bd = cfg->context; in lfs_filebd_erase()
167 LFS_ASSERT(block < cfg->block_count); in lfs_filebd_erase()
170 if (bd->cfg->erase_value != -1) { in lfs_filebd_erase()
171 off_t res1 = lseek(bd->fd, (off_t)block*cfg->block_size, SEEK_SET); in lfs_filebd_erase()
178 for (lfs_off_t i = 0; i < cfg->block_size; i++) { in lfs_filebd_erase()
179 ssize_t res2 = write(bd->fd, &(uint8_t){bd->cfg->erase_value}, 1); in lfs_filebd_erase()
192 int lfs_filebd_sync(const struct lfs_config *cfg) { in lfs_filebd_sync() argument
193 LFS_FILEBD_TRACE("lfs_filebd_sync(%p)", (void*)cfg); in lfs_filebd_sync()
195 lfs_filebd_t *bd = cfg->context; in lfs_filebd_sync()