samples: ms5837: 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 21:33:25 -07:00 committed by Carles Cufí
commit e30cfa42d4

View file

@ -15,12 +15,17 @@ LOG_MODULE_REGISTER(main);
void main(void)
{
struct sensor_value oversampling_rate = { 8192, 0 };
const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, meas_ms5837)));
const struct device *dev = DEVICE_DT_GET_ANY(meas_ms5837);
if (dev == NULL) {
LOG_ERR("Could not find MS5837 device, aborting test.");
return;
}
if (!device_is_ready(dev)) {
LOG_ERR("MS5837 device %s is not ready, aborting test.",
dev->name);
return;
}
if (sensor_attr_set(dev, SENSOR_CHAN_ALL, SENSOR_ATTR_OVERSAMPLING,
&oversampling_rate) != 0) {