Skip to content

Commit d9c4ec3

Browse files
sambhurstcarlescufi
authored andcommitted
usb_c: Fix comments before "else" statements
Move comments that precede an "else" into the "else" statement. Signed-off-by: Sam Hurst <[email protected]>
1 parent f84ee58 commit d9c4ec3

File tree

2 files changed

+63
-74
lines changed

2 files changed

+63
-74
lines changed

subsys/usb/usb_c/usbc_pe_snk_states.c

Lines changed: 47 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,11 @@ void pe_snk_select_capability_run(void *obj)
289289
}
290290

291291
pe_set_state(dev, PE_SNK_READY);
292-
}
293-
/*
294-
* No previous explicit contract, so transition
295-
* to PE_SNK_Wait_For_Capabilities
296-
*/
297-
else {
292+
} else {
293+
/*
294+
* No previous explicit contract, so transition
295+
* to PE_SNK_Wait_For_Capabilities
296+
*/
298297
pe_set_state(dev, PE_SNK_WAIT_FOR_CAPABILITIES);
299298
}
300299
} else {
@@ -426,9 +425,8 @@ void pe_snk_ready_run(void *obj)
426425
if (header.extended) {
427426
extended_message_not_supported(dev);
428427
return;
429-
}
430-
/* Data Messages */
431-
else if (header.number_of_data_objects > 0) {
428+
} else if (header.number_of_data_objects > 0) {
429+
/* Data Messages */
432430
switch (header.message_type) {
433431
case PD_DATA_SOURCE_CAP:
434432
pe_set_state(dev, PE_SNK_EVALUATE_CAPABILITY);
@@ -437,9 +435,8 @@ void pe_snk_ready_run(void *obj)
437435
pe_set_state(dev, PE_SEND_NOT_SUPPORTED);
438436
}
439437
return;
440-
}
441-
/* Control Messages */
442-
else {
438+
} else {
439+
/* Control Messages */
443440
switch (header.message_type) {
444441
case PD_CTRL_GOOD_CRC:
445442
/* Do nothing */
@@ -632,25 +629,23 @@ void pe_snk_get_source_cap_run(void *obj)
632629
if (atomic_test_and_clear_bit(pe->flags, PE_FLAGS_TX_COMPLETE)) {
633630
/* The Policy Engine Shall then start the SenderResponseTimer. */
634631
usbc_timer_start(&pe->pd_t_sender_response);
635-
}
636-
/*
637-
* The Policy Engine Shall transition to the PE_SNK_Evaluate_Capability
638-
* State when:
639-
* 1: In SPR Mode and SPR Source Capabilities were requested and
640-
* a Source_Capabilities Message is received
641-
*/
642-
else if (atomic_test_and_clear_bit(pe->flags, PE_FLAGS_MSG_RECEIVED)) {
632+
} else if (atomic_test_and_clear_bit(pe->flags, PE_FLAGS_MSG_RECEIVED)) {
633+
/*
634+
* The Policy Engine Shall transition to the PE_SNK_Evaluate_Capability
635+
* State when:
636+
* 1: In SPR Mode and SPR Source Capabilities were requested and
637+
* a Source_Capabilities Message is received
638+
*/
643639
header = prl_rx->emsg.header;
644640

645641
if (received_control_message(dev, header, PD_DATA_SOURCE_CAP)) {
646642
pe_set_state(dev, PE_SNK_EVALUATE_CAPABILITY);
647643
}
648-
}
649-
/*
650-
* The Policy Engine Shall transition to the PE_SNK_Ready state when:
651-
* 1: The SenderResponseTimer times out.
652-
*/
653-
else if (usbc_timer_expired(&pe->pd_t_sender_response)) {
644+
} else if (usbc_timer_expired(&pe->pd_t_sender_response)) {
645+
/*
646+
* The Policy Engine Shall transition to the PE_SNK_Ready state when:
647+
* 1: The SenderResponseTimer times out.
648+
*/
654649
pe_set_state(dev, PE_SNK_READY);
655650
/* Inform the DPM of the sender response timeout */
656651
policy_notify(dev, SENDER_RESPONSE_TIMEOUT);
@@ -710,26 +705,24 @@ void pe_send_soft_reset_run(void *obj)
710705
} else if (atomic_test_and_clear_bit(pe->flags, PE_FLAGS_TX_COMPLETE)) {
711706
/* Start SenderResponse timer */
712707
usbc_timer_start(&pe->pd_t_sender_response);
713-
}
714-
/*
715-
* The Policy Engine Shall transition to the PE_SNK_Wait_for_Capabilities
716-
* state when:
717-
* 1: An Accept Message has been received on SOP
718-
*/
719-
else if (atomic_test_and_clear_bit(pe->flags, PE_FLAGS_MSG_RECEIVED)) {
708+
} else if (atomic_test_and_clear_bit(pe->flags, PE_FLAGS_MSG_RECEIVED)) {
709+
/*
710+
* The Policy Engine Shall transition to the PE_SNK_Wait_for_Capabilities
711+
* state when:
712+
* 1: An Accept Message has been received on SOP
713+
*/
720714
header = prl_rx->emsg.header;
721715

722716
if (received_control_message(dev, header, PD_CTRL_ACCEPT)) {
723717
pe_set_state(dev, PE_SNK_WAIT_FOR_CAPABILITIES);
724718
}
725-
}
726-
/*
727-
* The Policy Engine Shall transition to the PE_SNK_Hard_Reset state when:
728-
* 1: A SenderResponseTimer timeout occurs
729-
* 2: Or the Protocol Layer indicates that a transmission error has occurred
730-
*/
731-
else if (usbc_timer_expired(&pe->pd_t_sender_response) ||
732-
atomic_test_and_clear_bit(pe->flags, PE_FLAGS_PROTOCOL_ERROR)) {
719+
} else if (usbc_timer_expired(&pe->pd_t_sender_response) ||
720+
atomic_test_and_clear_bit(pe->flags, PE_FLAGS_PROTOCOL_ERROR)) {
721+
/*
722+
* The Policy Engine Shall transition to the PE_SNK_Hard_Reset state when:
723+
* 1: A SenderResponseTimer timeout occurs
724+
* 2: Or the Protocol Layer indicates that a transmission error has occurred
725+
*/
733726
pe_set_state(dev, PE_SNK_HARD_RESET);
734727
}
735728
}
@@ -775,22 +768,20 @@ void pe_soft_reset_run(void *obj)
775768
if (atomic_test_and_clear_bit(pe->flags, PE_FLAGS_SEND_SOFT_RESET)) {
776769
/* Send Accept message */
777770
pe_send_ctrl_msg(dev, PD_PACKET_SOP, PD_CTRL_ACCEPT);
778-
}
779-
/*
780-
* The Policy Engine Shall transition to the PE_SNK_Wait_for_Capabilities
781-
* state when:
782-
* 1: The Accept Message has been sent on SOP.
783-
*/
784-
else if (atomic_test_and_clear_bit(pe->flags, PE_FLAGS_TX_COMPLETE)) {
771+
} else if (atomic_test_and_clear_bit(pe->flags, PE_FLAGS_TX_COMPLETE)) {
772+
/*
773+
* The Policy Engine Shall transition to the PE_SNK_Wait_for_Capabilities
774+
* state when:
775+
* 1: The Accept Message has been sent on SOP.
776+
*/
785777
pe_set_state(dev, PE_SNK_WAIT_FOR_CAPABILITIES);
786-
}
787-
/*
788-
* The Policy Engine Shall transition to the PE_SNK_Hard_Reset
789-
* state when:
790-
* 1: The Protocol Layer indicates that a transmission error
791-
* has occurred.
792-
*/
793-
else if (atomic_test_and_clear_bit(pe->flags, PE_FLAGS_PROTOCOL_ERROR)) {
778+
} else if (atomic_test_and_clear_bit(pe->flags, PE_FLAGS_PROTOCOL_ERROR)) {
779+
/*
780+
* The Policy Engine Shall transition to the PE_SNK_Hard_Reset
781+
* state when:
782+
* 1: The Protocol Layer indicates that a transmission error
783+
* has occurred.
784+
*/
794785
pe_set_state(dev, PE_SNK_HARD_RESET);
795786
}
796787
}

subsys/usb/usb_c/usbc_prl.c

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -620,11 +620,9 @@ static void prl_tx_wait_for_message_request_run(void *obj)
620620
*/
621621
if ((prl_tx->msg_type == PD_CTRL_SOFT_RESET) && (prl_tx->emsg.len == 0)) {
622622
prl_tx_set_state(dev, PRL_TX_LAYER_RESET_FOR_TRANSMIT);
623-
}
624-
/*
625-
* Message pending (except Soft Reset)
626-
*/
627-
else {
623+
} else {
624+
/* Message pending (except Soft Reset) */
625+
628626
/* NOTE: PRL_TX_Construct_Message State embedded here */
629627
prl_tx_construct_message(dev);
630628
prl_tx_set_state(dev, PRL_TX_WAIT_FOR_PHY_RESPONSE);
@@ -796,13 +794,13 @@ static void prl_tx_snk_pending_run(void *obj)
796794
*/
797795
if ((prl_tx->msg_type == PD_CTRL_SOFT_RESET) && (prl_tx->emsg.len == 0)) {
798796
prl_tx_set_state(dev, PRL_TX_LAYER_RESET_FOR_TRANSMIT);
799-
}
800-
/*
801-
* The Protocol Layer Shall transition to the PRL_Tx_Construct_Message
802-
* state when Rp is set to SinkTxOk and a Soft_Reset Message is not
803-
* pending.
804-
*/
805-
else if (cc1 == TC_CC_VOLT_RP_3A0 || cc2 == TC_CC_VOLT_RP_3A0) {
797+
} else if (cc1 == TC_CC_VOLT_RP_3A0 || cc2 == TC_CC_VOLT_RP_3A0) {
798+
/*
799+
* The Protocol Layer Shall transition to the PRL_Tx_Construct_Message
800+
* state when Rp is set to SinkTxOk and a Soft_Reset Message is not
801+
* pending.
802+
*/
803+
806804
/*
807805
* Message pending (except Soft Reset) &
808806
* Rp = SinkTxOk
@@ -932,12 +930,12 @@ static void prl_hr_reset_layer_entry(void *obj)
932930
*/
933931
prl_hr_send_msg_to_phy(dev);
934932
prl_hr_set_state(dev, PRL_HR_WAIT_FOR_PHY_HARD_RESET_COMPLETE);
935-
}
936-
/*
937-
* Protocol Layer reset complete &
938-
* Hard Reset was initiated by Port Partner
939-
*/
940-
else {
933+
} else {
934+
/*
935+
* Protocol Layer reset complete &
936+
* Hard Reset was initiated by Port Partner
937+
*/
938+
941939
/* Inform Policy Engine of the Hard Reset */
942940
pe_got_hard_reset(dev);
943941
prl_hr_set_state(dev, PRL_HR_WAIT_FOR_PE_HARD_RESET_COMPLETE);

0 commit comments

Comments
 (0)