@@ -68,6 +68,11 @@ static struct k_poll_event can_shell_rx_msgq_events[] = {
6868static void can_shell_tx_msgq_triggered_work_handler (struct k_work * work );
6969static void can_shell_rx_msgq_triggered_work_handler (struct k_work * work );
7070
71+ static bool device_is_can_and_ready (const struct device * dev )
72+ {
73+ return device_is_ready (dev ) && DEVICE_API_IS (can , dev );
74+ }
75+
7176#ifdef CONFIG_CAN_SHELL_SCRIPTING_FRIENDLY
7277static void can_shell_dummy_bypass_cb (const struct shell * sh , uint8_t * data , size_t len )
7378{
@@ -996,7 +1001,7 @@ static int cmd_can_recover(const struct shell *sh, size_t argc, char **argv)
9961001
9971002static void cmd_can_device_name (size_t idx , struct shell_static_entry * entry )
9981003{
999- const struct device * dev = shell_device_lookup (idx , NULL );
1004+ const struct device * dev = shell_device_filter (idx , device_is_can_and_ready );
10001005
10011006 entry -> syntax = (dev != NULL ) ? dev -> name : NULL ;
10021007 entry -> handler = NULL ;
@@ -1026,7 +1031,7 @@ static void cmd_can_mode(size_t idx, struct shell_static_entry *entry)
10261031
10271032static void cmd_can_device_name_mode (size_t idx , struct shell_static_entry * entry )
10281033{
1029- const struct device * dev = shell_device_lookup (idx , NULL );
1034+ const struct device * dev = shell_device_filter (idx , device_is_can_and_ready );
10301035
10311036 entry -> syntax = (dev != NULL ) ? dev -> name : NULL ;
10321037 entry -> handler = NULL ;
0 commit comments