drivers: sensor: dht: Convert sample to use DEVICE_DT_GET_ONE
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 <benjamin.bjornsson@gmail.com>
diff --git a/samples/sensor/dht/src/main.c b/samples/sensor/dht/src/main.c
index a9a39b8..d3460e9 100644
--- a/samples/sensor/dht/src/main.c
+++ b/samples/sensor/dht/src/main.c
@@ -32,11 +32,10 @@
void main(void)
{
- const char *const label = DT_LABEL(DT_INST(0, aosong_dht));
- const struct device *dht22 = device_get_binding(label);
+ const struct device *dht22 = DEVICE_DT_GET_ONE(aosong_dht);
- if (!dht22) {
- printf("Failed to find sensor %s\n", label);
+ if (!device_is_ready(dht22)) {
+ printf("Device %s is not ready\n", dht22->name);
return;
}