From c96f8f9c294f56e3f0e201709b6f38ef8e3d4162 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Tue, 5 Jul 2022 21:47:34 -0500 Subject: [PATCH] samples: lsm6dso: Convert 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. Also, Removed 'lsm6dso' from board & sample yaml's and move to just filtering based on devicetree compat. Signed-off-by: Kumar Gala --- boards/arm/stm32l562e_dk/stm32l562e_dk.yaml | 1 - boards/arm/stm32l562e_dk/stm32l562e_dk_ns.yaml | 1 - samples/sensor/lsm6dso/sample.yaml | 2 +- samples/sensor/lsm6dso/src/main.c | 15 +++------------ 4 files changed, 4 insertions(+), 15 deletions(-) diff --git a/boards/arm/stm32l562e_dk/stm32l562e_dk.yaml b/boards/arm/stm32l562e_dk/stm32l562e_dk.yaml index 16462654f6..614005cf15 100644 --- a/boards/arm/stm32l562e_dk/stm32l562e_dk.yaml +++ b/boards/arm/stm32l562e_dk/stm32l562e_dk.yaml @@ -8,7 +8,6 @@ toolchain: supported: - gpio - i2c - - lsm6dso - lptim - pwm - watchdog diff --git a/boards/arm/stm32l562e_dk/stm32l562e_dk_ns.yaml b/boards/arm/stm32l562e_dk/stm32l562e_dk_ns.yaml index 44a9779580..f8abd71639 100644 --- a/boards/arm/stm32l562e_dk/stm32l562e_dk_ns.yaml +++ b/boards/arm/stm32l562e_dk/stm32l562e_dk_ns.yaml @@ -8,7 +8,6 @@ toolchain: supported: - gpio - i2c - - lsm6dso - lptim - dac - spi diff --git a/samples/sensor/lsm6dso/sample.yaml b/samples/sensor/lsm6dso/sample.yaml index dd357dc38a..9edc9b8716 100644 --- a/samples/sensor/lsm6dso/sample.yaml +++ b/samples/sensor/lsm6dso/sample.yaml @@ -4,8 +4,8 @@ tests: sample.sensor.lsm6dso: harness: console tags: sensors - depends_on: lsm6dso timeout: 15 + filter: dt_compat_enabled("st,lsm6dso") harness_config: type: multi_line ordered: true diff --git a/samples/sensor/lsm6dso/src/main.c b/samples/sensor/lsm6dso/src/main.c index 9cfe59442b..5dc90b35f8 100644 --- a/samples/sensor/lsm6dso/src/main.c +++ b/samples/sensor/lsm6dso/src/main.c @@ -9,15 +9,6 @@ #include #include -#define LSM6DSO DT_INST(0, st_lsm6dso) - -#if DT_NODE_HAS_STATUS(LSM6DSO, okay) -#define LSM6DSO_LABEL DT_LABEL(LSM6DSO) -#else -#error Your devicetree has no enabled nodes with compatible "st,lsm6dso" -#define LSM6DSO_LABEL "" -#endif - static inline float out_ev(struct sensor_value *val) { return (val->val1 + (float)val->val2 / 1000000); @@ -116,10 +107,10 @@ static void test_polling_mode(const struct device *dev) void main(void) { - const struct device *dev = device_get_binding(LSM6DSO_LABEL); + const struct device *dev = DEVICE_DT_GET_ONE(st_lsm6dso); - if (dev == NULL) { - printf("No device \"%s\" found.\n", LSM6DSO_LABEL); + if (!device_is_ready(dev)) { + printk("%s: device not ready.\n", dev->name); return; }