MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / list_device

Function list_device

components/finsh/cmd.c:876–935  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

874};
875
876long list_device(void)
877{
878 rt_base_t level;
879 list_get_next_t find_arg;
880 struct rt_object_information *info;
881 rt_list_t *obj_list[LIST_FIND_OBJ_NR];
882 rt_list_t *next = (rt_list_t *)RT_NULL;
883 const char *device_type;
884
885 int maxlen;
886 const char *item_title = "device";
887
888 list_find_init(&find_arg, RT_Object_Class_Device, obj_list, sizeof(obj_list) / sizeof(obj_list[0]));
889 info = rt_list_entry(find_arg.list, struct rt_object_information, object_list);
890
891 maxlen = RT_NAME_MAX;
892
893 rt_kprintf("%-*.*s type ref count\n", maxlen, maxlen, item_title);
894 object_split(maxlen);
895 rt_kprintf(" -------------------- ----------\n");
896 do
897 {
898 next = list_get_next(next, &find_arg);
899 {
900 int i;
901 for (i = 0; i < find_arg.nr_out; i++)
902 {
903 struct rt_object *obj;
904 struct rt_device *device;
905
906 obj = rt_list_entry(obj_list[i], struct rt_object, list);
907 level = rt_spin_lock_irqsave(&info->spinlock);
908 if ((obj->type & ~RT_Object_Class_Static) != find_arg.type)
909 {
910 rt_spin_unlock_irqrestore(&info->spinlock, level);
911 continue;
912 }
913
914 rt_spin_unlock_irqrestore(&info->spinlock, level);
915
916 device = (struct rt_device *)obj;
917 device_type = "Unknown";
918 if (device->type < RT_Device_Class_Unknown &&
919 device_type_str[device->type] != RT_NULL)
920 {
921 device_type = device_type_str[device->type];
922 }
923 rt_kprintf("%-*.*s %-20s %-8d\n",
924 maxlen, RT_NAME_MAX,
925 device->parent.name,
926 device_type,
927 device->ref_count);
928
929 }
930 }
931 }
932 while (next != (rt_list_t *)RT_NULL);
933

Callers 2

ifFunction · 0.70
cmd_listFunction · 0.70

Calls 6

rt_kprintfFunction · 0.85
list_find_initFunction · 0.70
object_splitFunction · 0.70
list_get_nextFunction · 0.70
rt_spin_lock_irqsaveFunction · 0.50

Tested by

no test coverage detected