Ver código fonte

msm: camera: utils: Add priority to debug logs

Priority of debug logs allows for better control of which debug logs are
printed. Debug logs default to lowest priority.

CRs-Fixed: 2899680
Change-Id: I59de2d60aac80052b8c7219f866e242d9b475b4d
Signed-off-by: Anand Ravi <[email protected]>
Anand Ravi 4 anos atrás
pai
commit
d7e5ba94ce

+ 9 - 5
drivers/cam_utils/cam_debug_util.c

@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
- * Copyright (c) 2017-2020, The Linux Foundataion. All rights reserved.
+ * Copyright (c) 2017-2021, The Linux Foundataion. All rights reserved.
  */
 
 #include <linux/io.h>
@@ -17,6 +17,9 @@ module_param(debug_mdl, uint, 0644);
 static uint debug_type;
 module_param(debug_type, uint, 0644);
 
+static uint debug_priority;
+module_param(debug_priority, uint, 0644);
+
 struct camera_debug_settings cam_debug;
 
 const struct camera_debug_settings *cam_debug_get_settings()
@@ -254,15 +257,16 @@ const char *cam_get_tag_name(unsigned int tag_id)
 	return name;
 }
 
-void cam_debug_log(unsigned int module_id, const char *func, const int line,
-	const char *fmt, ...)
+void cam_debug_log(unsigned int module_id, unsigned int priority,
+	const char *func, const int line, const char *fmt, ...)
 {
-	char str_buffer[STR_BUFFER_MAX_LENGTH];
 	va_list args;
 
 	va_start(args, fmt);
 
-	if (debug_mdl & module_id) {
+	if ((debug_mdl & module_id) && (priority >= debug_priority)) {
+		char str_buffer[STR_BUFFER_MAX_LENGTH];
+
 		vsnprintf(str_buffer, STR_BUFFER_MAX_LENGTH, fmt, args);
 
 		if ((debug_type == 0) || (debug_type == 2)) {

+ 24 - 6
drivers/cam_utils/cam_debug_util.h

@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
- * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
  */
 
 #ifndef _CAM_DEBUG_UTIL_H_
@@ -50,6 +50,15 @@
 
 #define STR_BUFFER_MAX_LENGTH  512
 
+/*
+ * enum cam_debug_priority - Priority of debug log (0 = Lowest)
+ */
+enum cam_debug_priority {
+	CAM_DBG_PRIORITY_0,
+	CAM_DBG_PRIORITY_1,
+	CAM_DBG_PRIORITY_2,
+};
+
 /**
  * struct cam_cpas_debug_settings - Sysfs debug settings for cpas driver
  */
@@ -83,14 +92,15 @@ struct camera_debug_settings {
  *               respective debug logs
  *
  * @module_id :  Respective Module ID which is calling this function
+ * @priority  :  Priority of the debug log
  * @func      :  Function which is calling to print logs
  * @line      :  Line number associated with the function which is calling
  *               to print log
  * @fmt       :  Formatted string which needs to be print in the log
  *
  */
-void cam_debug_log(unsigned int module_id, const char *func, const int line,
-	const char *fmt, ...);
+void cam_debug_log(unsigned int module_id, unsigned int priority,
+	const char *func, const int line, const char *fmt, ...);
 
 /*
  *  cam_debug_trace()
@@ -202,14 +212,22 @@ const char *cam_get_module_name(unsigned int module_id);
 
 /*
  * CAM_DBG
- * @brief    :  This Macro will print debug logs when enabled using GROUP
+ * @brief    :  This Macro will print debug logs when enabled using GROUP and
+ *              if its priority is greater than the priority parameter
  *
  * @__module :  Respective module id which is been calling this Macro
  * @fmt      :  Formatted string which needs to be print in log
  * @args     :  Arguments which needs to be print in log
  */
-#define CAM_DBG(__module, fmt, args...)                            \
-	cam_debug_log(__module, __func__, __LINE__, fmt, ##args)
+#define CAM_DBG(__module, fmt, args...)                                        \
+	cam_debug_log(__module, CAM_DBG_PRIORITY_0, __func__, __LINE__,        \
+			fmt, ##args)
+#define CAM_DBG_PR1(__module, fmt, args...)                                    \
+	cam_debug_log(__module, CAM_DBG_PRIORITY_1, __func__, __LINE__,        \
+			fmt, ##args)
+#define CAM_DBG_PR2(__module, fmt, args...)                                    \
+	cam_debug_log(__module, CAM_DBG_PRIORITY_2, __func__, __LINE__,        \
+			fmt, ##args)
 
 /*
  * CAM_ERR_RATE_LIMIT