samples: led_ws2812: drop device_get_binding

Use DEVICE_DT_GET.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
Martí Bolívar 2021-04-26 13:16:15 -07:00 committed by Carles Cufí
commit 1dbf6f7827

View file

@ -18,7 +18,7 @@ LOG_MODULE_REGISTER(main);
#include <drivers/spi.h>
#include <sys/util.h>
#define STRIP_LABEL DT_LABEL(DT_ALIAS(led_strip))
#define STRIP_NODE DT_ALIAS(led_strip)
#define STRIP_NUM_PIXELS DT_PROP(DT_ALIAS(led_strip), chain_length)
#define DELAY_TIME K_MSEC(50)
@ -33,17 +33,17 @@ static const struct led_rgb colors[] = {
struct led_rgb pixels[STRIP_NUM_PIXELS];
static const struct device *strip = DEVICE_DT_GET(STRIP_NODE);
void main(void)
{
const struct device *strip;
size_t cursor = 0, color = 0;
int rc;
strip = device_get_binding(STRIP_LABEL);
if (strip) {
LOG_INF("Found LED strip device %s", STRIP_LABEL);
if (device_is_ready(strip)) {
LOG_INF("Found LED strip device %s", strip->name);
} else {
LOG_ERR("LED strip device %s not found", STRIP_LABEL);
LOG_ERR("LED strip device %s is not ready", strip->name);
return;
}