From ada791db3eb13ad5ac0447c8c8b0343c4d771fb9 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Pali=20Roh=C3=A1r?= <pali@kernel.org>
Date: Fri, 8 Apr 2022 16:30:13 +0200
Subject: [PATCH] board: turris: Do not cache Atsha device in BSS
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit

Atsha device is used prior relocation and at this early stage BSS does not
have to be ready yet. So do not cache Atsha device in BSS.

Fixes support for other Turris routers.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
---
 board/CZ.NIC/turris_atsha_otp.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/board/CZ.NIC/turris_atsha_otp.c b/board/CZ.NIC/turris_atsha_otp.c
index a4a77c74fb..840721a9b7 100644
--- a/board/CZ.NIC/turris_atsha_otp.c
+++ b/board/CZ.NIC/turris_atsha_otp.c
@@ -18,10 +18,8 @@
 
 static struct udevice *get_atsha204a_dev(void)
 {
-	static struct udevice *dev;
-
-	if (dev)
-		return dev;
+	/* Cannot be static because BSS does not have to be ready at this early stage */
+	struct udevice *dev;
 
 	if (uclass_get_device_by_name(UCLASS_MISC, "atsha204a@64", &dev)) {
 		puts("Cannot find ATSHA204A on I2C bus!\n");
-- 
2.39.5