samples: sensor: lps22hb: 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>
This commit is contained in:
Benjamin Björnsson 2022-06-23 16:58:16 +02:00 committed by Maureen Helm
parent d35c55d437
commit fc518e1eb0

View file

@ -43,10 +43,10 @@ static void process_sample(const struct device *dev)
void main(void)
{
const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, st_lps22hb_press)));
const struct device *dev = DEVICE_DT_GET_ONE(st_lps22hb_press);
if (dev == NULL) {
printf("Could not get LPS22HB device\n");
if (!device_is_ready(dev)) {
printf("Device %s is not ready\n", dev->name);
return;
}