@@ -588,6 +588,29 @@ static int vchiq_platform_init(struct platform_device *pdev, struct vchiq_state
588588 return 0 ;
589589}
590590
591+ int
592+ vchiq_platform_init_state (struct vchiq_state * state )
593+ {
594+ struct vchiq_arm_state * platform_state ;
595+
596+ platform_state = devm_kzalloc (state -> dev , sizeof (* platform_state ), GFP_KERNEL );
597+ if (!platform_state )
598+ return - ENOMEM ;
599+
600+ rwlock_init (& platform_state -> susp_res_lock );
601+
602+ init_completion (& platform_state -> ka_evt );
603+ atomic_set (& platform_state -> ka_use_count , 0 );
604+ atomic_set (& platform_state -> ka_use_ack_count , 0 );
605+ atomic_set (& platform_state -> ka_release_count , 0 );
606+
607+ platform_state -> state = state ;
608+
609+ state -> platform_state = (struct opaque_platform_state * )platform_state ;
610+
611+ return 0 ;
612+ }
613+
591614static struct vchiq_arm_state * vchiq_platform_get_arm_state (struct vchiq_state * state )
592615{
593616 return (struct vchiq_arm_state * )state -> platform_state ;
@@ -1335,39 +1358,6 @@ vchiq_keepalive_thread_func(void *v)
13351358 return 0 ;
13361359}
13371360
1338- int
1339- vchiq_platform_init_state (struct vchiq_state * state )
1340- {
1341- struct vchiq_arm_state * platform_state ;
1342- char threadname [16 ];
1343-
1344- platform_state = devm_kzalloc (state -> dev , sizeof (* platform_state ), GFP_KERNEL );
1345- if (!platform_state )
1346- return - ENOMEM ;
1347-
1348- snprintf (threadname , sizeof (threadname ), "vchiq-keep/%d" ,
1349- state -> id );
1350- platform_state -> ka_thread = kthread_create (& vchiq_keepalive_thread_func ,
1351- (void * )state , threadname );
1352- if (IS_ERR (platform_state -> ka_thread )) {
1353- dev_err (state -> dev , "couldn't create thread %s\n" , threadname );
1354- return PTR_ERR (platform_state -> ka_thread );
1355- }
1356-
1357- rwlock_init (& platform_state -> susp_res_lock );
1358-
1359- init_completion (& platform_state -> ka_evt );
1360- atomic_set (& platform_state -> ka_use_count , 0 );
1361- atomic_set (& platform_state -> ka_use_ack_count , 0 );
1362- atomic_set (& platform_state -> ka_release_count , 0 );
1363-
1364- platform_state -> state = state ;
1365-
1366- state -> platform_state = (struct opaque_platform_state * )platform_state ;
1367-
1368- return 0 ;
1369- }
1370-
13711361int
13721362vchiq_use_internal (struct vchiq_state * state , struct vchiq_service * service ,
13731363 enum USE_TYPE_E use_type )
@@ -1688,6 +1678,7 @@ void vchiq_platform_conn_state_changed(struct vchiq_state *state,
16881678 enum vchiq_connstate newstate )
16891679{
16901680 struct vchiq_arm_state * arm_state = vchiq_platform_get_arm_state (state );
1681+ char threadname [16 ];
16911682
16921683 dev_dbg (state -> dev , "suspend: %d: %s->%s\n" ,
16931684 state -> id , get_conn_state_name (oldstate ), get_conn_state_name (newstate ));
@@ -1702,7 +1693,17 @@ void vchiq_platform_conn_state_changed(struct vchiq_state *state,
17021693
17031694 arm_state -> first_connect = 1 ;
17041695 write_unlock_bh (& arm_state -> susp_res_lock );
1705- wake_up_process (arm_state -> ka_thread );
1696+ snprintf (threadname , sizeof (threadname ), "vchiq-keep/%d" ,
1697+ state -> id );
1698+ arm_state -> ka_thread = kthread_create (& vchiq_keepalive_thread_func ,
1699+ (void * )state ,
1700+ threadname );
1701+ if (IS_ERR (arm_state -> ka_thread )) {
1702+ dev_err (state -> dev , "suspend: Couldn't create thread %s\n" ,
1703+ threadname );
1704+ } else {
1705+ wake_up_process (arm_state -> ka_thread );
1706+ }
17061707}
17071708
17081709static const struct of_device_id vchiq_of_match [] = {
0 commit comments