[PATCH 5/5] sysreset: move print_resetinfo() to sysreset-uclass.c

Rasmus Villemoes rasmus.villemoes at prevas.dk
Fri May 1 16:55:16 CEST 2020


Moving this out of board_f.c allows board-specific SPL code to call
this rather than duplicating its implementation.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes at prevas.dk>
---
 common/board_f.c                   | 24 ------------------------
 drivers/sysreset/sysreset-uclass.c | 22 ++++++++++++++++++++++
 include/sysreset.h                 |  5 +++++
 3 files changed, 27 insertions(+), 24 deletions(-)

diff --git a/common/board_f.c b/common/board_f.c
index 82a164752a..252ad1c520 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -152,30 +152,6 @@ static int display_text_info(void)
 	return 0;
 }
 
-#ifdef CONFIG_SYSRESET
-static int print_resetinfo(void)
-{
-	struct udevice *dev;
-	char status[256];
-	int ret;
-
-	ret = uclass_first_device_err(UCLASS_SYSRESET, &dev);
-	if (ret) {
-		debug("%s: No sysreset device found (error: %d)\n",
-		      __func__, ret);
-		/* Not all boards have sysreset drivers available during early
-		 * boot, so don't fail if one can't be found.
-		 */
-		return 0;
-	}
-
-	if (!sysreset_get_status(dev, status, sizeof(status)))
-		printf("%s", status);
-
-	return 0;
-}
-#endif
-
 #if defined(CONFIG_DISPLAY_CPUINFO) && CONFIG_IS_ENABLED(CPU)
 static int print_cpuinfo(void)
 {
diff --git a/drivers/sysreset/sysreset-uclass.c b/drivers/sysreset/sysreset-uclass.c
index 51fdb1055e..739e4526ff 100644
--- a/drivers/sysreset/sysreset-uclass.c
+++ b/drivers/sysreset/sysreset-uclass.c
@@ -18,6 +18,28 @@
 #include <dm/root.h>
 #include <linux/err.h>
 
+int print_resetinfo(void)
+{
+	struct udevice *dev;
+	char status[256];
+	int ret;
+
+	ret = uclass_first_device_err(UCLASS_SYSRESET, &dev);
+	if (ret) {
+		debug("%s: No sysreset device found (error: %d)\n",
+		      __func__, ret);
+		/* Not all boards have sysreset drivers available during early
+		 * boot, so don't fail if one can't be found.
+		 */
+		return 0;
+	}
+
+	if (!sysreset_get_status(dev, status, sizeof(status)))
+		printf("%s", status);
+
+	return 0;
+}
+
 int sysreset_request(struct udevice *dev, enum sysreset_t type)
 {
 	struct sysreset_ops *ops = sysreset_get_ops(dev);
diff --git a/include/sysreset.h b/include/sysreset.h
index 61295e3fcb..5f402b9d04 100644
--- a/include/sysreset.h
+++ b/include/sysreset.h
@@ -116,4 +116,9 @@ void sysreset_walk_halt(enum sysreset_t type);
  */
 void reset_cpu(ulong addr);
 
+/**
+ * print_resetinfo() - print reset information to console
+ */
+int print_resetinfo(void);
+
 #endif
-- 
2.23.0



More information about the U-Boot mailing list