Skip to content

Commit 2611045

Browse files
Marcelo Diop-Gonzalezgregkh
authored andcommitted
staging: vchiq: Refactor indentation in vchiq_platform_conn_state_changed()
Reducing the indentation level helps a bit with the readability of this function. There's also a checkpatch fix here, moving the first argument to kthread_create() onto the same line, as well as a relocation of the statement "char threadname[16];" to the top of the function to avoid a declaration in the middle of code. Signed-off-by: Marcelo Diop-Gonzalez <marcgonzalez@google.com> Link: https://lore.kernel.org/r/20191114232801.71458-1-marcgonzalez@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 635dad0 commit 2611045

1 file changed

Lines changed: 21 additions & 20 deletions

File tree

  • drivers/staging/vc04_services/interface/vchiq_arm

‎drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c‎

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3132,31 +3132,32 @@ void vchiq_platform_conn_state_changed(struct vchiq_state *state,
31323132
enum vchiq_connstate newstate)
31333133
{
31343134
struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state);
3135+
char threadname[16];
31353136

31363137
vchiq_log_info(vchiq_susp_log_level, "%d: %s->%s", state->id,
31373138
get_conn_state_name(oldstate), get_conn_state_name(newstate));
3138-
if (state->conn_state == VCHIQ_CONNSTATE_CONNECTED) {
3139-
write_lock_bh(&arm_state->susp_res_lock);
3140-
if (!arm_state->first_connect) {
3141-
char threadname[16];
3139+
if (state->conn_state != VCHIQ_CONNSTATE_CONNECTED)
3140+
return;
31423141

3143-
arm_state->first_connect = 1;
3144-
write_unlock_bh(&arm_state->susp_res_lock);
3145-
snprintf(threadname, sizeof(threadname), "vchiq-keep/%d",
3146-
state->id);
3147-
arm_state->ka_thread = kthread_create(
3148-
&vchiq_keepalive_thread_func,
3149-
(void *)state,
3142+
write_lock_bh(&arm_state->susp_res_lock);
3143+
if (arm_state->first_connect) {
3144+
write_unlock_bh(&arm_state->susp_res_lock);
3145+
return;
3146+
}
3147+
3148+
arm_state->first_connect = 1;
3149+
write_unlock_bh(&arm_state->susp_res_lock);
3150+
snprintf(threadname, sizeof(threadname), "vchiq-keep/%d",
3151+
state->id);
3152+
arm_state->ka_thread = kthread_create(&vchiq_keepalive_thread_func,
3153+
(void *)state,
3154+
threadname);
3155+
if (IS_ERR(arm_state->ka_thread)) {
3156+
vchiq_log_error(vchiq_susp_log_level,
3157+
"vchiq: FATAL: couldn't create thread %s",
31503158
threadname);
3151-
if (IS_ERR(arm_state->ka_thread)) {
3152-
vchiq_log_error(vchiq_susp_log_level,
3153-
"vchiq: FATAL: couldn't create thread %s",
3154-
threadname);
3155-
} else {
3156-
wake_up_process(arm_state->ka_thread);
3157-
}
3158-
} else
3159-
write_unlock_bh(&arm_state->susp_res_lock);
3159+
} else {
3160+
wake_up_process(arm_state->ka_thread);
31603161
}
31613162
}
31623163

0 commit comments

Comments
 (0)