Skip to content

Commit ef7ed1c

Browse files
committed
drivers: can: shell: use shell_fprintf_normal instead of shell_fprintf
Due to the introduction of `shell_xxx_impl` wrapper functions in PR zephyrproject-rtos#75340 and rename to `shell_fprintf_xxx` in PR zephyrproject-rtos#77192 we can minimize caller overhead by eliminating direct `color` parameter passing. Signed-off-by: Pisit Sawangvonganan <[email protected]>
1 parent a3f71f1 commit ef7ed1c

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

drivers/can/can_shell.c

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -90,41 +90,41 @@ static void can_shell_print_frame(const struct shell *sh, const struct device *d
9090

9191
#ifdef CONFIG_CAN_RX_TIMESTAMP
9292
/* Timestamp */
93-
shell_fprintf(sh, SHELL_NORMAL, "(%05d) ", frame->timestamp);
93+
shell_fprintf_normal(sh, "(%05d) ", frame->timestamp);
9494
#endif /* CONFIG_CAN_RX_TIMESTAMP */
9595

96-
shell_fprintf(sh, SHELL_NORMAL, "%s ", dev->name);
96+
shell_fprintf_normal(sh, "%s ", dev->name);
9797

9898
#ifdef CONFIG_CAN_FD_MODE
9999
/* Flags */
100-
shell_fprintf(sh, SHELL_NORMAL, "%c%c ",
101-
(frame->flags & CAN_FRAME_BRS) == 0 ? '-' : 'B',
102-
(frame->flags & CAN_FRAME_ESI) == 0 ? '-' : 'P');
100+
shell_fprintf_normal(sh, "%c%c ",
101+
(frame->flags & CAN_FRAME_BRS) == 0 ? '-' : 'B',
102+
(frame->flags & CAN_FRAME_ESI) == 0 ? '-' : 'P');
103103
#endif /* CONFIG_CAN_FD_MODE */
104104

105105
/* CAN ID */
106-
shell_fprintf(sh, SHELL_NORMAL, "%*s%0*x ",
107-
(frame->flags & CAN_FRAME_IDE) != 0 ? 0 : 5, "",
108-
(frame->flags & CAN_FRAME_IDE) != 0 ? 8 : 3,
109-
(frame->flags & CAN_FRAME_IDE) != 0 ?
110-
frame->id & CAN_EXT_ID_MASK : frame->id & CAN_STD_ID_MASK);
106+
shell_fprintf_normal(sh, "%*s%0*x ",
107+
(frame->flags & CAN_FRAME_IDE) != 0 ? 0 : 5, "",
108+
(frame->flags & CAN_FRAME_IDE) != 0 ? 8 : 3,
109+
(frame->flags & CAN_FRAME_IDE) != 0 ?
110+
frame->id & CAN_EXT_ID_MASK : frame->id & CAN_STD_ID_MASK);
111111

112112
/* DLC as number of bytes */
113-
shell_fprintf(sh, SHELL_NORMAL, "%s[%0*d] ",
114-
(frame->flags & CAN_FRAME_FDF) != 0 ? "" : " ",
115-
(frame->flags & CAN_FRAME_FDF) != 0 ? 2 : 1,
116-
nbytes);
113+
shell_fprintf_normal(sh, "%s[%0*d] ",
114+
(frame->flags & CAN_FRAME_FDF) != 0 ? "" : " ",
115+
(frame->flags & CAN_FRAME_FDF) != 0 ? 2 : 1,
116+
nbytes);
117117

118118
/* Data payload */
119119
if ((frame->flags & CAN_FRAME_RTR) != 0) {
120-
shell_fprintf(sh, SHELL_NORMAL, "remote transmission request");
120+
shell_fprintf_normal(sh, "remote transmission request");
121121
} else {
122122
for (i = 0; i < nbytes; i++) {
123-
shell_fprintf(sh, SHELL_NORMAL, "%02x ", frame->data[i]);
123+
shell_fprintf_normal(sh, "%02x ", frame->data[i]);
124124
}
125125
}
126126

127-
shell_fprintf(sh, SHELL_NORMAL, "\n");
127+
shell_fprintf_normal(sh, "\n");
128128

129129
#ifdef CONFIG_CAN_SHELL_SCRIPTING_FRIENDLY
130130
shell_set_bypass(sh, NULL);
@@ -262,14 +262,14 @@ static void can_shell_print_extended_modes(const struct shell *sh, can_mode_t ca
262262
/* Lookup symbolic mode name */
263263
for (i = 0; i < ARRAY_SIZE(can_shell_mode_map); i++) {
264264
if (BIT(bit) == can_shell_mode_map[i].mode) {
265-
shell_fprintf(sh, SHELL_NORMAL, "%s ", can_shell_mode_map[i].name);
265+
shell_fprintf_normal(sh, "%s ", can_shell_mode_map[i].name);
266266
break;
267267
}
268268
}
269269

270270
if (i == ARRAY_SIZE(can_shell_mode_map)) {
271271
/* Symbolic name not found, use raw mode */
272-
shell_fprintf(sh, SHELL_NORMAL, "0x%08x ", (can_mode_t)BIT(bit));
272+
shell_fprintf_normal(sh, "0x%08x ", (can_mode_t)BIT(bit));
273273
}
274274
}
275275
}
@@ -373,13 +373,13 @@ static int cmd_can_show(const struct shell *sh, size_t argc, char **argv)
373373
shell_print(sh, "max std filters: %d", max_std_filters);
374374
shell_print(sh, "max ext filters: %d", max_ext_filters);
375375

376-
shell_fprintf(sh, SHELL_NORMAL, "capabilities: normal ");
376+
shell_fprintf_normal(sh, "capabilities: normal ");
377377
can_shell_print_extended_modes(sh, cap);
378-
shell_fprintf(sh, SHELL_NORMAL, "\n");
378+
shell_fprintf_normal(sh, "\n");
379379

380-
shell_fprintf(sh, SHELL_NORMAL, "mode: normal ");
380+
shell_fprintf_normal(sh, "mode: normal ");
381381
can_shell_print_extended_modes(sh, can_get_mode(dev));
382-
shell_fprintf(sh, SHELL_NORMAL, "\n");
382+
shell_fprintf_normal(sh, "\n");
383383

384384
shell_print(sh, "state: %s", can_shell_state_to_string(state));
385385
shell_print(sh, "rx errors: %d", err_cnt.rx_err_cnt);

0 commit comments

Comments
 (0)