]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
gpio: intel_gpio: Initialise or0 and or1
authorAndrew Goodbody <andrew.goodbody@linaro.org>
Fri, 25 Jul 2025 12:04:26 +0000 (13:04 +0100)
committerTom Rini <trini@konsulko.com>
Tue, 28 Oct 2025 16:32:59 +0000 (10:32 -0600)
In intel_gpio_set_flags the two variables or0 and or1 may be used
uninitialised. Correct this by setting initial values in the
declaration.
Also there is no need to use '|=' when the initial value is 0 and there
is only one assignment performed to each variable so just use '='
instead.

This issue was found by Smatch.

Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
drivers/gpio/intel_gpio.c

index 0ab6e8a90bcba8c23758ad68fca169bbb0cc17fb..ac2fb8bc2cccbf72ebf3338913b0a31bbeed73ff 100644 (file)
@@ -116,26 +116,26 @@ static int intel_gpio_set_flags(struct udevice *dev, unsigned int offset,
 {
        struct udevice *pinctrl = dev_get_parent(dev);
        u32 bic0 = 0, bic1 = 0;
-       u32 or0, or1;
+       u32 or0 = 0, or1 = 0;
        uint config_offset;
 
        config_offset = intel_pinctrl_get_config_reg_offset(pinctrl, offset);
 
        if (flags & GPIOD_IS_OUT) {
-               bic0 |= PAD_CFG0_MODE_MASK | PAD_CFG0_RX_STATE |
+               bic0 = PAD_CFG0_MODE_MASK | PAD_CFG0_RX_STATE |
                        PAD_CFG0_TX_DISABLE;
-               or0 |= PAD_CFG0_MODE_GPIO | PAD_CFG0_RX_DISABLE;
+               or0 = PAD_CFG0_MODE_GPIO | PAD_CFG0_RX_DISABLE;
        } else if (flags & GPIOD_IS_IN) {
-               bic0 |= PAD_CFG0_MODE_MASK | PAD_CFG0_TX_STATE |
+               bic0 = PAD_CFG0_MODE_MASK | PAD_CFG0_TX_STATE |
                        PAD_CFG0_RX_DISABLE;
-               or0 |= PAD_CFG0_MODE_GPIO | PAD_CFG0_TX_DISABLE;
+               or0 = PAD_CFG0_MODE_GPIO | PAD_CFG0_TX_DISABLE;
        }
        if (flags & GPIOD_PULL_UP) {
-               bic1 |= PAD_CFG1_PULL_MASK;
-               or1 |= PAD_CFG1_PULL_UP_20K;
+               bic1 = PAD_CFG1_PULL_MASK;
+               or1 = PAD_CFG1_PULL_UP_20K;
        } else if (flags & GPIOD_PULL_DOWN) {
-               bic1 |= PAD_CFG1_PULL_MASK;
-               or1 |= PAD_CFG1_PULL_DN_20K;
+               bic1 = PAD_CFG1_PULL_MASK;
+               or1 = PAD_CFG1_PULL_DN_20K;
        }
 
        pcr_clrsetbits32(pinctrl, PAD_CFG0_OFFSET(config_offset), bic0, or0);