samples: lps22hh: Convert to use DEVICE_DT_GET_ONE

Move to use DEVICE_DT_GET_ONE instead of device_get_binding.  This
is more generic than the hardcoded string that was being used.

Signed-off-by: Kumar Gala <galak@kernel.org>
This commit is contained in:
Kumar Gala 2022-07-14 11:09:19 -05:00 committed by Marti Bolivar
parent 3a223bc45b
commit 6b33c03892

View file

@ -50,10 +50,10 @@ static void lps22hh_handler(const struct device *dev,
void main(void)
{
const struct device *dev = device_get_binding("LPS22HH");
const struct device *dev = DEVICE_DT_GET_ONE(st_lps22hh);
if (dev == NULL) {
printf("Could not get LPS22HH device\n");
if (!device_is_ready(dev)) {
printk("sensor: device not ready.\n");
return;
}