qcacmn: Define qdf timer multiplier as a macro

The current QDF timer multiplier factor is of type
uint32 which takes whole number, so we cannot have multiplier
factors like 0.5 or 1.5

To provide such timer multiplier,
we define timer multiplier, as a macro, provided though
build options and support values like 0.5 or 1.5 through
1/2 and 3/2 respectively and this is used to configure the
timeout value.

Change-Id: I3f5441e33cca71f4a399cbbf9c6f61e2f21ee828
CRs-Fixed: 2450710
diff --git a/qdf/inc/qdf_timer.h b/qdf/inc/qdf_timer.h
index f7ac35e..0f82b1c 100644
--- a/qdf/inc/qdf_timer.h
+++ b/qdf/inc/qdf_timer.h
@@ -51,6 +51,14 @@
 	return __qdf_timer_init(timer, func, arg, type);
 }
 
+#ifdef QDF_TIMER_MULTIPLIER_FRAC
+#define qdf_msecs_to_jiffies(msec) \
+	(QDF_TIMER_MULTIPLIER_FRAC * __qdf_msecs_to_jiffies(msec))
+#else
+#define qdf_msecs_to_jiffies(msec) \
+	(qdf_timer_get_multiplier() * __qdf_msecs_to_jiffies(msec))
+#endif
+
 /**
  * qdf_timer_start() - start a timer
  * @timer: timer to start
diff --git a/qdf/linux/src/i_qdf_timer.h b/qdf/linux/src/i_qdf_timer.h
index 521e03d..2cbb6cb 100644
--- a/qdf/linux/src/i_qdf_timer.h
+++ b/qdf/linux/src/i_qdf_timer.h
@@ -36,8 +36,6 @@
 
 typedef void (*qdf_timer_func_t)(void *);
 
-#define qdf_msecs_to_jiffies(msec) \
-	(qdf_timer_get_multiplier() * msecs_to_jiffies(msec))
 
 struct __qdf_timer_t {
 	struct timer_list os_timer;
@@ -45,6 +43,8 @@
 	void *context;
 };
 
+#define __qdf_msecs_to_jiffies(msec) msecs_to_jiffies(msec)
+
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
 static inline void __os_timer_shim(struct timer_list *os_timer)
 {
@@ -121,13 +121,13 @@
 {
 	struct timer_list *os_timer = &timer->os_timer;
 
-	os_timer->expires = jiffies + qdf_msecs_to_jiffies(msec);
+	os_timer->expires = jiffies + __qdf_msecs_to_jiffies(msec);
 	add_timer(os_timer);
 }
 
 static inline void __qdf_timer_mod(struct __qdf_timer_t *timer, uint32_t msec)
 {
-	mod_timer(&timer->os_timer, jiffies + qdf_msecs_to_jiffies(msec));
+	mod_timer(&timer->os_timer, jiffies + __qdf_msecs_to_jiffies(msec));
 }
 
 static inline bool __qdf_timer_stop(struct __qdf_timer_t *timer)
diff --git a/qdf/linux/src/qdf_event.c b/qdf/linux/src/qdf_event.c
index ba7223a..929eff8 100644
--- a/qdf/linux/src/qdf_event.c
+++ b/qdf/linux/src/qdf_event.c
@@ -28,6 +28,7 @@
 /* Include Files */
 #include "qdf_event.h"
 #include "qdf_mc_timer.h"
+#include "qdf_timer.h"
 #include <qdf_module.h>
 
 struct qdf_evt_node {
@@ -211,10 +212,9 @@
 	if (timeout) {
 		long ret;
 
-		/* update the timeout if it's on an emulation platform */
-		timeout *= qdf_timer_get_multiplier();
-		ret = wait_for_completion_timeout(&event->complete,
-						  msecs_to_jiffies(timeout));
+		ret = wait_for_completion_timeout(
+				&event->complete,
+				qdf_msecs_to_jiffies(timeout));
 
 		if (ret <= 0)
 			return QDF_STATUS_E_TIMEOUT;
diff --git a/qdf/linux/src/qdf_mc_timer.c b/qdf/linux/src/qdf_mc_timer.c
index d0baa3a..c9ec3d7 100644
--- a/qdf/linux/src/qdf_mc_timer.c
+++ b/qdf/linux/src/qdf_mc_timer.c
@@ -29,6 +29,7 @@
 #include "qdf_list.h"
 #include "qdf_mem.h"
 #include <qdf_module.h>
+#include "qdf_timer.h"
 
 /* Preprocessor definitions and constants */
 #define LINUX_TIMER_COOKIE 0x12341234
@@ -662,9 +663,6 @@
 		return QDF_STATUS_E_INVAL;
 	}
 
-	/* update expiration time based on if emulation platform */
-	expiration_time *= qdf_timer_get_multiplier();
-
 	/* make sure the remainer of the logic isn't interrupted */
 	qdf_spin_lock_irqsave(&timer->platform_info.spinlock);
 
@@ -679,7 +677,7 @@
 
 	/* start the timer */
 	mod_timer(&(timer->platform_info.timer),
-		  jiffies + msecs_to_jiffies(expiration_time));
+		  jiffies + qdf_msecs_to_jiffies(expiration_time));
 
 	timer->state = QDF_TIMER_STATE_RUNNING;