Skip to content

Commit 70238d8

Browse files
glenn-andrewskartben
authored andcommitted
Lib: USB-C: Apply clang-format
Apply clang-format to USB-C in preparation for code changes No code is changed, only formatting. Signed-off-by: Glenn Andrews <[email protected]>
1 parent b469fc1 commit 70238d8

File tree

7 files changed

+64
-71
lines changed

7 files changed

+64
-71
lines changed

subsys/usb/usb_c/usbc_pe_common.c

+24-27
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,7 @@ void pe_report_error(const struct device *dev, const enum pe_error e,
309309
* Generate Hard Reset if Protocol Error occurred
310310
* while in PE_Send_Soft_Reset state.
311311
*/
312-
if (pe_get_state(dev) == PE_SEND_SOFT_RESET ||
313-
pe_get_state(dev) == PE_SOFT_RESET) {
312+
if (pe_get_state(dev) == PE_SEND_SOFT_RESET || pe_get_state(dev) == PE_SOFT_RESET) {
314313
atomic_set_bit(pe->flags, PE_FLAGS_PROTOCOL_ERROR);
315314
return;
316315
}
@@ -479,7 +478,7 @@ void pe_send_soft_reset(const struct device *dev, const enum pd_packet_type type
479478
* @brief Send a Power Delivery Data Message
480479
*/
481480
void pe_send_data_msg(const struct device *dev, const enum pd_packet_type type,
482-
const enum pd_data_msg_type msg)
481+
const enum pd_data_msg_type msg)
483482
{
484483
struct usbc_port_data *data = dev->data;
485484
struct policy_engine *pe = data->pe;
@@ -493,7 +492,7 @@ void pe_send_data_msg(const struct device *dev, const enum pd_packet_type type,
493492
* @brief Send a Power Delivery Control Message
494493
*/
495494
void pe_send_ctrl_msg(const struct device *dev, const enum pd_packet_type type,
496-
const enum pd_ctrl_msg_type msg)
495+
const enum pd_ctrl_msg_type msg)
497496
{
498497
struct usbc_port_data *data = dev->data;
499498
struct policy_engine *pe = data->pe;
@@ -669,9 +668,8 @@ void policy_get_snk_cap(const struct device *dev, uint32_t **pdos, int *num_pdos
669668
/**
670669
* @brief Send the received sink caps to the DPM
671670
*/
672-
void policy_set_port_partner_snk_cap(const struct device *dev,
673-
const uint32_t *pdos,
674-
const int num_pdos)
671+
void policy_set_port_partner_snk_cap(const struct device *dev, const uint32_t *pdos,
672+
const int num_pdos)
675673
{
676674
struct usbc_port_data *data = dev->data;
677675

@@ -684,28 +682,26 @@ void policy_set_port_partner_snk_cap(const struct device *dev,
684682
* @brief Check if Sink Request can be met by DPM
685683
*/
686684
enum usbc_snk_req_reply_t policy_check_sink_request(const struct device *dev,
687-
const uint32_t request_msg)
685+
const uint32_t request_msg)
688686
{
689687
struct usbc_port_data *data = dev->data;
690688

691689
/* This callback must be implemented */
692-
__ASSERT(data->policy_cb_check_sink_request != NULL,
693-
"Callback pointer should not be NULL");
690+
__ASSERT(data->policy_cb_check_sink_request != NULL, "Callback pointer should not be NULL");
694691

695692
return data->policy_cb_check_sink_request(dev, request_msg);
696693
}
697694

698695
/**
699696
* @brief Check if the present contract is still valid
700697
*/
701-
bool policy_present_contract_is_valid(const struct device *dev,
702-
const uint32_t present_contract)
698+
bool policy_present_contract_is_valid(const struct device *dev, const uint32_t present_contract)
703699
{
704700
struct usbc_port_data *data = dev->data;
705701

706702
/* This callback must be implemented */
707703
__ASSERT(data->policy_present_contract_is_valid != NULL,
708-
"Callback pointer should not be NULL");
704+
"Callback pointer should not be NULL");
709705

710706
return data->policy_present_contract_is_valid(dev, present_contract);
711707
}
@@ -718,8 +714,7 @@ bool policy_is_ps_ready(const struct device *dev)
718714
struct usbc_port_data *data = dev->data;
719715

720716
/* This callback must be implemented */
721-
__ASSERT(data->policy_is_ps_ready != NULL,
722-
"Callback pointer should not be NULL");
717+
__ASSERT(data->policy_is_ps_ready != NULL, "Callback pointer should not be NULL");
723718

724719
return data->policy_is_ps_ready(dev);
725720
}
@@ -783,8 +778,8 @@ static void pe_drs_evaluate_swap_run(void *obj)
783778
/* Only update data roles if last message sent was Accept */
784779
if (prl_tx->msg_type == PD_CTRL_ACCEPT) {
785780
/* Update Data Role */
786-
pe_set_data_role(dev, (pe->data_role == TC_ROLE_UFP)
787-
? TC_ROLE_DFP : TC_ROLE_UFP);
781+
pe_set_data_role(dev, (pe->data_role == TC_ROLE_UFP) ? TC_ROLE_DFP
782+
: TC_ROLE_UFP);
788783
/* Inform Device Policy Manager of Data Role Change */
789784
policy_notify(dev, (pe->data_role == TC_ROLE_UFP) ? DATA_ROLE_IS_UFP
790785
: DATA_ROLE_IS_DFP);
@@ -922,16 +917,16 @@ void pe_get_sink_cap_run(void *obj)
922917
if (received_data_message(dev, header, PD_DATA_SINK_CAP)) {
923918
#ifdef CONFIG_USBC_CSM_SOURCE_ONLY
924919
uint32_t *pdos = (uint32_t *)prl_rx->emsg.data;
925-
uint32_t num_pdos =
926-
PD_CONVERT_BYTES_TO_PD_HEADER_COUNT(prl_rx->emsg.len);
920+
uint32_t num_pdos = PD_CONVERT_BYTES_TO_PD_HEADER_COUNT(
921+
prl_rx->emsg.len);
927922

928923
policy_set_port_partner_snk_cap(dev, pdos, num_pdos);
929924
#endif
930925
pe_set_ready_state(dev);
931926
return;
932927
} else if (received_control_message(dev, header, PD_CTRL_REJECT) ||
933-
received_control_message(dev,
934-
header, PD_CTRL_NOT_SUPPORTED)) {
928+
received_control_message(dev, header,
929+
PD_CTRL_NOT_SUPPORTED)) {
935930
pe_set_ready_state(dev);
936931
return;
937932
}
@@ -1114,7 +1109,7 @@ static void pe_send_not_supported_run(void *obj)
11141109
const struct device *dev = pe->dev;
11151110

11161111
if (atomic_test_bit(pe->flags, PE_FLAGS_TX_COMPLETE) ||
1117-
atomic_test_bit(pe->flags, PE_FLAGS_MSG_DISCARDED)) {
1112+
atomic_test_bit(pe->flags, PE_FLAGS_MSG_DISCARDED)) {
11181113
atomic_clear_bit(pe->flags, PE_FLAGS_TX_COMPLETE);
11191114
atomic_clear_bit(pe->flags, PE_FLAGS_MSG_DISCARDED);
11201115
pe_set_ready_state(dev);
@@ -1194,8 +1189,8 @@ static void pe_sender_response_run(void *obj)
11941189
* 2) And the NoResponseTimer times out
11951190
* 3) And the HardResetCounter > nHardResetCount.
11961191
*/
1197-
if ((atomic_test_bit(pe->flags, PE_FLAGS_HAS_BEEN_PD_CONNECTED) == false)
1198-
&& pe->hard_reset_counter > PD_N_HARD_RESET_COUNT) {
1192+
if ((atomic_test_bit(pe->flags, PE_FLAGS_HAS_BEEN_PD_CONNECTED) == false) &&
1193+
pe->hard_reset_counter > PD_N_HARD_RESET_COUNT) {
11991194
pe_set_state(dev, PE_SUSPEND);
12001195
}
12011196
break;
@@ -1206,8 +1201,8 @@ static void pe_sender_response_run(void *obj)
12061201
* 2) And the NoResponseTimer times out
12071202
* 3) And the HardResetCounter > nHardResetCount
12081203
*/
1209-
if (atomic_test_bit(pe->flags, PE_FLAGS_HAS_BEEN_PD_CONNECTED)
1210-
&& pe->hard_reset_counter > PD_N_HARD_RESET_COUNT) {
1204+
if (atomic_test_bit(pe->flags, PE_FLAGS_HAS_BEEN_PD_CONNECTED) &&
1205+
pe->hard_reset_counter > PD_N_HARD_RESET_COUNT) {
12111206
usbc_request(dev, REQUEST_TC_ERROR_RECOVERY);
12121207
}
12131208
/*
@@ -1253,8 +1248,8 @@ static void pe_sender_response_exit(void *obj)
12531248
/**
12541249
* @brief Policy engine State table
12551250
*/
1251+
/* clang-format off */
12561252
static const struct smf_state pe_states[PE_STATE_COUNT] = {
1257-
/* PE Super States */
12581253
[PE_SENDER_RESPONSE_PARENT] = SMF_CREATE_STATE(
12591254
NULL,
12601255
pe_sender_response_run,
@@ -1452,5 +1447,7 @@ static const struct smf_state pe_states[PE_STATE_COUNT] = {
14521447
NULL,
14531448
NULL,
14541449
NULL),
1450+
14551451
};
1452+
/* clang-format off */
14561453
BUILD_ASSERT(ARRAY_SIZE(pe_states) == PE_STATE_COUNT);

subsys/usb/usb_c/usbc_pe_src_states.c

+10-14
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ static void send_src_caps(struct policy_engine *pe)
7979
uint32_t num_pdos = 0;
8080

8181
/* This callback must be implemented */
82-
__ASSERT(data->policy_cb_get_src_caps != NULL,
83-
"Callback pointer should not be NULL");
82+
__ASSERT(data->policy_cb_get_src_caps != NULL, "Callback pointer should not be NULL");
8483

8584
data->policy_cb_get_src_caps(dev, &pdos, &num_pdos);
8685

@@ -216,8 +215,8 @@ void pe_src_send_capabilities_run(void *obj)
216215
* 2) And we are presently not Connected.
217216
*/
218217
else if ((atomic_test_and_clear_bit(pe->flags, PE_FLAGS_MSG_XMIT_ERROR) ||
219-
atomic_test_and_clear_bit(pe->flags, PE_FLAGS_MSG_DISCARDED))
220-
&& (atomic_test_bit(pe->flags, PE_FLAGS_PD_CONNECTED) == false)) {
218+
atomic_test_and_clear_bit(pe->flags, PE_FLAGS_MSG_DISCARDED)) &&
219+
(atomic_test_bit(pe->flags, PE_FLAGS_PD_CONNECTED) == false)) {
221220
pe_set_state(dev, PE_SRC_DISCOVERY);
222221
}
223222
break;
@@ -232,7 +231,7 @@ void pe_src_send_capabilities_run(void *obj)
232231
if (received_data_message(dev, header, PD_DATA_REQUEST)) {
233232
/* Set to highest revision supported by both ports */
234233
prl_set_rev(dev, PD_PACKET_SOP,
235-
MIN(PD_REV30, header.specification_revision));
234+
MIN(PD_REV30, header.specification_revision));
236235
pe_set_state(dev, PE_SRC_NEGOTIATE_CAPABILITY);
237236
}
238237
}
@@ -267,8 +266,7 @@ void pe_src_negotiate_capability_entry(void *obj)
267266
* Ask the Device Policy Manager to evaluate the Request
268267
* from the Attached Sink.
269268
*/
270-
pe->snk_request_reply =
271-
policy_check_sink_request(dev, pe->snk_request);
269+
pe->snk_request_reply = policy_check_sink_request(dev, pe->snk_request);
272270

273271
/*
274272
* The Policy Engine Shall transition to the
@@ -380,8 +378,7 @@ void pe_src_ready_entry(void *obj)
380378
* Else on entry to the PE_SRC_Ready state the Source Shall notify the
381379
* Protocol Layer of the end of the Atomic Message Sequence (AMS).
382380
*/
383-
if (atomic_test_and_clear_bit(pe->flags,
384-
PE_FLAGS_PROTOCOL_ERROR_NO_SOFT_RESET)) {
381+
if (atomic_test_and_clear_bit(pe->flags, PE_FLAGS_PROTOCOL_ERROR_NO_SOFT_RESET)) {
385382
pe_dpm_end_ams(dev);
386383
}
387384
}
@@ -605,9 +602,9 @@ void pe_src_capability_response_run(void *obj)
605602
* 3: A Wait Message has been sent.
606603
*/
607604
if (atomic_test_bit(pe->flags, PE_FLAGS_EXPLICIT_CONTRACT) &&
608-
((pe->snk_request_reply == SNK_REQUEST_REJECT &&
609-
policy_present_contract_is_valid(dev, pe->present_contract)) ||
610-
(pe->snk_request_reply == SNK_REQUEST_WAIT))) {
605+
((pe->snk_request_reply == SNK_REQUEST_REJECT &&
606+
policy_present_contract_is_valid(dev, pe->present_contract)) ||
607+
(pe->snk_request_reply == SNK_REQUEST_WAIT))) {
611608
pe_set_state(dev, PE_SRC_READY);
612609
}
613610
/*
@@ -618,7 +615,7 @@ void pe_src_capability_response_run(void *obj)
618615
* is Invalid
619616
*/
620617
else if (atomic_test_bit(pe->flags, PE_FLAGS_EXPLICIT_CONTRACT) &&
621-
policy_present_contract_is_valid(dev, pe->present_contract) == false) {
618+
policy_present_contract_is_valid(dev, pe->present_contract) == false) {
622619
pe_set_state(dev, PE_SRC_HARD_RESET);
623620
}
624621
/*
@@ -718,5 +715,4 @@ void pe_src_hard_reset_entry(void *obj)
718715
* the PHY Layer
719716
*/
720717
prl_execute_hard_reset(dev);
721-
722718
}

subsys/usb/usb_c/usbc_prl.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ static void prl_tx_wait_for_message_request_run(void *obj)
624624
*/
625625
if (data->rev[PD_PACKET_SOP] == PD_REV30 && pe_dpm_initiated_ams(dev)) {
626626
if (atomic_test_bit(&prl_tx->flags, PRL_FLAGS_WAIT_SINK_OK) ||
627-
atomic_test_bit(&prl_tx->flags, PRL_FLAGS_SINK_NG)) {
627+
atomic_test_bit(&prl_tx->flags, PRL_FLAGS_SINK_NG)) {
628628
/*
629629
* If we are already in an AMS then allow the
630630
* multi-message AMS to continue.
@@ -637,7 +637,7 @@ static void prl_tx_wait_for_message_request_run(void *obj)
637637
* Policy Engine
638638
*/
639639
if (IS_ENABLED(CONFIG_USBC_CSM_SOURCE_ONLY) &&
640-
pe_get_power_role(dev) == TC_ROLE_SOURCE) {
640+
pe_get_power_role(dev) == TC_ROLE_SOURCE) {
641641
atomic_set_bit(&prl_tx->flags, PRL_FLAGS_SINK_NG);
642642
prl_tx_set_state(dev, PRL_TX_SRC_SOURCE_TX);
643643
} else {
@@ -1260,6 +1260,7 @@ static void prl_rx_wait_for_phy_message(const struct device *dev)
12601260
/**
12611261
* @brief Protocol Layer Transmit State table
12621262
*/
1263+
/* clang-format off */
12631264
static const struct smf_state prl_tx_states[PRL_TX_STATE_COUNT] = {
12641265
[PRL_TX_PHY_LAYER_RESET] = SMF_CREATE_STATE(
12651266
prl_tx_phy_layer_reset_entry,
@@ -1320,11 +1321,13 @@ static const struct smf_state prl_tx_states[PRL_TX_STATE_COUNT] = {
13201321
NULL),
13211322
#endif
13221323
};
1324+
/* clang-format on */
13231325
BUILD_ASSERT(ARRAY_SIZE(prl_tx_states) == PRL_TX_STATE_COUNT);
13241326

13251327
/**
13261328
* @brief Protocol Layer Hard Reset State table
13271329
*/
1330+
/* clang-format off */
13281331
static const struct smf_state prl_hr_states[PRL_HR_STATE_COUNT] = {
13291332
[PRL_HR_WAIT_FOR_REQUEST] = SMF_CREATE_STATE(
13301333
prl_hr_wait_for_request_entry,
@@ -1357,4 +1360,5 @@ static const struct smf_state prl_hr_states[PRL_HR_STATE_COUNT] = {
13571360
NULL,
13581361
NULL),
13591362
};
1363+
/* clang-format on */
13601364
BUILD_ASSERT(ARRAY_SIZE(prl_hr_states) == PRL_HR_STATE_COUNT);

subsys/usb/usb_c/usbc_stack.c

+12-15
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ static ALWAYS_INLINE void usbc_handler(void *port_dev)
4545
}
4646
}
4747

48+
/* format makes the backslashes exceed 100 lines: */
49+
/* clang-format off */
4850
#define USBC_SUBSYS_INIT(inst) \
4951
K_THREAD_STACK_DEFINE(my_stack_area_##inst, CONFIG_USBC_STACK_SIZE); \
5052
\
@@ -91,7 +93,7 @@ static ALWAYS_INLINE void usbc_handler(void *port_dev)
9193
DEVICE_DT_INST_DEFINE(inst, &usbc_subsys_init, NULL, &usbc_port_data_##inst, \
9294
&usbc_port_config_##inst, POST_KERNEL, \
9395
CONFIG_USBC_STACK_INIT_PRIORITY, NULL);
94-
96+
/* clang-format on */
9597
DT_INST_FOREACH_STATUS_OKAY(USBC_SUBSYS_INIT)
9698

9799
/**
@@ -207,8 +209,8 @@ void usbc_set_policy_cb_get_rdo(const struct device *dev,
207209
* @brief Set the callback for checking if Sink Power Supply is at
208210
* default level
209211
*/
210-
void usbc_set_policy_cb_is_snk_at_default(const struct device *dev,
211-
const policy_cb_is_snk_at_default_t policy_cb_is_snk_at_default)
212+
void usbc_set_policy_cb_is_snk_at_default(
213+
const struct device *dev, const policy_cb_is_snk_at_default_t policy_cb_is_snk_at_default)
212214
{
213215
struct usbc_port_data *data = dev->data;
214216

@@ -221,7 +223,7 @@ void usbc_set_policy_cb_is_snk_at_default(const struct device *dev,
221223
* @brief Set the callback for sending the Sink Caps to the DPM
222224
*/
223225
void usbc_set_policy_cb_set_port_partner_snk_cap(const struct device *dev,
224-
const policy_cb_set_port_partner_snk_cap_t cb)
226+
const policy_cb_set_port_partner_snk_cap_t cb)
225227
{
226228
struct usbc_port_data *data = dev->data;
227229

@@ -232,8 +234,7 @@ void usbc_set_policy_cb_set_port_partner_snk_cap(const struct device *dev,
232234
* @brief Set the callback that gets the Source Capabilities from the
233235
* Device Policy Manager
234236
*/
235-
void usbc_set_policy_cb_get_src_caps(const struct device *dev,
236-
const policy_cb_get_src_caps_t cb)
237+
void usbc_set_policy_cb_get_src_caps(const struct device *dev, const policy_cb_get_src_caps_t cb)
237238
{
238239
struct usbc_port_data *data = dev->data;
239240

@@ -256,8 +257,7 @@ void usbc_set_policy_cb_get_src_rp(const struct device *dev,
256257
* @brief Set the callback that controls the sourcing of VBUS from the
257258
* Device Policy Manager
258259
*/
259-
void usbc_set_policy_cb_src_en(const struct device *dev,
260-
const policy_cb_src_en_t policy_cb_src_en)
260+
void usbc_set_policy_cb_src_en(const struct device *dev, const policy_cb_src_en_t policy_cb_src_en)
261261
{
262262
struct usbc_port_data *data = dev->data;
263263

@@ -278,8 +278,7 @@ void usbc_set_policy_cb_check_sink_request(const struct device *dev,
278278
/**
279279
* @brief Set the callback for checking if the Source Power Supply is ready
280280
*/
281-
void usbc_set_policy_cb_is_ps_ready(const struct device *dev,
282-
const policy_cb_is_ps_ready_t cb)
281+
void usbc_set_policy_cb_is_ps_ready(const struct device *dev, const policy_cb_is_ps_ready_t cb)
283282
{
284283
struct usbc_port_data *data = dev->data;
285284

@@ -290,7 +289,7 @@ void usbc_set_policy_cb_is_ps_ready(const struct device *dev,
290289
* @brief Set the callback for checking if the Present Contract is still valid
291290
*/
292291
void usbc_set_policy_cb_present_contract_is_valid(const struct device *dev,
293-
const policy_cb_present_contract_is_valid_t cb)
292+
const policy_cb_present_contract_is_valid_t cb)
294293
{
295294
struct usbc_port_data *data = dev->data;
296295

@@ -313,8 +312,7 @@ void usbc_set_policy_cb_change_src_caps(const struct device *dev,
313312
* @brief Set the callback that controls the sourcing of VCONN from the
314313
* Device Policy Manager
315314
*/
316-
void usbc_set_vconn_control_cb(const struct device *dev,
317-
const tcpc_vconn_control_cb_t cb)
315+
void usbc_set_vconn_control_cb(const struct device *dev, const tcpc_vconn_control_cb_t cb)
318316
{
319317
struct usbc_port_data *data = dev->data;
320318
const struct device *tcpc = data->tcpc;
@@ -326,8 +324,7 @@ void usbc_set_vconn_control_cb(const struct device *dev,
326324
* @brief Set the callback that discharges VCONN from the
327325
* Device Policy Manager
328326
*/
329-
void usbc_set_vconn_discharge(const struct device *dev,
330-
const tcpc_vconn_discharge_cb_t cb)
327+
void usbc_set_vconn_discharge(const struct device *dev, const tcpc_vconn_discharge_cb_t cb)
331328
{
332329
struct usbc_port_data *data = dev->data;
333330
const struct device *tcpc = data->tcpc;

0 commit comments

Comments
 (0)