From 5be2c81222bc90bc83745f883c7e319d29a0fdb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Bj=C3=B6rnsson?= Date: Mon, 27 Jun 2022 07:01:03 +0200 Subject: [PATCH] samples: sensor: sm351lt: Convert sample to use DEVICE_DT_GET_ONE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move to use DEVICE_DT_GET_ONE instead of device_get_binding as we work on phasing out use of DTS 'label' property. Signed-off-by: Benjamin Björnsson --- samples/sensor/sm351lt/src/main.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/samples/sensor/sm351lt/src/main.c b/samples/sensor/sm351lt/src/main.c index 16ab2c818e7..afa9d56c035 100644 --- a/samples/sensor/sm351lt/src/main.c +++ b/samples/sensor/sm351lt/src/main.c @@ -41,11 +41,10 @@ static void trigger_handler(const struct device *dev, void main(void) { - const struct device *sensor = device_get_binding(DT_LABEL(DT_INST(0, honeywell_sm351lt))); + const struct device *sensor = DEVICE_DT_GET_ONE(honeywell_sm351lt); - if (sensor == NULL) { - printf("Could not get %s device\n", - DT_LABEL(DT_INST(0, honeywell_sm351lt))); + if (!device_is_ready(sensor)) { + printk("Device %s is not ready\n", sensor->name); return; }