From 32b7e8875e0a08290168ec7dda040d5a5db513fa Mon Sep 17 00:00:00 2001 From: Dawid Niedzwiecki Date: Thu, 24 Sep 2020 09:20:41 +0200 Subject: core: rename atomic_clear to atomic_clear_bits Change the name of atomic_clear to atomic_clear_bits to make to name more clear - the function clears only selected bits, but the name may suggest that it clears the whole variable. It is done as a part of porting to Zephyr, where atomic_clear zeros the variable. BUG=b:169151160 BRANCH=none TEST=buildall Signed-off-by: Dawid Niedzwiecki Change-Id: I7b0b47959c6c54af40f61bca8d9baebaa0375970 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2428943 Reviewed-by: Jett Rink --- common/button.c | 5 +++-- common/charge_manager.c | 2 +- common/device_event.c | 2 +- common/dptf.c | 4 ++-- common/host_event_commands.c | 4 ++-- common/keyboard_scan.c | 4 ++-- common/timer.c | 4 ++-- common/usb_pd_protocol.c | 8 ++++---- common/usbc/usb_pe_drp_sm.c | 7 ++++--- common/usbc/usb_prl_sm.c | 10 +++++----- common/usbc/usb_tc_drp_acc_trysrc_sm.c | 29 +++++++++++++++-------------- common/usbc_ppc.c | 4 ++-- 12 files changed, 43 insertions(+), 40 deletions(-) (limited to 'common') diff --git a/common/button.c b/common/button.c index 42d08c9baf..6f346ec7cb 100644 --- a/common/button.c +++ b/common/button.c @@ -387,8 +387,9 @@ static void simulate_button_release_deferred(void) /* Check state for button pressed */ if (sim_button_state & BIT(buttons[button_idx].type)) { /* Set state of the button as released */ - deprecated_atomic_clear(&sim_button_state, - BIT(buttons[button_idx].type)); + deprecated_atomic_clear_bits( + &sim_button_state, + BIT(buttons[button_idx].type)); button_interrupt_simulate(button_idx); } diff --git a/common/charge_manager.c b/common/charge_manager.c index de88d3e437..bc82859e5d 100644 --- a/common/charge_manager.c +++ b/common/charge_manager.c @@ -1250,7 +1250,7 @@ void charge_manager_source_port(int port, int enable) if (enable) deprecated_atomic_or(&source_port_bitmap, 1 << port); else - deprecated_atomic_clear(&source_port_bitmap, 1 << port); + deprecated_atomic_clear_bits(&source_port_bitmap, 1 << port); /* No change, exit early. */ if (prev_bitmap == source_port_bitmap) diff --git a/common/device_event.c b/common/device_event.c index 16d34b8729..3b1fae79d0 100644 --- a/common/device_event.c +++ b/common/device_event.c @@ -55,7 +55,7 @@ void device_clear_events(uint32_t mask) if (device_current_events & mask) CPRINTS("device event clear 0x%08x", mask); - deprecated_atomic_clear(&device_current_events, mask); + deprecated_atomic_clear_bits(&device_current_events, mask); } static void device_set_enabled_events(uint32_t mask) diff --git a/common/dptf.c b/common/dptf.c index 75bcdcad01..f4fc6d0ff6 100644 --- a/common/dptf.c +++ b/common/dptf.c @@ -47,7 +47,7 @@ int dptf_query_next_sensor_event(void) for (id = 0; id < TEMP_SENSOR_COUNT; id++) if (dptf_seen & BIT(id)) { /* atomic? */ - deprecated_atomic_clear(&dptf_seen, BIT(id)); + deprecated_atomic_clear_bits(&dptf_seen, BIT(id)); return id; } @@ -109,7 +109,7 @@ void dptf_set_temp_threshold(int sensor_id, int temp, int idx, int enable) if (dptf_threshold[sensor_id][idx].temp == -1) cond_init(&dptf_threshold[sensor_id][idx].over, 0); dptf_threshold[sensor_id][idx].temp = temp; - deprecated_atomic_clear(&dptf_seen, BIT(sensor_id)); + deprecated_atomic_clear_bits(&dptf_seen, BIT(sensor_id)); } else { dptf_threshold[sensor_id][idx].temp = -1; } diff --git a/common/host_event_commands.c b/common/host_event_commands.c index 01e1d577cf..9ab7f19d04 100644 --- a/common/host_event_commands.c +++ b/common/host_event_commands.c @@ -276,9 +276,9 @@ static void host_events_atomic_clear(host_event_t *e, host_event_t m) { uint32_t *ptr = (uint32_t *)e; - deprecated_atomic_clear(ptr, (uint32_t)m); + deprecated_atomic_clear_bits(ptr, (uint32_t)m); #ifdef CONFIG_HOST_EVENT64 - deprecated_atomic_clear(ptr + 1, (uint32_t)(m >> 32)); + deprecated_atomic_clear_bits(ptr + 1, (uint32_t)(m >> 32)); #endif } diff --git a/common/keyboard_scan.c b/common/keyboard_scan.c index 7e68c28bee..0e95eb6c34 100644 --- a/common/keyboard_scan.c +++ b/common/keyboard_scan.c @@ -143,8 +143,8 @@ void keyboard_scan_enable(int enable, enum kb_scan_disable_masks mask) { /* Access atomically */ if (enable) { - deprecated_atomic_clear((uint32_t *)&disable_scanning_mask, - mask); + deprecated_atomic_clear_bits((uint32_t *)&disable_scanning_mask, + mask); } else { deprecated_atomic_or((uint32_t *)&disable_scanning_mask, mask); clear_typematic_key(); diff --git a/common/timer.c b/common/timer.c index 6a210ee9da..c359efb541 100644 --- a/common/timer.c +++ b/common/timer.c @@ -41,7 +41,7 @@ static int timer_irq; static void expire_timer(task_id_t tskid) { /* we are done with this timer */ - deprecated_atomic_clear(&timer_running, 1 << tskid); + deprecated_atomic_clear_bits(&timer_running, 1 << tskid); /* wake up the taks waiting for this timer */ task_set_event(tskid, TASK_EVENT_TIMER, 0); } @@ -146,7 +146,7 @@ void timer_cancel(task_id_t tskid) { ASSERT(tskid < TASK_ID_COUNT); - deprecated_atomic_clear(&timer_running, BIT(tskid)); + deprecated_atomic_clear_bits(&timer_running, BIT(tskid)); /* * Don't need to cancel the hardware timer interrupt, instead do * timer-related housekeeping when the next timer interrupt fires. diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index cbf1a193cb..1fe963f1fc 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -531,8 +531,8 @@ static int reset_device_and_notify(int port) * waking the TCPC, but it has also set PD_EVENT_TCPC_RESET again, which * would result in a second, unnecessary init. */ - deprecated_atomic_clear(task_get_event_bitmap(task_get_current()), - PD_EVENT_TCPC_RESET); + deprecated_atomic_clear_bits(task_get_event_bitmap(task_get_current()), + PD_EVENT_TCPC_RESET); waiting_tasks = deprecated_atomic_read_clear(&pd[port].tasks_waiting_on_reset); @@ -611,8 +611,8 @@ void pd_prevent_low_power_mode(int port, int prevent) deprecated_atomic_or(&pd[port].tasks_preventing_lpm, current_task_mask); else - deprecated_atomic_clear(&pd[port].tasks_preventing_lpm, - current_task_mask); + deprecated_atomic_clear_bits(&pd[port].tasks_preventing_lpm, + current_task_mask); } /* This is only called from the PD tasks that owns the port. */ diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c index c64d8386ae..210bb9d1d8 100644 --- a/common/usbc/usb_pe_drp_sm.c +++ b/common/usbc/usb_pe_drp_sm.c @@ -65,7 +65,8 @@ #define PE_SET_FLAG(port, flag) deprecated_atomic_or(&pe[port].flags, (flag)) -#define PE_CLR_FLAG(port, flag) deprecated_atomic_clear(&pe[port].flags, (flag)) +#define PE_CLR_FLAG(port, flag) \ + deprecated_atomic_clear_bits(&pe[port].flags, (flag)) #define PE_CHK_FLAG(port, flag) (pe[port].flags & (flag)) /* @@ -75,7 +76,7 @@ #define PE_SET_DPM_REQUEST(port, req) \ deprecated_atomic_or(&pe[port].dpm_request, (req)) #define PE_CLR_DPM_REQUEST(port, req) \ - deprecated_atomic_clear(&pe[port].dpm_request, (req)) + deprecated_atomic_clear_bits(&pe[port].dpm_request, (req)) #define PE_CHK_DPM_REQUEST(port, req) (pe[port].dpm_request & (req)) /* @@ -6156,7 +6157,7 @@ void pd_dfp_discovery_init(int port) void pd_discovery_access_clear(int port, enum tcpm_transmit_type type) { - deprecated_atomic_clear(&task_access[port][type], 0xFFFFFFFF); + deprecated_atomic_clear_bits(&task_access[port][type], 0xFFFFFFFF); } bool pd_discovery_access_validate(int port, enum tcpm_transmit_type type) diff --git a/common/usbc/usb_prl_sm.c b/common/usbc/usb_prl_sm.c index dd8a06c0bd..69861fb482 100644 --- a/common/usbc/usb_prl_sm.c +++ b/common/usbc/usb_prl_sm.c @@ -42,30 +42,30 @@ #define RCH_SET_FLAG(port, flag) deprecated_atomic_or(&rch[port].flags, (flag)) #define RCH_CLR_FLAG(port, flag) \ - deprecated_atomic_clear(&rch[port].flags, (flag)) + deprecated_atomic_clear_bits(&rch[port].flags, (flag)) #define RCH_CHK_FLAG(port, flag) (rch[port].flags & (flag)) #define TCH_SET_FLAG(port, flag) deprecated_atomic_or(&tch[port].flags, (flag)) #define TCH_CLR_FLAG(port, flag) \ - deprecated_atomic_clear(&tch[port].flags, (flag)) + deprecated_atomic_clear_bits(&tch[port].flags, (flag)) #define TCH_CHK_FLAG(port, flag) (tch[port].flags & (flag)) #define PRL_TX_SET_FLAG(port, flag) \ deprecated_atomic_or(&prl_tx[port].flags, (flag)) #define PRL_TX_CLR_FLAG(port, flag) \ - deprecated_atomic_clear(&prl_tx[port].flags, (flag)) + deprecated_atomic_clear_bits(&prl_tx[port].flags, (flag)) #define PRL_TX_CHK_FLAG(port, flag) (prl_tx[port].flags & (flag)) #define PRL_HR_SET_FLAG(port, flag) \ deprecated_atomic_or(&prl_hr[port].flags, (flag)) #define PRL_HR_CLR_FLAG(port, flag) \ - deprecated_atomic_clear(&prl_hr[port].flags, (flag)) + deprecated_atomic_clear_bits(&prl_hr[port].flags, (flag)) #define PRL_HR_CHK_FLAG(port, flag) (prl_hr[port].flags & (flag)) #define PDMSG_SET_FLAG(port, flag) \ deprecated_atomic_or(&pdmsg[port].flags, (flag)) #define PDMSG_CLR_FLAG(port, flag) \ - deprecated_atomic_clear(&pdmsg[port].flags, (flag)) + deprecated_atomic_clear_bits(&pdmsg[port].flags, (flag)) #define PDMSG_CHK_FLAG(port, flag) (pdmsg[port].flags & (flag)) /* Protocol Layer Flags */ diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c index 97d69b0876..1756f39c4a 100644 --- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c +++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c @@ -65,14 +65,15 @@ void print_flag(int set_or_clear, int flag); print_flag(1, flag); \ deprecated_atomic_or(&tc[port].flags, (flag)); \ } while (0) -#define TC_CLR_FLAG(port, flag) \ - do { \ - print_flag(0, flag); \ - deprecated_atomic_clear(&tc[port].flags, (flag)); \ +#define TC_CLR_FLAG(port, flag) \ + do { \ + print_flag(0, flag); \ + deprecated_atomic_clear_bits(&tc[port].flags, (flag)); \ } while (0) #else #define TC_SET_FLAG(port, flag) deprecated_atomic_or(&tc[port].flags, (flag)) -#define TC_CLR_FLAG(port, flag) deprecated_atomic_clear(&tc[port].flags, (flag)) +#define TC_CLR_FLAG(port, flag) \ + deprecated_atomic_clear_bits(&tc[port].flags, (flag)) #endif #define TC_CHK_FLAG(port, flag) (tc[port].flags & (flag)) @@ -607,8 +608,8 @@ static bool pd_comm_allowed_by_policy(void) static void tc_policy_pd_enable(int port, int en) { if (en) - deprecated_atomic_clear(&tc[port].pd_disabled_mask, - PD_DISABLED_BY_POLICY); + deprecated_atomic_clear_bits(&tc[port].pd_disabled_mask, + PD_DISABLED_BY_POLICY); else deprecated_atomic_or(&tc[port].pd_disabled_mask, PD_DISABLED_BY_POLICY); @@ -619,8 +620,8 @@ static void tc_policy_pd_enable(int port, int en) static void tc_enable_pd(int port, int en) { if (en) - deprecated_atomic_clear(&tc[port].pd_disabled_mask, - PD_DISABLED_NO_CONNECTION); + deprecated_atomic_clear_bits(&tc[port].pd_disabled_mask, + PD_DISABLED_NO_CONNECTION); else deprecated_atomic_or(&tc[port].pd_disabled_mask, PD_DISABLED_NO_CONNECTION); @@ -631,7 +632,7 @@ static void tc_enable_try_src(int en) if (en) deprecated_atomic_or(&pd_try_src, 1); else - deprecated_atomic_clear(&pd_try_src, 1); + deprecated_atomic_clear_bits(&pd_try_src, 1); } static void tc_detached(int port) @@ -1739,8 +1740,8 @@ static __maybe_unused int reset_device_and_notify(int port) * waking the TCPC, but it has also set PD_EVENT_TCPC_RESET again, which * would result in a second, unnecessary init. */ - deprecated_atomic_clear(task_get_event_bitmap(task_get_current()), - PD_EVENT_TCPC_RESET); + deprecated_atomic_clear_bits(task_get_event_bitmap(task_get_current()), + PD_EVENT_TCPC_RESET); waiting_tasks = deprecated_atomic_read_clear(&tc[port].tasks_waiting_on_reset); @@ -1810,8 +1811,8 @@ void pd_prevent_low_power_mode(int port, int prevent) deprecated_atomic_or(&tc[port].tasks_preventing_lpm, current_task_mask); else - deprecated_atomic_clear(&tc[port].tasks_preventing_lpm, - current_task_mask); + deprecated_atomic_clear_bits(&tc[port].tasks_preventing_lpm, + current_task_mask); } #endif /* CONFIG_USB_PD_TCPC_LOW_POWER */ diff --git a/common/usbc_ppc.c b/common/usbc_ppc.c index 7b01ed4591..7a334ae439 100644 --- a/common/usbc_ppc.c +++ b/common/usbc_ppc.c @@ -82,7 +82,7 @@ int ppc_add_oc_event(int port) oc_event_cnt_tbl[port]++; /* The port overcurrented, so don't clear it's OC events. */ - deprecated_atomic_clear(&connected_ports, 1 << port); + deprecated_atomic_clear_bits(&connected_ports, 1 << port); if (oc_event_cnt_tbl[port] >= PPC_OC_CNT_THRESH) ppc_prints("OC event limit reached! " @@ -266,7 +266,7 @@ void ppc_sink_is_connected(int port, int is_connected) if (is_connected) deprecated_atomic_or(&connected_ports, 1 << port); else - deprecated_atomic_clear(&connected_ports, 1 << port); + deprecated_atomic_clear_bits(&connected_ports, 1 << port); } int ppc_vbus_sink_enable(int port, int enable) -- cgit v1.2.1