qcacld-3.0: Remove epping context from cds

cds_get_context was not supporting epping.  Allow epping to manage its
own global context since it is a top level module.

Change-Id: Ic5faf885c83109162be141788a5f8871a4e35cef
CRs-Fixed: 967244
diff --git a/core/cds/inc/cds_sched.h b/core/cds/inc/cds_sched.h
index 3ccf3cb..3d8d367 100644
--- a/core/cds/inc/cds_sched.h
+++ b/core/cds/inc/cds_sched.h
@@ -263,7 +263,6 @@
 
 	void *htc_ctx;
 
-	void *epping_ctx;
 	/*
 	 * cdf_ctx will be used by cdf
 	 * while allocating dma memory
diff --git a/core/cds/src/cds_api.c b/core/cds/src/cds_api.c
index 5c36ef3..448aee0 100644
--- a/core/cds/src/cds_api.c
+++ b/core/cds/src/cds_api.c
@@ -1068,10 +1068,6 @@
 	}
 
 	case CDF_MODULE_ID_EPPING:
-	{
-		pGpModContext = &(gp_cds_context->epping_ctx);
-		break;
-	}
 	case CDF_MODULE_ID_SME:
 	case CDF_MODULE_ID_PE:
 	case CDF_MODULE_ID_HDD:
@@ -1154,18 +1150,13 @@
 		break;
 	}
 
-	case CDF_MODULE_ID_EPPING:
-	{
-		pGpModContext = &(gp_cds_context->epping_ctx);
-		break;
-	}
-
 	case CDF_MODULE_ID_TXRX:
 	{
 		pGpModContext = &(gp_cds_context->pdev_txrx_ctx);
 		break;
 	}
 
+	case CDF_MODULE_ID_EPPING:
 	case CDF_MODULE_ID_HDD:
 	case CDF_MODULE_ID_SME:
 	case CDF_MODULE_ID_PE:
diff --git a/core/utils/epping/inc/epping_internal.h b/core/utils/epping/inc/epping_internal.h
index ab68c2b..0ea5d52 100644
--- a/core/utils/epping/inc/epping_internal.h
+++ b/core/utils/epping/inc/epping_internal.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2015 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2016 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -104,7 +104,7 @@
 } epping_poll_t;
 #endif
 
-typedef struct epping_context_s {
+typedef struct epping_context {
 	int32_t con_mode;
 	char *pwlan_module_name;
 	uint32_t target_type;
diff --git a/core/utils/epping/src/epping_main.c b/core/utils/epping/src/epping_main.c
index a625c0b..2fa6375 100644
--- a/core/utils/epping/src/epping_main.c
+++ b/core/utils/epping/src/epping_main.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2015 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2016 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -73,6 +73,8 @@
 #define WLAN_WAIT_TIME_WLANSTART 2000
 #endif
 
+static struct epping_context *g_epping_ctx;
+
 /**
  * epping_open(): End point ping driver open Function
  *
@@ -83,22 +85,17 @@
  */
 int epping_open(void)
 {
-	epping_context_t *pEpping_ctx;
-	v_CONTEXT_t cds_context;
-	CDF_STATUS status = CDF_STATUS_SUCCESS;
-
 	EPPING_LOG(CDF_TRACE_LEVEL_INFO_HIGH, "%s: Enter", __func__);
 
-	cds_context = cds_get_global_context();
-	status = cds_alloc_context(cds_context, CDF_MODULE_ID_EPPING,
-				       (void **)&pEpping_ctx,
-				       sizeof(*pEpping_ctx));
-	if (status != CDF_STATUS_SUCCESS) {
-		EPPING_LOG(CDF_TRACE_LEVEL_ERROR, "%s: cannot alloc epping context", __func__);
+	g_epping_ctx = cdf_mem_malloc(sizeof(*g_epping_ctx));
+
+	if (g_epping_ctx == NULL) {
+		EPPING_LOG(CDF_TRACE_LEVEL_ERROR,
+				"%s: cannot alloc epping context", __func__);
 		return -ENOMEM;
 	}
 
-	pEpping_ctx->con_mode = cds_get_conparam();
+	g_epping_ctx->con_mode = cds_get_conparam();
 	return 0;
 }
 
@@ -114,7 +111,7 @@
 {
 	epping_context_t *pEpping_ctx;
 
-	pEpping_ctx = cds_get_context(CDF_MODULE_ID_EPPING);
+	pEpping_ctx = g_epping_ctx;
 	if (pEpping_ctx == NULL) {
 		EPPING_LOG(CDF_TRACE_LEVEL_FATAL,
 			   "%s: error: pEpping_ctx  = NULL", __func__);
@@ -140,30 +137,31 @@
  */
 void epping_close(void)
 {
-	epping_context_t *pEpping_ctx;
+	epping_context_t *to_free;
 
-	pEpping_ctx = cds_get_context(CDF_MODULE_ID_EPPING);
-	if (pEpping_ctx == NULL) {
+
+	if (g_epping_ctx == NULL) {
 		EPPING_LOG(CDF_TRACE_LEVEL_FATAL,
-			   "%s: error: pEpping_ctx  = NULL", __func__);
+			   "%s: error: g_epping_ctx  = NULL", __func__);
 		return;
 	}
-	cds_free_context(NULL, CDF_MODULE_ID_EPPING,
-		cds_get_context(CDF_MODULE_ID_EPPING));
+
+	to_free = g_epping_ctx;
+	g_epping_ctx = NULL;
+	cdf_mem_free(to_free);
 }
 
 static void epping_target_suspend_acknowledge(void *context)
 {
-	epping_context_t *pEpping_ctx = cds_get_context(CDF_MODULE_ID_EPPING);
 	int wow_nack = *((int *)context);
 
-	if (NULL == pEpping_ctx) {
+	if (NULL == g_epping_ctx) {
 		EPPING_LOG(CDF_TRACE_LEVEL_FATAL,
 			   "%s: epping_ctx is NULL", __func__);
 		return;
 	}
 	/* EPPING_TODO: do we need wow_nack? */
-	pEpping_ctx->wow_nack = wow_nack;
+	g_epping_ctx->wow_nack = wow_nack;
 }
 
 /**
@@ -195,7 +193,7 @@
 		return ret;
 	}
 
-	pEpping_ctx = cds_get_context(CDF_MODULE_ID_EPPING);
+	pEpping_ctx = g_epping_ctx;
 	if (pEpping_ctx == NULL) {
 		EPPING_LOG(CDF_TRACE_LEVEL_FATAL,
 			   "%s: Failed to get pEpping_ctx", __func__);