samples: sensor: ccs811: 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/ccs811/src/main.c b/samples/sensor/ccs811/src/main.c
index 74e579a..6862c67 100644
--- a/samples/sensor/ccs811/src/main.c
+++ b/samples/sensor/ccs811/src/main.c
@@ -113,12 +113,12 @@
void main(void)
{
- const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, ams_ccs811)));
+ const struct device *dev = DEVICE_DT_GET_ONE(ams_ccs811);
struct ccs811_configver_type cfgver;
int rc;
- if (!dev) {
- printk("Failed to get device binding");
+ if (!device_is_ready(dev)) {
+ printk("Device %s is not ready\n", dev->name);
return;
}