samples: mcp9808: 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:03:19 -07:00 committed by Carles Cufí
commit 37f0ca0229

View file

@ -106,12 +106,15 @@ static void trigger_handler(const struct device *dev,
void main(void) void main(void)
{ {
const char *const devname = DT_LABEL(DT_INST(0, microchip_mcp9808)); const struct device *dev = DEVICE_DT_GET_ANY(microchip_mcp9808);
const struct device *dev = device_get_binding(devname);
int rc; int rc;
if (dev == NULL) { if (dev == NULL) {
printf("Device %s not found.\n", devname); printf("Device not found.\n");
return;
}
if (!device_is_ready(dev)) {
printf("Device %s is not ready.\n", dev->name);
return; return;
} }