@@ -169,6 +169,11 @@ static int find_sensor_trigger_device(const struct device *sensor)
169
169
return -1 ;
170
170
}
171
171
172
+ static bool sensor_device_check (const struct device * dev )
173
+ {
174
+ return DEVICE_API_IS (sensor , dev );
175
+ }
176
+
172
177
/* Forward declaration */
173
178
static void data_ready_trigger_handler (const struct device * sensor ,
174
179
const struct sensor_trigger * trigger );
@@ -544,8 +549,8 @@ static int cmd_get_sensor(const struct shell *sh, size_t argc, char *argv[])
544
549
}
545
550
546
551
dev = device_get_binding (argv [1 ]);
547
- if (dev == NULL ) {
548
- shell_error (sh , "Device unknown (%s)" , argv [1 ]);
552
+ if (dev == NULL || ! sensor_device_check ( dev ) ) {
553
+ shell_error (sh , "Sensor device unknown (%s)" , argv [1 ]);
549
554
k_mutex_unlock (& cmd_get_mutex );
550
555
return - ENODEV ;
551
556
}
@@ -613,8 +618,8 @@ static int cmd_sensor_attr_set(const struct shell *shell_ptr, size_t argc, char
613
618
int rc ;
614
619
615
620
dev = device_get_binding (argv [1 ]);
616
- if (dev == NULL ) {
617
- shell_error (shell_ptr , "Device unknown (%s)" , argv [1 ]);
621
+ if (dev == NULL || ! sensor_device_check ( dev ) ) {
622
+ shell_error (shell_ptr , "Sensor device unknown (%s)" , argv [1 ]);
618
623
return - ENODEV ;
619
624
}
620
625
@@ -697,8 +702,8 @@ static int cmd_sensor_attr_get(const struct shell *shell_ptr, size_t argc, char
697
702
const struct device * dev ;
698
703
699
704
dev = device_get_binding (argv [1 ]);
700
- if (dev == NULL ) {
701
- shell_error (shell_ptr , "Device unknown (%s)" , argv [1 ]);
705
+ if (dev == NULL || ! sensor_device_check ( dev ) ) {
706
+ shell_error (shell_ptr , "Sensor device unknown (%s)" , argv [1 ]);
702
707
return - ENODEV ;
703
708
}
704
709
@@ -848,7 +853,7 @@ SHELL_DYNAMIC_CMD_CREATE(dsub_device_name, device_name_get);
848
853
849
854
static void device_name_get (size_t idx , struct shell_static_entry * entry )
850
855
{
851
- const struct device * dev = shell_device_lookup (idx , NULL );
856
+ const struct device * dev = shell_device_filter (idx , sensor_device_check );
852
857
853
858
current_cmd_ctx = CTX_GET ;
854
859
entry -> syntax = (dev != NULL ) ? dev -> name : NULL ;
@@ -1047,8 +1052,8 @@ static int cmd_trig_sensor(const struct shell *sh, size_t argc, char **argv)
1047
1052
1048
1053
/* Parse device name */
1049
1054
dev = device_get_binding (argv [1 ]);
1050
- if (dev == NULL ) {
1051
- shell_error (sh , "Device unknown (%s)" , argv [1 ]);
1055
+ if (dev == NULL || ! sensor_device_check ( dev ) ) {
1056
+ shell_error (sh , "Sensor device unknown (%s)" , argv [1 ]);
1052
1057
return - ENODEV ;
1053
1058
}
1054
1059
0 commit comments