Parcourir la source

msm: camera: common: Add common function to modify timer

Add common function to modify system timer, with timeout
multiplier as a debug capability.

CRs-Fixed: 2932495
Change-Id: I73282aa30b938b7efce97a2e8fd757b04096ccad
Signed-off-by: Mukund Madhusudan Atre <[email protected]>
Mukund Madhusudan Atre il y a 4 ans
Parent
commit
c31cb00512

+ 5 - 5
drivers/cam_req_mgr/cam_req_mgr_timer.c

@@ -1,10 +1,11 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
- * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2019, 2021, The Linux Foundation. All rights reserved.
  */
 
 #include "cam_req_mgr_timer.h"
 #include "cam_debug_util.h"
+#include "cam_common_util.h"
 
 extern struct kmem_cache *g_cam_req_mgr_timer_cachep;
 
@@ -12,10 +13,9 @@ void crm_timer_reset(struct cam_req_mgr_timer *crm_timer)
 {
 	if (!crm_timer)
 		return;
-	CAM_DBG(CAM_CRM, "Starting timer to fire in %d ms. (jiffies=%lu)\n",
-		crm_timer->expires, jiffies);
-	mod_timer(&crm_timer->sys_timer,
-		(jiffies + msecs_to_jiffies(crm_timer->expires)));
+
+	cam_common_modify_timer(&crm_timer->sys_timer, crm_timer->expires);
+
 }
 
 void crm_timer_callback(struct timer_list *timer_data)

+ 19 - 0
drivers/cam_utils/cam_common_util.c

@@ -6,6 +6,7 @@
 #include <linux/string.h>
 #include <linux/types.h>
 #include <linux/slab.h>
+#include <linux/timer.h>
 #include <linux/completion.h>
 #include <linux/module.h>
 #include <linux/iopoll.h>
@@ -103,3 +104,21 @@ int cam_common_read_poll_timeout(
 
 	return rc;
 }
+
+int cam_common_modify_timer(struct timer_list *timer, int32_t timeout_val)
+{
+	if (!timer) {
+		CAM_ERR(CAM_UTIL, "Invalid reference to system timer");
+		return -EINVAL;
+	}
+
+	if (timeout_multiplier < 1)
+		timeout_multiplier = 1;
+
+	CAM_DBG(CAM_UTIL, "Starting timer to fire in %d ms. (jiffies=%lu)\n",
+		(timeout_val * timeout_multiplier), jiffies);
+	mod_timer(timer,
+		(jiffies + msecs_to_jiffies(timeout_val * timeout_multiplier)));
+
+	return 0;
+}

+ 13 - 0
drivers/cam_utils/cam_common_util.h

@@ -103,4 +103,17 @@ int cam_common_read_poll_timeout(
 	uint32_t             mask,
 	uint32_t             check_val,
 	uint32_t            *status);
+
+/**
+ * cam_common_modify_timer()
+ *
+ * @brief                  common interface to modify timer,
+ *
+ * @timer:                 reference to system timer
+ * @timeout_val:           timeout value for timer
+ *
+ * @return:                0 if success and negative if fail
+ */
+int cam_common_modify_timer(struct timer_list *timer, int32_t timeout_val);
+
 #endif /* _CAM_COMMON_UTIL_H_ */