diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/btle_ll.c | 2 | ||||
-rw-r--r-- | common/button.c | 6 | ||||
-rw-r--r-- | common/charge_manager.c | 4 | ||||
-rw-r--r-- | common/dptf.c | 10 | ||||
-rw-r--r-- | common/fpsensor.c | 4 | ||||
-rw-r--r-- | common/i2c_master.c | 2 | ||||
-rw-r--r-- | common/keyboard_mkbp.c | 32 | ||||
-rw-r--r-- | common/keyboard_scan.c | 10 | ||||
-rw-r--r-- | common/lightbar.c | 4 | ||||
-rw-r--r-- | common/mkbp_event.c | 2 | ||||
-rw-r--r-- | common/motion_sense.c | 8 | ||||
-rw-r--r-- | common/switch.c | 2 | ||||
-rw-r--r-- | common/system.c | 2 | ||||
-rw-r--r-- | common/throttle_ap.c | 2 | ||||
-rw-r--r-- | common/timer.c | 2 | ||||
-rw-r--r-- | common/usb_pd_protocol.c | 8 | ||||
-rw-r--r-- | common/usbc_ppc.c | 2 | ||||
-rw-r--r-- | common/util.c | 2 |
18 files changed, 52 insertions, 52 deletions
diff --git a/common/btle_ll.c b/common/btle_ll.c index fdf27d71c6..02f6af73d0 100644 --- a/common/btle_ll.c +++ b/common/btle_ll.c @@ -622,7 +622,7 @@ int ble_ll_adv_event(void) int rv; for (chan_idx = 0; chan_idx < 3; chan_idx++) { - if (ll_adv_params.advChannelMap & (1 << chan_idx)) { + if (ll_adv_params.advChannelMap & BIT(chan_idx)) { rv = ble_ll_adv(chan_idx + 37); if (rv != EC_SUCCESS) return rv; diff --git a/common/button.c b/common/button.c index 3caa4383b5..88cf9e69b6 100644 --- a/common/button.c +++ b/common/button.c @@ -353,7 +353,7 @@ static int console_command_button(int argc, char **argv) if (button == BUTTON_COUNT) return EC_ERROR_PARAM1 + argv_idx - 1; - button_mask |= (1 << button); + button_mask |= BIT(button); } if (!button_mask) @@ -363,7 +363,7 @@ static int console_command_button(int argc, char **argv) /* Press the button(s) */ for (button_idx = 0; button_idx < BUTTON_COUNT; button_idx++) - if (button_mask & (1 << button_idx)) + if (button_mask & BIT(button_idx)) button_interrupt_simulate(button_idx); /* Hold the button(s) */ @@ -372,7 +372,7 @@ static int console_command_button(int argc, char **argv) /* Release the button(s) */ for (button_idx = 0; button_idx < BUTTON_COUNT; button_idx++) - if (button_mask & (1 << button_idx)) + if (button_mask & BIT(button_idx)) button_interrupt_simulate(button_idx); /* Wait till button processing is finished */ diff --git a/common/charge_manager.c b/common/charge_manager.c index 6793b095b4..dcb819ee3a 100644 --- a/common/charge_manager.c +++ b/common/charge_manager.c @@ -1050,12 +1050,12 @@ int charge_manager_get_power_limit_uw(void) static inline int has_other_active_source(int port) { - return source_port_bitmap & ~(1 << port); + return source_port_bitmap & ~BIT(port); } static inline int is_active_source(int port) { - return source_port_bitmap & (1 << port); + return source_port_bitmap & BIT(port); } static int can_supply_max_current(int port) diff --git a/common/dptf.c b/common/dptf.c index 23e597bec9..0596b4100f 100644 --- a/common/dptf.c +++ b/common/dptf.c @@ -45,8 +45,8 @@ int dptf_query_next_sensor_event(void) int id; for (id = 0; id < TEMP_SENSOR_COUNT; id++) - if (dptf_seen & (1 << id)) { /* atomic? */ - atomic_clear(&dptf_seen, (1 << id)); + if (dptf_seen & BIT(id)) { /* atomic? */ + atomic_clear(&dptf_seen, BIT(id)); return id; } @@ -73,13 +73,13 @@ static int dpft_check_temp_threshold(int sensor_id, int temp) if (cond_went_true(&dptf_threshold[sensor_id][i].over)) { CPRINTS("DPTF over threshold [%d][%d", sensor_id, i); - atomic_or(&dptf_seen, (1 << sensor_id)); + atomic_or(&dptf_seen, BIT(sensor_id)); tripped = 1; } if (cond_went_false(&dptf_threshold[sensor_id][i].over)) { CPRINTS("DPTF under threshold [%d][%d", sensor_id, i); - atomic_or(&dptf_seen, (1 << sensor_id)); + atomic_or(&dptf_seen, BIT(sensor_id)); tripped = 1; } } @@ -97,7 +97,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; - atomic_clear(&dptf_seen, (1 << sensor_id)); + atomic_clear(&dptf_seen, BIT(sensor_id)); } else { dptf_threshold[sensor_id][idx].temp = -1; } diff --git a/common/fpsensor.c b/common/fpsensor.c index b3b376a400..d30d13ca40 100644 --- a/common/fpsensor.c +++ b/common/fpsensor.c @@ -167,7 +167,7 @@ static uint32_t fp_process_enroll(void) if (res < 0) return EC_MKBP_FP_ENROLL | EC_MKBP_FP_ERRCODE(EC_MKBP_FP_ERR_ENROLL_INTERNAL); - templ_dirty |= (1 << templ_valid); + templ_dirty |= BIT(templ_valid); if (percent == 100) { res = fp_enrollment_finish(fp_template[templ_valid]); if (res) @@ -694,7 +694,7 @@ static int fp_command_frame(struct host_cmd_handler_args *args) CPRINTS("fgr%d: Failed to encrypt template", fgr); return EC_RES_UNAVAILABLE; } - templ_dirty &= ~(1 << fgr); + templ_dirty &= ~BIT(fgr); } memcpy(out, fp_enc_buffer + offset, size); args->response_size = size; diff --git a/common/i2c_master.c b/common/i2c_master.c index bda3561d34..cfc1a9108a 100644 --- a/common/i2c_master.c +++ b/common/i2c_master.c @@ -178,7 +178,7 @@ void i2c_lock(int port, int lock) } else { interrupt_disable(); - i2c_port_active_list &= ~(1 << port); + i2c_port_active_list &= ~BIT(port); /* Once there is no i2c port active, enable sleep bit of i2c. */ if (!i2c_port_active_list) enable_sleep(SLEEP_MASK_I2C_MASTER); diff --git a/common/keyboard_mkbp.c b/common/keyboard_mkbp.c index 186475b4dd..bca1385391 100644 --- a/common/keyboard_mkbp.c +++ b/common/keyboard_mkbp.c @@ -50,7 +50,7 @@ */ #define BATTERY_KEY_COL 0 #define BATTERY_KEY_ROW 7 -#define BATTERY_KEY_ROW_MASK (1 << BATTERY_KEY_ROW) +#define BATTERY_KEY_ROW_MASK BIT(BATTERY_KEY_ROW) static uint32_t fifo_start; /* first entry */ static uint32_t fifo_end; /* last entry */ @@ -238,7 +238,7 @@ test_mockable int mkbp_fifo_add(uint8_t event_type, const uint8_t *buffp) void mkbp_update_switches(uint32_t sw, int state) { - mkbp_switch_state &= ~(1 << sw); + mkbp_switch_state &= ~BIT(sw); mkbp_switch_state |= (!!state << sw); mkbp_fifo_add(EC_MKBP_EVENT_SWITCH, @@ -280,22 +280,22 @@ void keyboard_update_button(enum keyboard_button_type button, int is_pressed) { switch (button) { case KEYBOARD_BUTTON_POWER: - mkbp_button_state &= ~(1 << EC_MKBP_POWER_BUTTON); + mkbp_button_state &= ~BIT(EC_MKBP_POWER_BUTTON); mkbp_button_state |= (is_pressed << EC_MKBP_POWER_BUTTON); break; case KEYBOARD_BUTTON_VOLUME_UP: - mkbp_button_state &= ~(1 << EC_MKBP_VOL_UP); + mkbp_button_state &= ~BIT(EC_MKBP_VOL_UP); mkbp_button_state |= (is_pressed << EC_MKBP_VOL_UP); break; case KEYBOARD_BUTTON_VOLUME_DOWN: - mkbp_button_state &= ~(1 << EC_MKBP_VOL_DOWN); + mkbp_button_state &= ~BIT(EC_MKBP_VOL_DOWN); mkbp_button_state |= (is_pressed << EC_MKBP_VOL_DOWN); break; case KEYBOARD_BUTTON_RECOVERY: - mkbp_button_state &= ~(1 << EC_MKBP_RECOVERY); + mkbp_button_state &= ~BIT(EC_MKBP_RECOVERY); mkbp_button_state |= (is_pressed << EC_MKBP_RECOVERY); break; @@ -418,15 +418,15 @@ static uint32_t get_supported_buttons(void) uint32_t val = 0; #ifdef CONFIG_VOLUME_BUTTONS - val |= (1 << EC_MKBP_VOL_UP) | (1 << EC_MKBP_VOL_DOWN); + val |= BIT(EC_MKBP_VOL_UP) | BIT(EC_MKBP_VOL_DOWN); #endif /* defined(CONFIG_VOLUME_BUTTONS) */ #ifdef CONFIG_DEDICATED_RECOVERY_BUTTON - val |= (1 << EC_MKBP_RECOVERY); + val |= BIT(EC_MKBP_RECOVERY); #endif /* defined(CONFIG_DEDICATED_RECOVERY_BUTTON) */ #ifdef CONFIG_POWER_BUTTON - val |= (1 << EC_MKBP_POWER_BUTTON); + val |= BIT(EC_MKBP_POWER_BUTTON); #endif /* defined(CONFIG_POWER_BUTTON) */ return val; @@ -437,13 +437,13 @@ static uint32_t get_supported_switches(void) uint32_t val = 0; #ifdef CONFIG_LID_SWITCH - val |= (1 << EC_MKBP_LID_OPEN); + val |= BIT(EC_MKBP_LID_OPEN); #endif #ifdef CONFIG_TABLET_MODE_SWITCH - val |= (1 << EC_MKBP_TABLET_MODE); + val |= BIT(EC_MKBP_TABLET_MODE); #endif #ifdef CONFIG_BASE_ATTACHED_SWITCH - val |= (1 << EC_MKBP_BASE_ATTACHED); + val |= BIT(EC_MKBP_BASE_ATTACHED); #endif return val; } @@ -536,12 +536,12 @@ DECLARE_HOST_COMMAND(EC_CMD_MKBP_INFO, mkbp_get_info, /* For boards without a keyscan task, try and simulate keyboard presses. */ static void simulate_key(int row, int col, int pressed) { - if ((simulated_key[col] & (1 << row)) == ((pressed ? 1 : 0) << row)) + if ((simulated_key[col] & BIT(row)) == ((pressed ? 1 : 0) << row)) return; /* No change */ - simulated_key[col] &= ~(1 << row); + simulated_key[col] &= ~BIT(row); if (pressed) - simulated_key[col] |= (1 << row); + simulated_key[col] |= BIT(row); keyboard_fifo_add(simulated_key); } @@ -556,7 +556,7 @@ static int command_mkbp_keyboard_press(int argc, char **argv) if (simulated_key[i] == 0) continue; for (j = 0; j < KEYBOARD_ROWS; ++j) - if (simulated_key[i] & (1 << j)) + if (simulated_key[i] & BIT(j)) ccprintf("\t%d %d\n", i, j); } diff --git a/common/keyboard_scan.c b/common/keyboard_scan.c index 24fc7bc73c..a8f843e0a2 100644 --- a/common/keyboard_scan.c +++ b/common/keyboard_scan.c @@ -197,10 +197,10 @@ static void simulate_key(int row, int col, int pressed) { int old_polls; - if ((simulated_key[col] & (1 << row)) == ((pressed ? 1 : 0) << row)) + if ((simulated_key[col] & BIT(row)) == ((pressed ? 1 : 0) << row)) return; /* No change */ - simulated_key[col] ^= (1 << row); + simulated_key[col] ^= BIT(row); /* Keep track of polls now that we've got keys simulated */ old_polls = kbd_polls; @@ -481,7 +481,7 @@ static int check_keys_changed(uint8_t *state) continue; for (i = 0; i < KEYBOARD_ROWS; i++) { - if (diff & (1 << i)) + if (diff & BIT(i)) scan_edge_index[c][i] = scan_time_index; } @@ -601,7 +601,7 @@ static uint32_t check_key_list(const uint8_t *state) k = boot_key_list; for (c = 0; c < ARRAY_SIZE(boot_key_list); c++, k++) { if (curr_state[k->mask_index] & k->mask_value) { - boot_key_mask |= (1 << c); + boot_key_mask |= BIT(c); curr_state[k->mask_index] &= ~k->mask_value; } } @@ -1005,7 +1005,7 @@ static int command_keyboard_press(int argc, char **argv) if (simulated_key[i] == 0) continue; for (j = 0; j < KEYBOARD_ROWS; ++j) - if (simulated_key[i] & (1 << j)) + if (simulated_key[i] & BIT(j)) ccprintf("\t%d %d\n", i, j); } diff --git a/common/lightbar.c b/common/lightbar.c index c7fed67e7e..c0dd35e56b 100644 --- a/common/lightbar.c +++ b/common/lightbar.c @@ -1322,7 +1322,7 @@ static uint32_t lightbyte_SET_COLOR_SINGLE(void) return EC_RES_INVALID_PARAM; for (i = 0; i < NUM_LEDS; i++) - if (led & (1 << i)) + if (led & BIT(i)) led_desc[i][control][color] = value; return EC_SUCCESS; @@ -1350,7 +1350,7 @@ static uint32_t lightbyte_SET_COLOR_RGB(void) return EC_RES_INVALID_PARAM; for (i = 0; i < NUM_LEDS; i++) - if (led & (1 << i)) { + if (led & BIT(i)) { led_desc[i][control][LB_COL_RED] = r; led_desc[i][control][LB_COL_GREEN] = g; led_desc[i][control][LB_COL_BLUE] = b; diff --git a/common/mkbp_event.c b/common/mkbp_event.c index d604600a0f..fc70035a10 100644 --- a/common/mkbp_event.c +++ b/common/mkbp_event.c @@ -31,7 +31,7 @@ static void clear_event(uint8_t event_type) static int event_is_set(uint8_t event_type) { - return events & (1 << event_type); + return events & BIT(event_type); } #ifdef CONFIG_MKBP_USE_GPIO diff --git a/common/motion_sense.c b/common/motion_sense.c index e0332ae073..9601970f7b 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -557,7 +557,7 @@ static void motion_sense_shutdown(void) sensor->drv->list_activities(sensor, &enabled, &disabled); /* exclude double tap, it is used internally. */ - enabled &= ~(1 << MOTIONSENSE_ACTIVITY_DOUBLE_TAP); + enabled &= ~BIT(MOTIONSENSE_ACTIVITY_DOUBLE_TAP); while (enabled) { int activity = get_next_bit(&enabled); sensor->drv->manage_activity(sensor, activity, 0, NULL); @@ -927,8 +927,8 @@ void motion_sense_task(void *u) uint16_t ready_status; struct motion_sensor_t *sensor; #ifdef CONFIG_LID_ANGLE - const uint16_t lid_angle_sensors = ((1 << CONFIG_LID_ANGLE_SENSOR_BASE)| - (1 << CONFIG_LID_ANGLE_SENSOR_LID)); + const uint16_t lid_angle_sensors = (BIT(CONFIG_LID_ANGLE_SENSOR_BASE)| + BIT(CONFIG_LID_ANGLE_SENSOR_LID)); #endif #ifdef CONFIG_ACCEL_FIFO timestamp_t ts_last_int; @@ -961,7 +961,7 @@ void motion_sense_task(void *u) &ts_begin_task); if (ret != EC_SUCCESS) continue; - ready_status |= (1 << i); + ready_status |= BIT(i); } } #ifdef CONFIG_GESTURE_DETECTION diff --git a/common/switch.c b/common/switch.c index 93650c2629..f7f07ad99a 100644 --- a/common/switch.c +++ b/common/switch.c @@ -122,7 +122,7 @@ static int command_mmapinfo(int argc, char **argv) }; ccprintf("memmap switches = 0x%x\n", val); for (i = 0; i < ARRAY_SIZE(explanation); i++) - if (val & (1 << i)) + if (val & BIT(i)) ccprintf(" %s\n", explanation[i]); return EC_SUCCESS; diff --git a/common/system.c b/common/system.c index 467218560a..d956787e74 100644 --- a/common/system.c +++ b/common/system.c @@ -285,7 +285,7 @@ void system_print_reset_flags(void) } for (i = 0; i < ARRAY_SIZE(reset_flag_descs); i++) { - if (reset_flags & (1 << i)) { + if (reset_flags & BIT(i)) { if (count++) CPUTS(" "); diff --git a/common/throttle_ap.c b/common/throttle_ap.c index 209948a482..d82d5429e5 100644 --- a/common/throttle_ap.c +++ b/common/throttle_ap.c @@ -30,7 +30,7 @@ void throttle_ap(enum throttle_level level, mutex_lock(&throttle_mutex); - bitmask = (1 << source); + bitmask = BIT(source); switch (level) { case THROTTLE_ON: diff --git a/common/timer.c b/common/timer.c index 117cea4b71..776d1b8a62 100644 --- a/common/timer.c +++ b/common/timer.c @@ -77,7 +77,7 @@ void process_timers(int overflow) next.le.lo)) next.val = timer_deadline[tskid].val; - check_timer &= ~(1 << tskid); + check_timer &= ~BIT(tskid); } /* if there is a new timer, let's retry */ } while (timer_running & ~running_t0); diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index ebac69b209..730281c9b5 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -477,7 +477,7 @@ static int reset_device_and_notify(int port) /* Wake up all waiting tasks. */ while (waiting_tasks) { task = __fls(waiting_tasks); - waiting_tasks &= ~(1 << task); + waiting_tasks &= ~BIT(task); task_set_event(task, TASK_EVENT_PD_AWAKE, 0); } @@ -4366,7 +4366,7 @@ static void resume_pd_port(void) while (suspended_ports) { port = __builtin_ctz(suspended_ports); - suspended_ports &= ~(1 << port); + suspended_ports &= ~BIT(port); pd_set_suspend(port, 0); } } @@ -4574,7 +4574,7 @@ static void re_enable_ports(void) while (ports) { int port = __fls(ports); - ports &= ~(1 << port); + ports &= ~BIT(port); /* * Let the board know that the overcurrent is @@ -4605,7 +4605,7 @@ void pd_handle_overcurrent(int port) board_overcurrent_event(port, 1); /* Wait 1s before trying to re-enable the port. */ - atomic_or(&port_oc_reset_req, (1 << port)); + atomic_or(&port_oc_reset_req, BIT(port)); hook_call_deferred(&re_enable_ports_data, SECOND); } #endif /* defined(CONFIG_USBC_PPC) */ diff --git a/common/usbc_ppc.c b/common/usbc_ppc.c index 54da1f22b4..2904c00ded 100644 --- a/common/usbc_ppc.c +++ b/common/usbc_ppc.c @@ -69,7 +69,7 @@ static void clear_oc_tbl(void) * Only clear the table if the port partner is no longer * attached after debouncing. */ - if ((!((1 << port) & connected_ports)) && + if ((!(BIT(port) & connected_ports)) && oc_event_cnt_tbl[port]) { oc_event_cnt_tbl[port] = 0; CPRINTS("C%d: OC events cleared", port); diff --git a/common/util.c b/common/util.c index 1261def58f..8005e0bfdb 100644 --- a/common/util.c +++ b/common/util.c @@ -506,7 +506,7 @@ int uint64divmod(uint64_t *n, int d) int get_next_bit(uint32_t *mask) { int bit = 31 - __builtin_clz(*mask); - *mask &= ~(1 << bit); + *mask &= ~BIT(bit); return bit; } |