@@ -280,6 +280,29 @@ static int vchiq_platform_init(struct platform_device *pdev, struct vchiq_state
280280 return 0 ;
281281}
282282
283+ int
284+ vchiq_platform_init_state (struct vchiq_state * state )
285+ {
286+ struct vchiq_arm_state * platform_state ;
287+
288+ platform_state = devm_kzalloc (state -> dev , sizeof (* platform_state ), GFP_KERNEL );
289+ if (!platform_state )
290+ return - ENOMEM ;
291+
292+ rwlock_init (& platform_state -> susp_res_lock );
293+
294+ init_completion (& platform_state -> ka_evt );
295+ atomic_set (& platform_state -> ka_use_count , 0 );
296+ atomic_set (& platform_state -> ka_use_ack_count , 0 );
297+ atomic_set (& platform_state -> ka_release_count , 0 );
298+
299+ platform_state -> state = state ;
300+
301+ state -> platform_state = (struct opaque_platform_state * )platform_state ;
302+
303+ return 0 ;
304+ }
305+
283306static struct vchiq_arm_state * vchiq_platform_get_arm_state (struct vchiq_state * state )
284307{
285308 return (struct vchiq_arm_state * )state -> platform_state ;
@@ -988,39 +1011,6 @@ vchiq_keepalive_thread_func(void *v)
9881011 return 0 ;
9891012}
9901013
991- int
992- vchiq_platform_init_state (struct vchiq_state * state )
993- {
994- struct vchiq_arm_state * platform_state ;
995- char threadname [16 ];
996-
997- platform_state = devm_kzalloc (state -> dev , sizeof (* platform_state ), GFP_KERNEL );
998- if (!platform_state )
999- return - ENOMEM ;
1000-
1001- snprintf (threadname , sizeof (threadname ), "vchiq-keep/%d" ,
1002- state -> id );
1003- platform_state -> ka_thread = kthread_create (& vchiq_keepalive_thread_func ,
1004- (void * )state , threadname );
1005- if (IS_ERR (platform_state -> ka_thread )) {
1006- dev_err (state -> dev , "couldn't create thread %s\n" , threadname );
1007- return PTR_ERR (platform_state -> ka_thread );
1008- }
1009-
1010- rwlock_init (& platform_state -> susp_res_lock );
1011-
1012- init_completion (& platform_state -> ka_evt );
1013- atomic_set (& platform_state -> ka_use_count , 0 );
1014- atomic_set (& platform_state -> ka_use_ack_count , 0 );
1015- atomic_set (& platform_state -> ka_release_count , 0 );
1016-
1017- platform_state -> state = state ;
1018-
1019- state -> platform_state = (struct opaque_platform_state * )platform_state ;
1020-
1021- return 0 ;
1022- }
1023-
10241014int
10251015vchiq_use_internal (struct vchiq_state * state , struct vchiq_service * service ,
10261016 enum USE_TYPE_E use_type )
@@ -1341,6 +1331,7 @@ void vchiq_platform_conn_state_changed(struct vchiq_state *state,
13411331 enum vchiq_connstate newstate )
13421332{
13431333 struct vchiq_arm_state * arm_state = vchiq_platform_get_arm_state (state );
1334+ char threadname [16 ];
13441335
13451336 dev_dbg (state -> dev , "suspend: %d: %s->%s\n" ,
13461337 state -> id , get_conn_state_name (oldstate ), get_conn_state_name (newstate ));
@@ -1355,7 +1346,17 @@ void vchiq_platform_conn_state_changed(struct vchiq_state *state,
13551346
13561347 arm_state -> first_connect = 1 ;
13571348 write_unlock_bh (& arm_state -> susp_res_lock );
1358- wake_up_process (arm_state -> ka_thread );
1349+ snprintf (threadname , sizeof (threadname ), "vchiq-keep/%d" ,
1350+ state -> id );
1351+ arm_state -> ka_thread = kthread_create (& vchiq_keepalive_thread_func ,
1352+ (void * )state ,
1353+ threadname );
1354+ if (IS_ERR (arm_state -> ka_thread )) {
1355+ dev_err (state -> dev , "suspend: Couldn't create thread %s\n" ,
1356+ threadname );
1357+ } else {
1358+ wake_up_process (arm_state -> ka_thread );
1359+ }
13591360}
13601361
13611362static const struct of_device_id vchiq_of_match [] = {
0 commit comments