samples: boards: reel_board: mesh_badge: use DEVICE_DT_GET

Obtain flash device at compile time using DEVICE_DT_GET.

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

View file

@ -7,6 +7,7 @@
#include <zephyr.h> #include <zephyr.h>
#include <device.h> #include <device.h>
#include <devicetree.h>
#include <drivers/gpio.h> #include <drivers/gpio.h>
#include <display/cfb.h> #include <display/cfb.h>
#include <sys/printk.h> #include <sys/printk.h>
@ -577,9 +578,12 @@ static int configure_leds(void)
static int erase_storage(void) static int erase_storage(void)
{ {
const struct device *dev; const struct device *dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_flash_controller));
dev = device_get_binding(DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL); if (!device_is_ready(dev)) {
printk("Flash device not ready\n");
return -ENODEV;
}
return flash_erase(dev, FLASH_AREA_OFFSET(storage), return flash_erase(dev, FLASH_AREA_OFFSET(storage),
FLASH_AREA_SIZE(storage)); FLASH_AREA_SIZE(storage));