Merge "prima: Update driver timer APIs according to kernel 4.19" into wlan-driver.lnx.1.0
diff --git a/CORE/HDD/src/wlan_hdd_early_suspend.c b/CORE/HDD/src/wlan_hdd_early_suspend.c
index 174f1ea..537e7ae 100644
--- a/CORE/HDD/src/wlan_hdd_early_suspend.c
+++ b/CORE/HDD/src/wlan_hdd_early_suspend.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2018, 2021 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -2146,17 +2146,20 @@
     vos_ssr_unprotect(__func__);
 }
 
-static void hdd_ssr_timer_init(void)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0))
+static void hdd_ssr_timer_cb(struct timer_list *data)
 {
-    init_timer(&ssr_timer);
+	hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HDD SSR timer expired", __func__);
+
+#ifdef WCN_PRONTO
+	if (wcnss_hardware_type() == WCNSS_PRONTO_HW)
+		wcnss_pronto_log_debug_regs();
+#endif
+
+	VOS_BUG(0);
 }
 
-static void hdd_ssr_timer_del(void)
-{
-    del_timer(&ssr_timer);
-    ssr_timer_started = false;
-}
-
+#else
 static void hdd_ssr_timer_cb(unsigned long data)
 {
     hddLog(VOS_TRACE_LEVEL_FATAL, "%s: HDD SSR timer expired", __func__);
@@ -2168,6 +2171,26 @@
 
     VOS_BUG(0);
 }
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0))
+static void hdd_ssr_timer_init(void)
+{
+	timer_setup(&ssr_timer, hdd_ssr_timer_cb, 0);
+}
+
+#else
+static void hdd_ssr_timer_init(void)
+{
+	init_timer(&ssr_timer);
+}
+#endif
+
+static void hdd_ssr_timer_del(void)
+{
+    del_timer(&ssr_timer);
+    ssr_timer_started = false;
+}
 
 static void hdd_ssr_timer_start(int msec)
 {
diff --git a/CORE/VOSS/src/vos_timer.c b/CORE/VOSS/src/vos_timer.c
index 8b6970d..324a5d2 100644
--- a/CORE/VOSS/src/vos_timer.c
+++ b/CORE/VOSS/src/vos_timer.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2013, 2015-2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2013, 2015-2021 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -110,9 +110,8 @@
 
   --------------------------------------------------------------------------*/
 
-static void vos_linux_timer_callback (unsigned long data)
+static void vos_linux_timer_callback(vos_timer_t *timer)
 {
-   vos_timer_t *timer = ( vos_timer_t *)data; 
    vos_msg_t msg;
    VOS_STATUS vStatus;
    unsigned long flags;
@@ -375,6 +374,47 @@
 }
 #endif
   
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0))
+static void vos_timer_shim(struct timer_list *vos_timer)
+{
+	vos_timer_platform_t *platformInfo_ptr = container_of(vos_timer,
+							vos_timer_platform_t,
+							Timer);
+
+	vos_timer_t *timer = container_of(platformInfo_ptr, vos_timer_t,
+						platformInfo);
+
+	vos_linux_timer_callback(timer);
+}
+
+static void vos_timer_setup(vos_timer_t *timer, bool deferrable)
+{
+	uint32_t flags = 0;
+
+	if (deferrable)
+		flags |= TIMER_DEFERRABLE;
+	timer_setup(&(timer->platformInfo.Timer), vos_timer_shim,
+		    flags);
+}
+#else
+static void vos_timer_shim(unsigned long data)
+{
+	vos_timer_t *timer = (vos_timer_t *)data;
+
+	vos_linux_timer_callback(timer);
+}
+
+static void vos_timer_setup(vos_timer_t *timer, bool deferrable)
+{
+	if (deferrable)
+		init_timer_deferrable(&timer->platformInfo.Timer);
+	else
+		init_timer(&timer->platformInfo.Timer);
+	timer->platformInfo.Timer.function = vos_timer_shim;
+	timer->platformInfo.Timer.data = (unsigned long)timer;
+}
+#endif
+
 /*--------------------------------------------------------------------------
   
   \brief vos_timer_init() - Initialize a vOSS timer.
@@ -484,12 +524,7 @@
     * with arguments passed or with default values
     */
    spin_lock_init(&timer->platformInfo.spinlock);
-   if(deferrable)
-     init_timer_deferrable(&(timer->platformInfo.Timer));
-   else
-     init_timer(&(timer->platformInfo.Timer));
-   timer->platformInfo.Timer.function = vos_linux_timer_callback;
-   timer->platformInfo.Timer.data = (unsigned long)timer;
+   vos_timer_setup(timer, deferrable);
    timer->callback = callback;
    timer->userData = userData;
    timer->type = timerType;
@@ -541,12 +576,7 @@
     * with arguments passed or with default values
     */
    spin_lock_init(&timer->platformInfo.spinlock);
-   if(deferrable)
-     init_timer_deferrable(&(timer->platformInfo.Timer));
-   else
-     init_timer(&(timer->platformInfo.Timer));
-   timer->platformInfo.Timer.function = vos_linux_timer_callback;
-   timer->platformInfo.Timer.data = (unsigned long)timer;
+   vos_timer_setup(timer, deferrable);
    timer->callback = callback;
    timer->userData = userData;
    timer->type = timerType;