Commit cd76ab34 authored by Adrien Ricciardi's avatar Adrien Ricciardi Committed by Fabio Baltieri
Browse files

fs: nvs: Simplified the initial loop in calc_free_space()



Replaced the initial loop that computes the initial free space
by a simple formula.

Signed-off-by: default avatarAdrien Ricciardi <aricciardi@baylibre.com>
parent 9acfd9d4
Loading
Loading
Loading
Loading
+7 −8
Original line number Diff line number Diff line
@@ -1309,14 +1309,13 @@ ssize_t nvs_calc_free_space(struct nvs_fs *fs)

	ate_size = nvs_al_size(fs, sizeof(struct nvs_ate));

	free_space = 0;
	for (uint16_t i = 1; i < fs->sector_count; i++) {
	/*
	 * There is always a closing ATE and a reserved ATE for
		 * deletion in each sector
	 * deletion in each sector.
	 * Take into account one less sector because it is reserved for the
	 * garbage collection.
	 */
		free_space += (fs->sector_size - (2 * ate_size));
	}
	free_space = (fs->sector_count - 1) * (fs->sector_size - (2 * ate_size));

	step_addr = fs->ate_wra;