From 05b222134124de3510721e64a1767da9919d7e65 Mon Sep 17 00:00:00 2001 From: Gerard Marull-Paretas Date: Wed, 23 Mar 2022 15:33:29 +0100 Subject: [PATCH] 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 --- tests/subsys/shell/shell_flash/src/shell_flash_test.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/subsys/shell/shell_flash/src/shell_flash_test.c b/tests/subsys/shell/shell_flash/src/shell_flash_test.c index 775a6423e01..a30f3c49126 100644 --- a/tests/subsys/shell/shell_flash/src/shell_flash_test.c +++ b/tests/subsys/shell/shell_flash/src/shell_flash_test.c @@ -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);