diff mbox series

[v2,14/18] common: board_r: Drop initr_api wrapper

Message ID 20201122083556.6756-15-ovidiu.panait@windriver.com
State Superseded
Delegated to: Tom Rini
Headers show
Series Minor board_f/board_r cleanups | expand

Commit Message

Ovidiu Panait Nov. 22, 2020, 8:35 a.m. UTC
Add a return value to api_init and use it directly in the
post-relocation init sequence, rather than using a wrapper stub.

Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
---
v2 updates:
- add function comment

 api/api.c         |  6 ++++--
 api/api_private.h |  2 +-
 common/board_r.c  | 11 +----------
 include/api.h     | 10 +++++++++-
 4 files changed, 15 insertions(+), 14 deletions(-)

Comments

Simon Glass Nov. 23, 2020, 1:28 a.m. UTC | #1
On Sun, 22 Nov 2020 at 01:37, Ovidiu Panait <ovidiu.panait@windriver.com> wrote:
>
> Add a return value to api_init and use it directly in the
> post-relocation init sequence, rather than using a wrapper stub.
>
> Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
> ---
> v2 updates:
> - add function comment
>
>  api/api.c         |  6 ++++--
>  api/api_private.h |  2 +-
>  common/board_r.c  | 11 +----------
>  include/api.h     | 10 +++++++++-
>  4 files changed, 15 insertions(+), 14 deletions(-)

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

Patch

diff --git a/api/api.c b/api/api.c
index 493b77f809..89003c161c 100644
--- a/api/api.c
+++ b/api/api.c
@@ -642,7 +642,7 @@  int syscall(int call, int *retval, ...)
 	return 1;
 }
 
-void api_init(void)
+int api_init(void)
 {
 	struct api_signature *sig;
 
@@ -679,7 +679,7 @@  void api_init(void)
 	sig = malloc(sizeof(struct api_signature));
 	if (sig == NULL) {
 		printf("API: could not allocate memory for the signature!\n");
-		return;
+		return -ENOMEM;
 	}
 
 	env_set_hex("api_address", (unsigned long)sig);
@@ -691,6 +691,8 @@  void api_init(void)
 	sig->checksum = crc32(0, (unsigned char *)sig,
 			      sizeof(struct api_signature));
 	debugf("syscall entry: 0x%lX\n", (unsigned long)sig->syscall);
+
+	return 0;
 }
 
 void platform_set_mr(struct sys_info *si, unsigned long start, unsigned long size,
diff --git a/api/api_private.h b/api/api_private.h
index 07fd50ad3a..bb23821c2c 100644
--- a/api/api_private.h
+++ b/api/api_private.h
@@ -8,7 +8,7 @@ 
 #ifndef _API_PRIVATE_H_
 #define _API_PRIVATE_H_
 
-void	api_init(void);
+int	api_init(void);
 void	platform_set_mr(struct sys_info *, unsigned long, unsigned long, int);
 int	platform_sys_info(struct sys_info *);
 
diff --git a/common/board_r.c b/common/board_r.c
index 32ad40d372..500457b080 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -490,15 +490,6 @@  static int initr_malloc_bootparams(void)
 }
 #endif
 
-#if defined(CONFIG_API)
-static int initr_api(void)
-{
-	/* Initialize API */
-	api_init();
-	return 0;
-}
-#endif
-
 #ifdef CONFIG_CMD_NET
 static int initr_ethaddr(void)
 {
@@ -753,7 +744,7 @@  static init_fnc_t init_sequence_r[] = {
 	stdio_add_devices,
 	jumptable_init,
 #ifdef CONFIG_API
-	initr_api,
+	api_init,
 #endif
 	console_init_r,		/* fully init console as a device */
 #ifdef CONFIG_DISPLAY_BOARDINFO_LATE
diff --git a/include/api.h b/include/api.h
index 84d81dc817..83412a7c87 100644
--- a/include/api.h
+++ b/include/api.h
@@ -7,6 +7,14 @@ 
 #ifndef __API_H
 #define __API_H
 
-void api_init(void);
+/**
+ * api_init() - Initialize API for external applications
+ *
+ * Initialize API for external (standalone) applications running on top of
+ * U-Boot. It is called during the generic post-relocation init sequence.
+ *
+ * Return: 0 if OK
+ */
+int api_init(void);
 
 #endif