modbus: serial: Convert to DEVICE_DT_GET

Move to using DEVICE_DT_GET so we can phase out DT_LABEL.

Signed-off-by: Kumar Gala <galak@kernel.org>
This commit is contained in:
Kumar Gala 2022-06-27 11:35:27 -05:00 committed by Carles Cufí
commit e1e8179690
3 changed files with 3 additions and 7 deletions

View file

@ -35,7 +35,7 @@ DT_INST_FOREACH_STATUS_OKAY(MB_RTU_DEFINE_GPIO_CFGS)
(&prop##_cfg_##inst), (NULL))
#define MODBUS_DT_GET_SERIAL_DEV(inst) { \
.dev_name = DT_INST_BUS_LABEL(inst), \
.dev = DEVICE_DT_GET(DT_INST_BUS(inst)), \
.de = MB_RTU_ASSIGN_GPIO_CFG(inst, de_gpios), \
.re = MB_RTU_ASSIGN_GPIO_CFG(inst, re_gpios), \
},

View file

@ -81,8 +81,6 @@
#define MODBUS_ADU_PROTO_ID 0x0000
struct modbus_serial_config {
/* UART device name */
const char *dev_name;
/* UART device */
const struct device *dev;
/* RTU timeout (maximum inter-frame delay) */

View file

@ -516,10 +516,8 @@ int modbus_serial_init(struct modbus_context *ctx,
return -ENOTSUP;
}
cfg->dev = device_get_binding(cfg->dev_name);
if (cfg->dev == NULL) {
LOG_ERR("Failed to get UART device %s",
cfg->dev_name);
if (!device_is_ready(cfg->dev)) {
LOG_ERR("Bus device %s is not ready", cfg->dev->name);
return -ENODEV;
}