From 3a223bc45bfa00d46419f203e4dff45e1a3d5665 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Thu, 14 Jul 2022 11:08:27 -0500 Subject: [PATCH] samples: sensor: hts221: Convert to use DEVICE_DT_GET_ONE Move to use DEVICE_DT_GET_ONE instead of device_get_binding. This is more generic than the hardcoded string that was being used. Signed-off-by: Kumar Gala --- samples/sensor/hts221/src/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/sensor/hts221/src/main.c b/samples/sensor/hts221/src/main.c index 7122c865e2b..ae9f7f4e5e8 100644 --- a/samples/sensor/hts221/src/main.c +++ b/samples/sensor/hts221/src/main.c @@ -48,10 +48,10 @@ static void hts221_handler(const struct device *dev, void main(void) { - const struct device *dev = device_get_binding("HTS221"); + const struct device *dev = DEVICE_DT_GET_ONE(st_hts221); - if (dev == NULL) { - printf("Could not get HTS221 device\n"); + if (!device_is_ready(dev)) { + printk("sensor: device not ready.\n"); return; }