From cfc5209a4953a348797f70a41f0faecb51f5a0d7 Mon Sep 17 00:00:00 2001
From: Felix Gerking <felix.gerking@garz-fricke.com>
Date: Fri, 13 Jan 2023 16:26:00 +0100
Subject: [PATCH] touchdriver:kernel-module-touchgpio: Initialize pin values by
 default

Initialize values for reset, wake and irq pins to -1, otherwise
gpio_is_valid could evaluate them wrongly.

BCS 746-000997
---
 .../touchdriver/kernel-module-touchgpio/src/touch_gpio.c    | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/recipes-kernel/touchdriver/kernel-module-touchgpio/src/touch_gpio.c b/recipes-kernel/touchdriver/kernel-module-touchgpio/src/touch_gpio.c
index 35991ee2..ba61c649 100644
--- a/recipes-kernel/touchdriver/kernel-module-touchgpio/src/touch_gpio.c
+++ b/recipes-kernel/touchdriver/kernel-module-touchgpio/src/touch_gpio.c
@@ -125,8 +125,12 @@ static struct touch_gpio * touch_gpio_allocate(struct device *dev)
 		dev_err(dev, "Failed to allocate touch_gpio struct\n");
 	else
 		gpios->dev = dev;
-	return gpios;
 
+	/* Initialize pins to -1, otherwise gpio_is_valid could evaluate them wrongly */
+	gpios->reset_pin = -1;
+	gpios->wake_pin = -1;
+	gpios->irq_pin = -1;
+	return gpios;
 }
 
 void touch_gpio_free ( struct touch_gpio * gpios)
-- 
GitLab