Skip to content

Commit fca5719

Browse files
galakcarlescufi
authored andcommitted
samples: ti_hdc: 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: Kumar Gala <[email protected]>
1 parent d9774bd commit fca5719

File tree

1 file changed

+5
-2
lines changed
  • samples/sensor/ti_hdc/src

1 file changed

+5
-2
lines changed

samples/sensor/ti_hdc/src/main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515
void main(void)
1616
{
1717
printk("Running on %s!\n", CONFIG_ARCH);
18-
const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, ti_hdc)));
18+
const struct device *dev = DEVICE_DT_GET_ONE(ti_hdc);
1919

20-
__ASSERT(dev != NULL, "Failed to get device binding");
20+
if (!device_is_ready(dev)) {
21+
printk("sensor: device not ready.\n");
22+
return;
23+
}
2124

2225
printk("Dev %p name %s is ready!\n", dev, dev->name);
2326

0 commit comments

Comments
 (0)