diff mbox series

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

Message ID 20200501145516.18168-6-rasmus.villemoes@prevas.dk
State New
Delegated to: Mario Six
Headers show
Series some sysreset patches (mostly for mpc83xx) | expand

Commit Message

Rasmus Villemoes May 1, 2020, 2:55 p.m. UTC
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@prevas.dk>
---
 common/board_f.c                   | 24 ------------------------
 drivers/sysreset/sysreset-uclass.c | 22 ++++++++++++++++++++++
 include/sysreset.h                 |  5 +++++
 3 files changed, 27 insertions(+), 24 deletions(-)

Comments

Simon Glass May 3, 2020, 2:26 a.m. UTC | #1
Hi Rasmus,

On Fri, 1 May 2020 at 08:55, Rasmus Villemoes
<rasmus.villemoes@prevas.dk> wrote:
>
> 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@prevas.dk>
> ---
>  common/board_f.c                   | 24 ------------------------
>  drivers/sysreset/sysreset-uclass.c | 22 ++++++++++++++++++++++
>  include/sysreset.h                 |  5 +++++
>  3 files changed, 27 insertions(+), 24 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

nits below

Can you also (new patch) rename this to sysreset_print_info() so it
matches its header?

>
> 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

/*
 * Not all ...

> +                * 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
>

Regards,
Simon
diff mbox series

Patch

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