qcacmn: Remove cds_get_context in HIF

Refactor Transport Layer from cds_get_context and pass the hif context
to all the API's to operate.

Change-Id: I1dedda76357f844e08fd422bf9eb15af70587eae
CRs-Fixed: 967765
diff --git a/hif/inc/hif.h b/hif/inc/hif.h
index 671bdd2..3b0496e 100644
--- a/hif/inc/hif.h
+++ b/hif/inc/hif.h
@@ -576,9 +576,9 @@
 int hif_check_soc_status(struct ol_softc *scn);
 void hif_disable_isr(void *scn);
 void hif_reset_soc(void *scn);
-void hif_disable_aspm(void);
-void hif_save_htc_htt_config_endpoint(int htc_endpoint);
-CDF_STATUS hif_open(enum ath_hal_bus_type bus_type);
+void hif_disable_aspm(void *);
+void hif_save_htc_htt_config_endpoint(void *hif_ctx, int htc_endpoint);
+CDF_STATUS hif_open(cdf_device_t cdf_ctx, enum ath_hal_bus_type bus_type);
 void hif_close(void *hif_ctx);
 CDF_STATUS hif_enable(void *hif_ctx, struct device *dev, void *bdev,
 	const hif_bus_id *bid, enum ath_hal_bus_type bus_type,
@@ -592,7 +592,7 @@
 void hif_pm_runtime_get_noresume(void *hif_ctx);
 int hif_pm_runtime_put(void *hif_ctx);
 struct hif_pm_runtime_lock *hif_runtime_lock_init(const char *name);
-void hif_runtime_lock_deinit(struct hif_pm_runtime_lock *lock);
+void hif_runtime_lock_deinit(void *hif_ctx, struct hif_pm_runtime_lock *lock);
 int hif_pm_runtime_prevent_suspend(void *ol_sc,
 		struct hif_pm_runtime_lock *lock);
 int hif_pm_runtime_allow_suspend(void *ol_sc,
@@ -614,8 +614,8 @@
 static inline struct hif_pm_runtime_lock *hif_runtime_lock_init(
 		const char *name)
 { return NULL; }
-static inline void hif_runtime_lock_deinit(struct hif_pm_runtime_lock *lock)
-{}
+static inline void
+hif_runtime_lock_deinit(void *hif_ctx, struct hif_pm_runtime_lock *lock) {}
 
 static inline int hif_pm_runtime_prevent_suspend(void *ol_sc,
 		struct hif_pm_runtime_lock *lock)
@@ -631,21 +631,21 @@
 void hif_enable_power_management(void *hif_ctx);
 void hif_disable_power_management(void *hif_ctx);
 
-void hif_vote_link_down(void);
-void hif_vote_link_up(void);
-bool hif_can_suspend_link(void);
+void hif_vote_link_down(void *);
+void hif_vote_link_up(void *);
+bool hif_can_suspend_link(void *);
 
-int hif_bus_resume(void);
-int hif_bus_suspend(void);
+int hif_bus_resume(void *);
+int hif_bus_suspend(void *);
 
 #ifdef FEATURE_RUNTIME_PM
-int hif_pre_runtime_suspend(void);
-void hif_pre_runtime_resume(void);
-int hif_runtime_suspend(void);
-int hif_runtime_resume(void);
-void hif_process_runtime_suspend_success(void);
-void hif_process_runtime_suspend_failure(void);
-void hif_process_runtime_resume_success(void);
+int hif_pre_runtime_suspend(void *hif_ctx);
+void hif_pre_runtime_resume(void *hif_ctx);
+int hif_runtime_suspend(void *hif_ctx);
+int hif_runtime_resume(void *hif_ctx);
+void hif_process_runtime_suspend_success(void *);
+void hif_process_runtime_suspend_failure(void *);
+void hif_process_runtime_resume_success(void *);
 #endif
 
 int hif_dump_registers(struct ol_softc *scn);
diff --git a/hif/inc/hif_napi.h b/hif/inc/hif_napi.h
index c6f817f..66bbd35 100644
--- a/hif/inc/hif_napi.h
+++ b/hif/inc/hif_napi.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2015-2016 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -94,7 +94,7 @@
 int hif_napi_schedule(struct ol_softc *scn, int ce_id);
 
 /* called by hdd_napi, which is called by kernel */
-int hif_napi_poll(struct napi_struct *napi, int budget);
+int hif_napi_poll(void *hif_ctx, struct napi_struct *napi, int budget);
 
 #ifdef FEATURE_NAPI_DEBUG
 #define NAPI_DEBUG(fmt, ...)			\
diff --git a/hif/src/ce/ce_main.c b/hif/src/ce/ce_main.c
index 7316b5c..54ef56e 100644
--- a/hif/src/ce/ce_main.c
+++ b/hif/src/ce/ce_main.c
@@ -1848,7 +1848,7 @@
 	scn->notice_send = true;
 
 	cdf_mem_zero(&soc_info, sizeof(soc_info));
-	ret = icnss_get_soc_info(&soc_info);
+	ret = icnss_get_soc_info(scn, &soc_info);
 	if (ret < 0) {
 		HIF_ERROR("%s: icnss_get_soc_info error = %d", __func__, ret);
 		return CDF_STATUS_NOT_INITIALIZED;
@@ -1957,7 +1957,7 @@
 	if (rv != CDF_STATUS_SUCCESS)
 		goto err;
 	else
-		init_tasklet_workers();
+		init_tasklet_workers(scn);
 
 	HIF_TRACE("%s: X, ret = %d\n", __func__, rv);
 
diff --git a/hif/src/ce/ce_tasklet.c b/hif/src/ce/ce_tasklet.c
index a2edeba..a68dcec 100644
--- a/hif/src/ce/ce_tasklet.c
+++ b/hif/src/ce/ce_tasklet.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2015-2016 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -72,14 +72,29 @@
 }
 
 /**
+ * struct tasklet_work
+ *
+ * @id: ce_id
+ * @work: work
+ */
+struct tasklet_work {
+	enum ce_id_type id;
+	void *data;
+	struct work_struct work;
+};
+
+
+/**
  * reschedule_ce_tasklet_work_handler() - reschedule work
- * @ce_id: ce_id
+ * @work: struct work_struct
  *
  * Return: N/A
  */
-static void reschedule_ce_tasklet_work_handler(int ce_id)
+static void reschedule_ce_tasklet_work_handler(struct work_struct *work)
 {
-	struct ol_softc *scn = cds_get_context(CDF_MODULE_ID_HIF);
+	struct tasklet_work *ce_work = container_of(work, struct tasklet_work,
+						    work);
+	struct ol_softc *scn = ce_work->data;
 	struct HIF_CE_state *hif_ce_state;
 
 	if (NULL == scn) {
@@ -92,39 +107,14 @@
 		HIF_ERROR("%s: wlan driver is unloaded", __func__);
 		return;
 	}
-	tasklet_schedule(&hif_ce_state->tasklets[ce_id].intr_tq);
+	tasklet_schedule(&hif_ce_state->tasklets[ce_work->id].intr_tq);
 	return;
 }
 
-/**
- * struct tasklet_work
- *
- * @id: ce_id
- * @work: work
- */
-struct tasklet_work {
-	enum ce_id_type id;
-	struct work_struct work;
-};
-
 static struct tasklet_work tasklet_workers[CE_ID_MAX];
 static bool work_initialized;
 
 /**
- * work_handler() - work_handler
- * @work: struct work_struct
- *
- * Return: N/A
- */
-static void work_handler(struct work_struct *work)
-{
-	struct tasklet_work *tmp;
-
-	tmp = container_of(work, struct tasklet_work, work);
-	reschedule_ce_tasklet_work_handler(tmp->id);
-}
-
-/**
  * init_tasklet_work() - init_tasklet_work
  * @work: struct work_struct
  * @work_handler: work_handler
@@ -133,13 +123,13 @@
  */
 #ifdef CONFIG_CNSS
 static void init_tasklet_work(struct work_struct *work,
-	work_func_t work_handler)
+			      work_func_t work_handler)
 {
 	cnss_init_work(work, work_handler);
 }
 #else
 static void init_tasklet_work(struct work_struct *work,
-	work_func_t work_handler)
+			      work_func_t work_handler)
 {
 	INIT_WORK(work, work_handler);
 }
@@ -147,16 +137,19 @@
 
 /**
  * init_tasklet_workers() - init_tasklet_workers
+ * @scn: HIF Context
  *
  * Return: N/A
  */
-void init_tasklet_workers(void)
+void init_tasklet_workers(struct ol_softc *scn)
 {
 	uint32_t id;
 
 	for (id = 0; id < CE_ID_MAX; id++) {
 		tasklet_workers[id].id = id;
-		init_tasklet_work(&tasklet_workers[id].work, work_handler);
+		tasklet_workers[id].data = scn;
+		init_tasklet_work(&tasklet_workers[id].work,
+				  reschedule_ce_tasklet_work_handler);
 	}
 	work_initialized = true;
 }
diff --git a/hif/src/ce/ce_tasklet.h b/hif/src/ce/ce_tasklet.h
index bcfd75c..4b5f558 100644
--- a/hif/src/ce/ce_tasklet.h
+++ b/hif/src/ce/ce_tasklet.h
@@ -28,7 +28,7 @@
 #ifndef __CE_TASKLET_H__
 #define __CE_TASKLET_H__
 #include "ce_main.h"
-void init_tasklet_workers(void);
+void init_tasklet_workers(struct ol_softc *scn);
 void ce_tasklet_init(struct HIF_CE_state *hif_ce_state, uint32_t mask);
 void ce_tasklet_kill(struct HIF_CE_state *hif_ce_state);
 CDF_STATUS ce_register_irq(struct HIF_CE_state *hif_ce_state, uint32_t mask);
diff --git a/hif/src/hif_main.c b/hif/src/hif_main.c
index 61c57ab..4c8fc53 100644
--- a/hif/src/hif_main.c
+++ b/hif/src/hif_main.c
@@ -281,9 +281,9 @@
  *
  * Return: n/a
  */
-void hif_vote_link_down(void)
+void hif_vote_link_down(void *hif_ctx)
 {
-	struct ol_softc *scn = cds_get_context(CDF_MODULE_ID_HIF);
+	struct ol_softc *scn = hif_ctx;
 	CDF_BUG(scn);
 
 	scn->linkstate_vote--;
@@ -302,9 +302,9 @@
  *
  * Return: n/a
  */
-void hif_vote_link_up(void)
+void hif_vote_link_up(void *hif_ctx)
 {
-	struct ol_softc *scn = cds_get_context(CDF_MODULE_ID_HIF);
+	struct ol_softc *scn = hif_ctx;
 	CDF_BUG(scn);
 
 	scn->linkstate_vote++;
@@ -324,9 +324,9 @@
  *
  * Return: false if hif will guarantee link up durring suspend.
  */
-bool hif_can_suspend_link(void)
+bool hif_can_suspend_link(void *hif_ctx)
 {
-	struct ol_softc *scn = cds_get_context(CDF_MODULE_ID_HIF);
+	struct ol_softc *scn = hif_ctx;
 	CDF_BUG(scn);
 
 	return scn->linkstate_vote == 0;
@@ -405,19 +405,12 @@
  */
 int hif_init_cdf_ctx(void *hif_ctx)
 {
-	cdf_device_t cdf_ctx;
 	struct ol_softc *scn = (struct ol_softc *)hif_ctx;
-
-	cdf_ctx = cds_get_context(CDF_MODULE_ID_CDF_DEVICE);
-	if (!cdf_ctx) {
-		HIF_ERROR("%s: CDF is NULL", __func__);
-		return -ENOMEM;
-	}
+	cdf_device_t cdf_ctx = scn->cdf_dev;
 
 	cdf_ctx->drv = &scn->aps_osdev;
 	cdf_ctx->drv_hdl = scn->aps_osdev.bdev;
 	cdf_ctx->dev = scn->aps_osdev.device;
-	scn->cdf_dev = cdf_ctx;
 	return 0;
 }
 
@@ -443,9 +436,9 @@
  *
  * Return: void
  */
-void hif_save_htc_htt_config_endpoint(int htc_endpoint)
+void hif_save_htc_htt_config_endpoint(void *hif_ctx, int htc_endpoint)
 {
-	struct ol_softc *scn = cds_get_context(CDF_MODULE_ID_HIF);
+	struct ol_softc *scn = hif_ctx;
 
 	if (!scn) {
 		HIF_ERROR("%s: error: scn or scn->hif_sc is NULL!",
@@ -498,7 +491,7 @@
  *
  * Return: scn
  */
-CDF_STATUS hif_open(enum ath_hal_bus_type bus_type)
+CDF_STATUS hif_open(cdf_device_t cdf_ctx, enum ath_hal_bus_type bus_type)
 {
 	struct ol_softc *scn;
 	v_CONTEXT_t cds_context;
@@ -514,6 +507,7 @@
 	}
 
 	cdf_mem_zero(scn, sizeof(*scn));
+	scn->cdf_dev = cdf_ctx;
 	cfg = hif_get_ini_handle(scn);
 	cfg->max_no_of_peers = 1;
 	cdf_atomic_init(&scn->wow_done);
@@ -594,7 +588,7 @@
 	}
 
 	if (ADRASTEA_BU)
-		hif_vote_link_up();
+		hif_vote_link_up(hif_ctx);
 
 	if (hif_config_ce(scn)) {
 		HIF_ERROR("%s: Target probe failed.", __func__);
@@ -663,7 +657,7 @@
 		hif_stop(scn);
 
 	if (ADRASTEA_BU)
-		hif_vote_link_down();
+		hif_vote_link_down(hif_ctx);
 
 	if (scn->aps_osdev.bdev)
 		hif_disable_bus(scn->aps_osdev.bdev);
diff --git a/hif/src/hif_napi.c b/hif/src/hif_napi.c
index 2ef3dfd..a7925e8 100644
--- a/hif/src/hif_napi.c
+++ b/hif/src/hif_napi.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2015-2016 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -398,7 +398,7 @@
  * Returns:
  *  int: the amount of work done in this poll ( <= budget)
  */
-int hif_napi_poll(struct napi_struct *napi, int budget)
+int hif_napi_poll(void *hif_ctx, struct napi_struct *napi, int budget)
 {
 	int    rc = 0; /* default: no work done, also takes care of error */
 	int    normalized, bucket;
@@ -413,7 +413,7 @@
 		container_of(napi, struct qca_napi_info, napi);
 	napi_info->stats[cpu].napi_polls++;
 
-	hif = (struct ol_softc *)cds_get_context(CDF_MODULE_ID_HIF);
+	hif = hif_ctx;
 	if (unlikely(NULL == hif))
 		CDF_ASSERT(hif != NULL); /* emit a warning if hif NULL */
 	else {
diff --git a/hif/src/icnss_stub/icnss_stub.c b/hif/src/icnss_stub/icnss_stub.c
index aa958ec..ee75746 100644
--- a/hif/src/icnss_stub/icnss_stub.c
+++ b/hif/src/icnss_stub/icnss_stub.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2015-2016 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -331,14 +331,15 @@
  *
  * Return: 0 for success
  */
-int icnss_get_soc_info(struct icnss_soc_info *info)
+int icnss_get_soc_info(void *hif_ctx, struct icnss_soc_info *info)
 {
-	struct ol_softc *scn = cds_get_context(CDF_MODULE_ID_HIF);
+	struct ol_softc *scn = hif_ctx;
 
 	if (!scn) {
 		HIF_ERROR("%s: SCN = NULL", __func__);
 		return -EINVAL;
 	}
+
 	info->v_addr = scn->mem;
 	info->p_addr = scn->mem_pa;
 	info->version = 0;
diff --git a/hif/src/icnss_stub/icnss_stub.h b/hif/src/icnss_stub/icnss_stub.h
index 33a83ac..69d886f 100644
--- a/hif/src/icnss_stub/icnss_stub.h
+++ b/hif/src/icnss_stub/icnss_stub.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2015-2016 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -128,7 +128,7 @@
 int icnss_ce_free_irq(int irq, void *context);
 void icnss_enable_irq(unsigned int ce_id);
 void icnss_disable_irq(unsigned int ce_id);
-int icnss_get_soc_info(struct icnss_soc_info *info);
+int icnss_get_soc_info(void *hif_ctx, struct icnss_soc_info *info);
 int icnss_get_ce_id(int irq);
 #endif /* _ICNSS_WLAN_H_ */
 #endif /* HIF_PCI */
diff --git a/hif/src/pcie/if_pci.c b/hif/src/pcie/if_pci.c
index cdf25b5..2241313 100644
--- a/hif/src/pcie/if_pci.c
+++ b/hif/src/pcie/if_pci.c
@@ -1765,9 +1765,8 @@
  *
  * Return: 0 for success and non-zero for failure
  */
-static int hif_bus_suspend_link_up(void)
+static int hif_bus_suspend_link_up(struct ol_softc *scn)
 {
-	struct ol_softc *scn = cds_get_context(CDF_MODULE_ID_HIF);
 	struct pci_dev *pdev;
 	int status;
 
@@ -1795,9 +1794,8 @@
  *
  * Return: 0 for success and non-zero for failure
  */
-static int hif_bus_resume_link_up(void)
+static int hif_bus_resume_link_up(struct ol_softc *scn)
 {
-	struct ol_softc *scn = cds_get_context(CDF_MODULE_ID_HIF);
 	struct pci_dev *pdev;
 
 	if (!scn)
@@ -1827,9 +1825,8 @@
  *
  * Return: 0 for success and non-zero for failure
  */
-static int hif_bus_suspend_link_down(void)
+static int hif_bus_suspend_link_down(struct ol_softc *scn)
 {
-	struct ol_softc *scn = cds_get_context(CDF_MODULE_ID_HIF);
 	struct pci_dev *pdev;
 	struct HIF_CE_state *hif_state;
 	int status = 0;
@@ -1868,9 +1865,8 @@
  *
  * Return: 0 for success and non-zero for failure
  */
-static int hif_bus_resume_link_down(void)
+static int hif_bus_resume_link_down(struct ol_softc *scn)
 {
-	struct ol_softc *scn = cds_get_context(CDF_MODULE_ID_HIF);
 	struct pci_dev *pdev;
 
 	if (!scn)
@@ -1896,12 +1892,13 @@
  *
  * Return: 0 for success and non-zero error code for failure
  */
-int hif_bus_suspend(void)
+int hif_bus_suspend(void *hif_ctx)
 {
-	if (hif_can_suspend_link())
-		return hif_bus_suspend_link_down();
+	struct ol_softc *scn = hif_ctx;
+	if (hif_can_suspend_link(scn))
+		return hif_bus_suspend_link_down(scn);
 	else
-		return hif_bus_suspend_link_up();
+		return hif_bus_suspend_link_up(scn);
 }
 
 /**
@@ -1911,12 +1908,13 @@
  *
  * Return: 0 for success and non-zero error code for failure
  */
-int hif_bus_resume(void)
+int hif_bus_resume(void *hif_ctx)
 {
-	if (hif_can_suspend_link())
-		return hif_bus_resume_link_down();
+	struct ol_softc *scn = hif_ctx;
+	if (hif_can_suspend_link(scn))
+		return hif_bus_resume_link_down(scn);
 	else
-		return hif_bus_resume_link_up();
+		return hif_bus_resume_link_up(scn);
 }
 
 #ifdef FEATURE_RUNTIME_PM
@@ -1926,9 +1924,9 @@
  *
  * indexes into the runtime pm state and sets it.
  */
-static void __hif_runtime_pm_set_state(enum hif_pm_runtime_state state)
+static void __hif_runtime_pm_set_state(struct ol_softc *scn,
+				enum hif_pm_runtime_state state)
 {
-	struct ol_softc *scn = cds_get_context(CDF_MODULE_ID_HIF);
 	struct hif_pci_softc *sc;
 
 	if (NULL == scn) {
@@ -1941,17 +1939,15 @@
 	cdf_atomic_set(&sc->pm_state, state);
 
 }
-#endif
 
-#ifdef FEATURE_RUNTIME_PM
 /**
  * hif_runtime_pm_set_state_inprogress(): adjust runtime pm state
  *
  * Notify hif that a runtime pm opperation has started
  */
-static void hif_runtime_pm_set_state_inprogress(void)
+static void hif_runtime_pm_set_state_inprogress(struct ol_softc *scn)
 {
-	__hif_runtime_pm_set_state(HIF_PM_RUNTIME_STATE_INPROGRESS);
+	__hif_runtime_pm_set_state(scn, HIF_PM_RUNTIME_STATE_INPROGRESS);
 }
 
 /**
@@ -1959,9 +1955,9 @@
  *
  * Notify hif that a the runtime pm state should be on
  */
-static void hif_runtime_pm_set_state_on(void)
+static void hif_runtime_pm_set_state_on(struct ol_softc *scn)
 {
-	__hif_runtime_pm_set_state(HIF_PM_RUNTIME_STATE_ON);
+	__hif_runtime_pm_set_state(scn, HIF_PM_RUNTIME_STATE_ON);
 }
 
 /**
@@ -1969,14 +1965,14 @@
  *
  * Notify hif that a runtime suspend attempt has been completed successfully
  */
-static void hif_runtime_pm_set_state_suspended(void)
+static void hif_runtime_pm_set_state_suspended(struct ol_softc *scn)
 {
-	__hif_runtime_pm_set_state(HIF_PM_RUNTIME_STATE_SUSPENDED);
+	__hif_runtime_pm_set_state(scn, HIF_PM_RUNTIME_STATE_SUSPENDED);
 }
 
-static inline struct hif_pci_softc *get_sc(void)
+static inline struct hif_pci_softc *get_sc(void *hif_ctx)
 {
-	struct ol_softc *scn = cds_get_context(CDF_MODULE_ID_HIF);
+	struct ol_softc *scn = hif_ctx;
 
 	if (NULL == scn) {
 		HIF_ERROR("%s: Could not disable ASPM scn is null",
@@ -1990,9 +1986,9 @@
 /**
  * hif_log_runtime_suspend_success() - log a successful runtime suspend
  */
-static void hif_log_runtime_suspend_success(void)
+static void hif_log_runtime_suspend_success(void *hif_ctx)
 {
-	struct hif_pci_softc *sc = get_sc();
+	struct hif_pci_softc *sc = get_sc(hif_ctx);
 	if (sc == NULL)
 		return;
 
@@ -2006,9 +2002,9 @@
  * log a failed runtime suspend
  * mark last busy to prevent immediate runtime suspend
  */
-static void hif_log_runtime_suspend_failure(void)
+static void hif_log_runtime_suspend_failure(void *hif_ctx)
 {
-	struct hif_pci_softc *sc = get_sc();
+	struct hif_pci_softc *sc = get_sc(hif_ctx);
 	if (sc == NULL)
 		return;
 
@@ -2021,9 +2017,9 @@
  * log a successfull runtime resume
  * mark last busy to prevent immediate runtime suspend
  */
-static void hif_log_runtime_resume_success(void)
+static void hif_log_runtime_resume_success(void *hif_ctx)
 {
-	struct hif_pci_softc *sc = get_sc();
+	struct hif_pci_softc *sc = get_sc(hif_ctx);
 	if (sc == NULL)
 		return;
 
@@ -2037,9 +2033,9 @@
  * mark last busy to delay a retry.
  * adjust the runtime_pm state.
  */
-void hif_process_runtime_suspend_failure(void)
+void hif_process_runtime_suspend_failure(void *hif_ctx)
 {
-	struct hif_pci_softc *sc = get_sc();
+	struct hif_pci_softc *sc = get_sc(hif_ctx);
 
 	hif_log_runtime_suspend_failure();
 	if (sc != NULL)
@@ -2058,14 +2054,14 @@
  *
  * return -EINVAL if the bus won't go down.  otherwise return 0
  */
-int hif_pre_runtime_suspend(void)
+int hif_pre_runtime_suspend(void *hif_ctx)
 {
-	if (!hif_can_suspend_link()) {
+	if (!hif_can_suspend_link(hif_ctx)) {
 		HIF_ERROR("Runtime PM not supported for link up suspend");
 		return -EINVAL;
 	}
 
-	hif_runtime_pm_set_state_inprogress();
+	hif_runtime_pm_set_state_inprogress(hif_ctx);
 	return 0;
 }
 
@@ -2075,10 +2071,10 @@
  * Record the success.
  * adjust the runtime_pm state
  */
-void hif_process_runtime_suspend_success(void)
+void hif_process_runtime_suspend_success(void *hif_ctx)
 {
-	hif_runtime_pm_set_state_suspended();
-	hif_log_runtime_suspend_success();
+	hif_runtime_pm_set_state_suspended(hif_ctx);
+	hif_log_runtime_suspend_success(hif_ctx);
 }
 
 /**
@@ -2086,9 +2082,9 @@
  *
  * update the runtime pm state.
  */
-void hif_pre_runtime_resume(void)
+void hif_pre_runtime_resume(void *hif_ctx)
 {
-	hif_runtime_pm_set_state_inprogress();
+	hif_runtime_pm_set_state_inprogress(hif_ctx);
 }
 
 /**
@@ -2097,9 +2093,9 @@
  * record the success.
  * adjust the runtime_pm state
  */
-void hif_process_runtime_resume_success(void)
+void hif_process_runtime_resume_success(void *hif_ctx)
 {
-	struct hif_pci_softc *sc = get_sc();
+	struct hif_pci_softc *sc = get_sc(hif_ctx);
 
 	hif_log_runtime_resume_success();
 	if (sc != NULL)
@@ -2113,9 +2109,9 @@
  *
  * Return: 0 for success and non-zero error code for failure
  */
-int hif_runtime_suspend(void)
+int hif_runtime_suspend(void *hif_ctx)
 {
-	return hif_bus_suspend();
+	return hif_bus_suspend(hif_ctx);
 }
 
 #ifdef WLAN_FEATURE_FASTPATH
@@ -2126,10 +2122,9 @@
  * since runtime pm may cause ce_send_fast to skip the register
  * write.
  */
-static void hif_fastpath_resume(void)
+static void hif_fastpath_resume(void *hif_ctx)
 {
-	struct ol_softc *scn =
-		(struct ol_softc *)cds_get_context(CDF_MODULE_ID_HIF);
+	struct ol_softc *scn = hif_ctx;
 	struct CE_state *ce_state;
 
 	if (!scn)
@@ -2149,7 +2144,7 @@
 	}
 }
 #else
-static void hif_fastpath_resume(void) {}
+static void hif_fastpath_resume(void *hif_ctx) {}
 #endif
 
 
@@ -2158,11 +2153,11 @@
  *
  *  Return: 0 for success and non-zero error code for failure
  */
-int hif_runtime_resume(void)
+int hif_runtime_resume(void *hif_ctx)
 {
-	int status = hif_bus_resume();
+	int status = hif_bus_resume(hif_ctx);
 
-	hif_fastpath_resume();
+	hif_fastpath_resume(hif_ctx);
 
 	return status;
 }
@@ -2219,9 +2214,9 @@
 #endif
 }
 
-void hif_disable_aspm(void)
+void hif_disable_aspm(void *hif_ctx)
 {
-	struct ol_softc *scn = cds_get_context(CDF_MODULE_ID_HIF);
+	struct ol_softc *scn = hif_ctx;
 	struct hif_pci_softc *sc;
 
 	if (NULL == scn) {
@@ -2730,7 +2725,6 @@
 	HIF_TRACE("%s: con_mode = 0x%x, device_id = 0x%x",
 		  __func__, cds_get_conparam(), id->device);
 
-	ol_sc = cds_get_context(CDF_MODULE_ID_HIF);
 	if (!ol_sc) {
 		HIF_ERROR("%s: hif_ctx is NULL", __func__);
 		return CDF_STATUS_E_NOMEM;
@@ -3299,11 +3293,11 @@
  *
  * Return: void
  */
-void hif_runtime_lock_deinit(struct hif_pm_runtime_lock *data)
+void hif_runtime_lock_deinit(void *hif_ctx, struct hif_pm_runtime_lock *data)
 {
 	unsigned long flags;
 	struct hif_pm_runtime_lock *context = data;
-	struct ol_softc *scn = cds_get_context(CDF_MODULE_ID_HIF);
+	struct ol_softc *scn = hif_ctx;
 	struct hif_pci_softc *sc;
 
 	if (!scn)
diff --git a/hif/src/snoc/if_snoc.c b/hif/src/snoc/if_snoc.c
index 3b8fc2c..6d46dfa 100644
--- a/hif/src/snoc/if_snoc.c
+++ b/hif/src/snoc/if_snoc.c
@@ -142,7 +142,7 @@
  *
  * Return: 0 for success and non-zero for failure
  */
-int hif_bus_suspend(void)
+int hif_bus_suspend(void *hif_ctx)
 {
 	return 0;
 }
@@ -155,7 +155,7 @@
  *
  * Return: 0 for success and non-zero for failure
  */
-int hif_bus_resume(void)
+int hif_bus_resume(void *hif_ctx)
 {
 	return 0;
 }
@@ -174,7 +174,7 @@
  *
  * Return: n/a
  */
-void hif_disable_aspm(void)
+void hif_disable_aspm(void *hif_ctx)
 {
 }