From 62b02c515fc8195eae2155921ee283eddd1cac9e Mon Sep 17 00:00:00 2001 From: Urja Rannikko Date: Sun, 31 Jul 2016 13:39:08 +0300 Subject: [PATCH] usb: Simplify TOG_SET_REG_BIT_MSK_AND_SET A xor B with B=0 is A, thus this should be correct and faster. --- include/libopencm3/stm32/tools.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/include/libopencm3/stm32/tools.h b/include/libopencm3/stm32/tools.h index c7ef7c1d..ef8d7b06 100644 --- a/include/libopencm3/stm32/tools.h +++ b/include/libopencm3/stm32/tools.h @@ -56,12 +56,7 @@ #define TOG_SET_REG_BIT_MSK_AND_SET(REG, MSK, BIT, EXTRA_BITS) \ do { \ register uint16_t toggle_mask = GET_REG(REG) & (MSK); \ - register uint16_t bit_selector; \ - for (bit_selector = 1; bit_selector; bit_selector <<= 1) { \ - if ((bit_selector & (BIT)) != 0) { \ - toggle_mask ^= bit_selector; \ - } \ - } \ + toggle_mask ^= BIT; \ SET_REG((REG), toggle_mask | (EXTRA_BITS)); \ } while (0)