From 311787032ad79ddd796e2eef478e1f40018c90c1 Mon Sep 17 00:00:00 2001 From: Mingqiang Chi Date: Tue, 24 Jul 2018 14:32:50 +0800 Subject: [PATCH] hv:Change shell_init to void type Remove shell_construct Change shell_init to void type Signed-off-by: Mingqiang Chi Acked-by: Eddie Dong --- hypervisor/debug/shell_internal.c | 14 ------------- hypervisor/debug/shell_internal.h | 1 - hypervisor/debug/shell_public.c | 35 ++++++++++++------------------- hypervisor/include/debug/shell.h | 4 ++-- 4 files changed, 15 insertions(+), 39 deletions(-) diff --git a/hypervisor/debug/shell_internal.c b/hypervisor/debug/shell_internal.c index 5b3bc0869..262964d78 100644 --- a/hypervisor/debug/shell_internal.c +++ b/hypervisor/debug/shell_internal.c @@ -1159,17 +1159,3 @@ void shell_special_serial(struct shell *p_shell, uint8_t ch) break; } } - -int shell_construct(struct shell **p_shell) -{ - int status = 0; - /* Allocate memory for shell session */ - *p_shell = (struct shell *) calloc(1, sizeof(**p_shell)); - - if ((*p_shell) == NULL) { - pr_err("Error: out of memory"); - status = -ENOMEM; - } - - return status; -} diff --git a/hypervisor/debug/shell_internal.h b/hypervisor/debug/shell_internal.h index 336b57905..28d97b742 100644 --- a/hypervisor/debug/shell_internal.h +++ b/hypervisor/debug/shell_internal.h @@ -139,7 +139,6 @@ struct shell_cmd { /* Global function prototypes */ int shell_show_req_info(struct shell *p_shell, int argc, char **argv); -int shell_construct(struct shell **p_shell); int shell_cmd_help(struct shell *p_shell, int argc, char **argv); int shell_list_vm(struct shell *p_shell, int argc, char **argv); int shell_list_vcpu(struct shell *p_shell, int argc, char **argv); diff --git a/hypervisor/debug/shell_public.c b/hypervisor/debug/shell_public.c index 17ed1c40b..9a100e429 100644 --- a/hypervisor/debug/shell_public.c +++ b/hypervisor/debug/shell_public.c @@ -8,7 +8,7 @@ #include "shell_internal.h" /* Shell that uses serial I/O */ -static struct shell *serial_session; +static struct shell serial_session; static struct shell_cmd acrn_cmd[] = { { @@ -133,31 +133,22 @@ static struct shell_cmd acrn_cmd[] = { }, }; -int shell_init(void) +void shell_init(void) { - int status; - - status = shell_construct(&serial_session); - if (status != 0) { - return status; - } - /* Set the function pointers for the shell i/p and o/p functions */ - serial_session->session_io.io_init = shell_init_serial; - serial_session->session_io.io_deinit = shell_terminate_serial; - serial_session->session_io.io_puts = shell_puts_serial; - serial_session->session_io.io_getc = shell_getc_serial; - serial_session->session_io.io_special = shell_special_serial; - serial_session->session_io.io_echo_on = (bool)true; + serial_session.session_io.io_init = shell_init_serial; + serial_session.session_io.io_deinit = shell_terminate_serial; + serial_session.session_io.io_puts = shell_puts_serial; + serial_session.session_io.io_getc = shell_getc_serial; + serial_session.session_io.io_special = shell_special_serial; + serial_session.session_io.io_echo_on = (bool)true; - serial_session->shell_cmd = acrn_cmd; - serial_session->cmd_count = ARRAY_SIZE(acrn_cmd); + serial_session.shell_cmd = acrn_cmd; + serial_session.cmd_count = ARRAY_SIZE(acrn_cmd); /* Initialize the handler for the serial port that will be used * for shell i/p and o/p */ - status = serial_session->session_io.io_init(serial_session); - - return status; + serial_session.session_io.io_init(&serial_session); } /** @@ -194,7 +185,7 @@ int shell_set_name(struct shell *p_shell, const char *name) void shell_kick_session(void) { /* Kick the shell */ - kick_shell(serial_session); + kick_shell(&serial_session); } int shell_switch_console(void) @@ -208,7 +199,7 @@ int shell_switch_console(void) vuart->active = false; /* Output that switching to ACRN shell */ - shell_puts(serial_session, + shell_puts(&serial_session, "\r\n\r\n----- Entering ACRN Shell -----\r\n"); return 0; } diff --git a/hypervisor/include/debug/shell.h b/hypervisor/include/debug/shell.h index d9e6b9262..6a71411be 100644 --- a/hypervisor/include/debug/shell.h +++ b/hypervisor/include/debug/shell.h @@ -11,11 +11,11 @@ #define GUEST_CONSOLE_TO_HV_SWITCH_KEY 0 /* CTRL + SPACE */ #ifdef HV_DEBUG -int shell_init(void); +void shell_init(void); void shell_kick_session(void); int shell_switch_console(void); #else -static inline int shell_init(void) { return 0; } +static inline void shell_init(void) {} static inline void shell_kick_session(void) {} static inline int shell_switch_console(void) { return 0; } #endif