File tree Expand file tree Collapse file tree 2 files changed +2
-64
lines changed Expand file tree Collapse file tree 2 files changed +2
-64
lines changed Original file line number Diff line number Diff line change @@ -111,38 +111,7 @@ rt_err_t rt_device_init_all(void)
111111 */
112112rt_device_t rt_device_find (const char * name )
113113{
114- struct rt_object * object ;
115- struct rt_list_node * node ;
116- struct rt_object_information * information ;
117-
118- /* enter critical */
119- if (rt_thread_self () != RT_NULL )
120- rt_enter_critical ();
121-
122- /* try to find device object */
123- information = rt_object_get_information (RT_Object_Class_Device );
124- RT_ASSERT (information != RT_NULL );
125- for (node = information -> object_list .next ;
126- node != & (information -> object_list );
127- node = node -> next )
128- {
129- object = rt_list_entry (node , struct rt_object , list );
130- if (rt_strncmp (object -> name , name , RT_NAME_MAX ) == 0 )
131- {
132- /* leave critical */
133- if (rt_thread_self () != RT_NULL )
134- rt_exit_critical ();
135-
136- return (rt_device_t )object ;
137- }
138- }
139-
140- /* leave critical */
141- if (rt_thread_self () != RT_NULL )
142- rt_exit_critical ();
143-
144- /* not found */
145- return RT_NULL ;
114+ return (rt_device_t )rt_object_find (name , RT_Object_Class_Device );
146115}
147116RTM_EXPORT (rt_device_find );
148117
Original file line number Diff line number Diff line change @@ -862,38 +862,7 @@ RTM_EXPORT(rt_thread_timeout);
862862 */
863863rt_thread_t rt_thread_find (char * name )
864864{
865- struct rt_object_information * information ;
866- struct rt_object * object ;
867- struct rt_list_node * node ;
868-
869- /* enter critical */
870- if (rt_thread_self () != RT_NULL )
871- rt_enter_critical ();
872-
873- /* try to find device object */
874- information = rt_object_get_information (RT_Object_Class_Thread );
875- RT_ASSERT (information != RT_NULL );
876- for (node = information -> object_list .next ;
877- node != & (information -> object_list );
878- node = node -> next )
879- {
880- object = rt_list_entry (node , struct rt_object , list );
881- if (rt_strncmp (object -> name , name , RT_NAME_MAX ) == 0 )
882- {
883- /* leave critical */
884- if (rt_thread_self () != RT_NULL )
885- rt_exit_critical ();
886-
887- return (rt_thread_t )object ;
888- }
889- }
890-
891- /* leave critical */
892- if (rt_thread_self () != RT_NULL )
893- rt_exit_critical ();
894-
895- /* not found */
896- return RT_NULL ;
865+ return (rt_thread_t )rt_object_find (name , RT_Object_Class_Thread );
897866}
898867RTM_EXPORT (rt_thread_find );
899868
You can’t perform that action at this time.
0 commit comments