samples: lis2dh: drop device_get_binding/DT_INST

Use DEVICE_DT_GET_ANY.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
Martí Bolívar 2021-04-26 14:04:30 -07:00 committed by Carles Cufí
commit 363a1d6c84

View file

@ -50,11 +50,14 @@ static void trigger_handler(const struct device *dev,
void main(void)
{
const struct device *sensor = device_get_binding(DT_LABEL(DT_INST(0, st_lis2dh)));
const struct device *sensor = DEVICE_DT_GET_ANY(st_lis2dh);
if (sensor == NULL) {
printf("Could not get %s device\n",
DT_LABEL(DT_INST(0, st_lis2dh)));
printf("No device found\n");
return;
}
if (!device_is_ready(sensor)) {
printf("Device %s is not ready\n", sensor->name);
return;
}