Skip to content
Permalink
Browse files

drivers/flash/flash_simulator: Allow unaligned read

This commit adds the default configuration to the flash_simualtor
to allow unaligned reads.
Disable this option when testing to increase test coverage.

Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
  • Loading branch information...
rakons authored and carlescufi committed May 27, 2019
1 parent e58df2c commit 617c6fdb242dc9d13fb8b93ccf0f1aa82cf65059
Showing with 15 additions and 3 deletions.
  1. +9 −0 drivers/flash/Kconfig.simulator
  2. +5 −3 drivers/flash/flash_simulator.c
  3. +1 −0 tests/drivers/flash_simulator/prj.conf
@@ -16,6 +16,15 @@ menuconfig FLASH_SIMULATOR

if FLASH_SIMULATOR

config FLASH_SIMULATOR_UNALIGNED_READ
bool
prompt "Allow read access to be unaligned"
default y
help
If selected, the reading operation does not check if access is aligned.
Disable this option only if you want to simulate
a specific FLASH interface that requires aligned read access.

config FLASH_SIMULATOR_DOUBLE_WRITES
bool
prompt "Allow program units to be programmed more than once"
@@ -139,9 +139,11 @@ static int flash_sim_read(struct device *dev, const off_t offset, void *data,
return -EINVAL;
}

if ((offset % FLASH_SIMULATOR_PROG_UNIT) ||
(len % FLASH_SIMULATOR_PROG_UNIT)) {
return -EINVAL;
if (!IS_ENABLED(CONFIG_FLASH_SIMULATOR_UNALIGNED_READ)) {
if ((offset % FLASH_SIMULATOR_PROG_UNIT) ||
(len % FLASH_SIMULATOR_PROG_UNIT)) {
return -EINVAL;
}
}

STATS_INC(flash_sim_stats, flash_read_calls);
@@ -3,3 +3,4 @@ CONFIG_FLASH=y
CONFIG_FLASH_SIMULATOR=y
CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES=n
CONFIG_FLASH_SIMULATOR_ERASE_PROTECT=y
CONFIG_FLASH_SIMULATOR_UNALIGNED_READ=n

0 comments on commit 617c6fd

Please sign in to comment.
You can’t perform that action at this time.