tests: subsys: shell: shell_flash: use DEVICE_DT_GET

Obtain flash device at compile time using DEVICE_DT_GET. Also drop
useless static attribute from flash_dev.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
Gerard Marull-Paretas 2022-03-23 15:33:29 +01:00 committed by Carles Cufí
commit 05b2221341

View file

@ -35,7 +35,7 @@ static void test_flash_read(void)
"00000020: 61 62 63 |abc |",
};
const struct shell *shell = shell_backend_dummy_get_ptr();
static const struct device *flash_dev;
const struct device *flash_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_flash_controller));
const char *buf;
const int test_base = FLASH_SIMULATOR_BASE_OFFSET;
const int test_size = 0x24; /* 32-alignment required */
@ -47,10 +47,9 @@ static void test_flash_read(void)
for (i = 0; i < test_size; i++) {
data[i] = 'A' + i;
}
flash_dev = device_get_binding(DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL);
zassert_true(flash_dev != NULL,
"Simulated flash driver was not found!");
zassert_true(device_is_ready(flash_dev),
"Simulated flash driver not ready");
ret = flash_write(flash_dev, test_base, data, test_size);
zassert_equal(0, ret, "flash_write() failed: %d", ret);