@@ -280,6 +280,29 @@ static int vchiq_platform_init(struct platform_device *pdev, struct vchiq_state
280
280
return 0 ;
281
281
}
282
282
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
+
283
306
static struct vchiq_arm_state * vchiq_platform_get_arm_state (struct vchiq_state * state )
284
307
{
285
308
return (struct vchiq_arm_state * )state -> platform_state ;
@@ -988,39 +1011,6 @@ vchiq_keepalive_thread_func(void *v)
988
1011
return 0 ;
989
1012
}
990
1013
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
-
1024
1014
int
1025
1015
vchiq_use_internal (struct vchiq_state * state , struct vchiq_service * service ,
1026
1016
enum USE_TYPE_E use_type )
@@ -1341,6 +1331,7 @@ void vchiq_platform_conn_state_changed(struct vchiq_state *state,
1341
1331
enum vchiq_connstate newstate )
1342
1332
{
1343
1333
struct vchiq_arm_state * arm_state = vchiq_platform_get_arm_state (state );
1334
+ char threadname [16 ];
1344
1335
1345
1336
dev_dbg (state -> dev , "suspend: %d: %s->%s\n" ,
1346
1337
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,
1355
1346
1356
1347
arm_state -> first_connect = 1 ;
1357
1348
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
+ }
1359
1360
}
1360
1361
1361
1362
static const struct of_device_id vchiq_of_match [] = {
0 commit comments