mirror of
				https://github.com/eledio-devices/thirdparty-littlefs.git
				synced 2025-10-31 16:14:16 +01:00 
			
		
		
		
	Removed words variable from lfs struct
This commit is contained in:
		
							
								
								
									
										10
									
								
								lfs.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								lfs.c
									
									
									
									
									
								
							| @@ -859,11 +859,12 @@ int lfs_dir_rewind(lfs_t *lfs, lfs_dir_t *dir) { | |||||||
| /// File index list operations /// | /// File index list operations /// | ||||||
| static int lfs_index(lfs_t *lfs, lfs_off_t *off) { | static int lfs_index(lfs_t *lfs, lfs_off_t *off) { | ||||||
|     lfs_off_t i = 0; |     lfs_off_t i = 0; | ||||||
|  |     lfs_size_t words = lfs->cfg->block_size / 4; | ||||||
|  |  | ||||||
|     while (*off >= lfs->cfg->block_size) { |     while (*off >= lfs->cfg->block_size) { | ||||||
|         i += 1; |         i += 1; | ||||||
|         *off -= lfs->cfg->block_size; |         *off -= lfs->cfg->block_size; | ||||||
|         *off += 4*lfs_min(lfs_ctz(i)+1, lfs->words-1); |         *off += 4*lfs_min(lfs_ctz(i)+1, words-1); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     return i; |     return i; | ||||||
| @@ -881,11 +882,12 @@ static int lfs_index_find(lfs_t *lfs, | |||||||
|  |  | ||||||
|     lfs_off_t current = lfs_index(lfs, &(lfs_off_t){size-1}); |     lfs_off_t current = lfs_index(lfs, &(lfs_off_t){size-1}); | ||||||
|     lfs_off_t target = lfs_index(lfs, &pos); |     lfs_off_t target = lfs_index(lfs, &pos); | ||||||
|  |     lfs_size_t words = lfs->cfg->block_size / 4; | ||||||
|  |  | ||||||
|     while (current > target) { |     while (current > target) { | ||||||
|         lfs_size_t skip = lfs_min( |         lfs_size_t skip = lfs_min( | ||||||
|                 lfs_npw2(current-target+1) - 1, |                 lfs_npw2(current-target+1) - 1, | ||||||
|                 lfs_min(lfs_ctz(current)+1, lfs->words-1) - 1); |                 lfs_min(lfs_ctz(current)+1, words-1) - 1); | ||||||
|  |  | ||||||
|         int err = lfs_cache_read(lfs, rcache, pcache, head, 4*skip, &head, 4); |         int err = lfs_cache_read(lfs, rcache, pcache, head, 4*skip, &head, 4); | ||||||
|         if (err) { |         if (err) { | ||||||
| @@ -945,7 +947,8 @@ static int lfs_index_extend(lfs_t *lfs, | |||||||
|  |  | ||||||
|     // append block |     // append block | ||||||
|     index += 1; |     index += 1; | ||||||
|     lfs_size_t skips = lfs_min(lfs_ctz(index)+1, lfs->words-1); |     lfs_size_t words = lfs->cfg->block_size / 4; | ||||||
|  |     lfs_size_t skips = lfs_min(lfs_ctz(index)+1, words-1); | ||||||
|  |  | ||||||
|     for (lfs_off_t i = 0; i < skips; i++) { |     for (lfs_off_t i = 0; i < skips; i++) { | ||||||
|         int err = lfs_cache_prog(lfs, pcache, *block, 4*i, &head, 4); |         int err = lfs_cache_prog(lfs, pcache, *block, 4*i, &head, 4); | ||||||
| @@ -1538,7 +1541,6 @@ int lfs_rename(lfs_t *lfs, const char *oldpath, const char *newpath) { | |||||||
| /// Filesystem operations /// | /// Filesystem operations /// | ||||||
| static int lfs_init(lfs_t *lfs, const struct lfs_config *cfg) { | static int lfs_init(lfs_t *lfs, const struct lfs_config *cfg) { | ||||||
|     lfs->cfg = cfg; |     lfs->cfg = cfg; | ||||||
|     lfs->words = lfs->cfg->block_size / sizeof(uint32_t); |  | ||||||
|  |  | ||||||
|     // setup read cache |     // setup read cache | ||||||
|     lfs->rcache.block = 0xffffffff; |     lfs->rcache.block = 0xffffffff; | ||||||
|   | |||||||
							
								
								
									
										1
									
								
								lfs.h
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								lfs.h
									
									
									
									
									
								
							| @@ -210,7 +210,6 @@ typedef struct lfs_free { | |||||||
| // littlefs type | // littlefs type | ||||||
| typedef struct lfs { | typedef struct lfs { | ||||||
|     const struct lfs_config *cfg; |     const struct lfs_config *cfg; | ||||||
|     lfs_size_t words;       // number of 32-bit words that can fit in a block |  | ||||||
|  |  | ||||||
|     lfs_block_t root[2]; |     lfs_block_t root[2]; | ||||||
|     lfs_dir_t *scratch; |     lfs_dir_t *scratch; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user