uart: Prevent UART read/write before intialization.
Check if UART is initalized before reading or writing on it.
Change-Id: I7edd7960c3a90f93a6293c4a6278d820f9ad3937
diff --git a/platform/msm_shared/uart_dm.c b/platform/msm_shared/uart_dm.c
index 01cf5a4..3ac657f 100644
--- a/platform/msm_shared/uart_dm.c
+++ b/platform/msm_shared/uart_dm.c
@@ -46,6 +46,8 @@
extern void dsb(void);
+static int uart_init_flag = 0;
+
/* Note:
* This is a basic implementation of UART_DM protocol. More focus has been
* given on simplicity than efficiency. Few of the things to be noted are:
@@ -419,6 +421,9 @@
ASSERT(port < ARRAY_SIZE(gsbi_lookup));
gsbi_lookup[port++] = gsbi_id;
+
+ /* Set UART init flag */
+ uart_init_flag = 1;
}
@@ -431,6 +436,10 @@
{
uint8_t gsbi_id = gsbi_lookup[port];
+ /* Don't do anything if UART is not initialized */
+ if(!uart_init_flag)
+ return;
+
msm_boot_uart_dm_write(gsbi_id, &c, 1);
return 0;
@@ -446,6 +455,10 @@
static unsigned int word = 0;
uint8_t gsbi_id = gsbi_lookup[port];
+ /* Don't do anything if UART is not initialized */
+ if(!uart_init_flag)
+ return;
+
if (!word)
{
/* Read from FIFO only if it's a first read or all the four