Skip to content

Commit e1e8179

Browse files
galakcarlescufi
authored andcommitted
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 <[email protected]>
1 parent e63643d commit e1e8179

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

subsys/modbus/modbus_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ DT_INST_FOREACH_STATUS_OKAY(MB_RTU_DEFINE_GPIO_CFGS)
3535
(&prop##_cfg_##inst), (NULL))
3636

3737
#define MODBUS_DT_GET_SERIAL_DEV(inst) { \
38-
.dev_name = DT_INST_BUS_LABEL(inst), \
38+
.dev = DEVICE_DT_GET(DT_INST_BUS(inst)), \
3939
.de = MB_RTU_ASSIGN_GPIO_CFG(inst, de_gpios), \
4040
.re = MB_RTU_ASSIGN_GPIO_CFG(inst, re_gpios), \
4141
},

subsys/modbus/modbus_internal.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@
8181
#define MODBUS_ADU_PROTO_ID 0x0000
8282

8383
struct modbus_serial_config {
84-
/* UART device name */
85-
const char *dev_name;
8684
/* UART device */
8785
const struct device *dev;
8886
/* RTU timeout (maximum inter-frame delay) */

subsys/modbus/modbus_serial.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -516,10 +516,8 @@ int modbus_serial_init(struct modbus_context *ctx,
516516
return -ENOTSUP;
517517
}
518518

519-
cfg->dev = device_get_binding(cfg->dev_name);
520-
if (cfg->dev == NULL) {
521-
LOG_ERR("Failed to get UART device %s",
522-
cfg->dev_name);
519+
if (!device_is_ready(cfg->dev)) {
520+
LOG_ERR("Bus device %s is not ready", cfg->dev->name);
523521
return -ENODEV;
524522
}
525523

0 commit comments

Comments
 (0)