Skip to content

Commit 6176b2c

Browse files
committed
drivers: gpio: wch: simplify port_toggle_bits logic
computation of BSHR was unnecessarily complex, with redundant XOR/masking operations. Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
1 parent f080c4f commit 6176b2c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/gpio/wch_gpio_ch32v00x.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ static int gpio_ch32v00x_port_clear_bits_raw(const struct device *dev, uint32_t
104104
static int gpio_ch32v00x_port_toggle_bits(const struct device *dev, uint32_t pins)
105105
{
106106
const struct gpio_ch32v00x_config *config = dev->config;
107-
uint32_t changed = (config->regs->OUTDR ^ pins) & pins;
107+
uint32_t current = config->regs->OUTDR;
108108

109-
config->regs->BSHR = (changed & pins) | (~changed & pins) << 16;
109+
config->regs->BSHR = (~current & pins) | (current & pins) << 16;
110110

111111
return 0;
112112
}

0 commit comments

Comments
 (0)