[PATCH] gpio: intel_gpio: Initialise or0 and or1

Andrew Goodbody andrew.goodbody at linaro.org
Fri Jul 25 14:04:26 CEST 2025


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 at linaro.org>
---
 drivers/gpio/intel_gpio.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/gpio/intel_gpio.c b/drivers/gpio/intel_gpio.c
index 0ab6e8a90bc..ac2fb8bc2cc 100644
--- a/drivers/gpio/intel_gpio.c
+++ b/drivers/gpio/intel_gpio.c
@@ -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);

---
base-commit: 021783860f7e628f7c4e0c101707cd4250e6d61f
change-id: 20250725-intel_gpio-592996809013

Best regards,
-- 
Andrew Goodbody <andrew.goodbody at linaro.org>



More information about the U-Boot mailing list