Преглед изворни кода

msm: camera: common: Reduce data section size with logging optimized

Current logic of logging passes the strings as arguments to
logging Macros. This converts them into string literals and
increase the data section size.
This commit changes the logic to convert the tags into
strings inside a function, thus optimizing the data section size.
Top level estimations shows the reduction of 1.5MB .ko size.

CRs-Fixed: 3470008
Change-Id: Ifcd5bedc374e8c5f36b8c0be5ae050959b432666
Signed-off-by: Gaurav Jindal <[email protected]>
Gaurav Jindal пре 2 година
родитељ
комит
42108eab32
2 измењених фајлова са 29 додато и 14 уклоњено
  1. 14 5
      drivers/cam_utils/cam_debug_util.c
  2. 15 9
      drivers/cam_utils/cam_debug_util.h

+ 14 - 5
drivers/cam_utils/cam_debug_util.c

@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/io.h>
@@ -259,10 +259,11 @@ void cam_print_to_buffer(char *buf, const size_t buf_size, size_t *len, unsigned
 	va_end(args);
 }
 
-static void __cam_print_log(int type, const char *fmt, va_list args)
+static void __cam_print_log(int type, const char *fmt, ...)
 {
-	va_list args1, args2;
+	va_list args1, args2, args;
 
+	va_start(args, fmt);
 	va_copy(args1, args);
 	va_copy(args2, args1);
 	if ((type & CAM_PRINT_LOG) && (debug_type != 1))
@@ -273,16 +274,24 @@ static void __cam_print_log(int type, const char *fmt, va_list args)
 	}
 	va_end(args2);
 	va_end(args1);
+	va_end(args);
 }
 
-void cam_print_log(int type, const char *fmt, ...)
+void cam_print_log(int type, int module, int tag, const char *func,
+	int line, const char *fmt, ...)
 {
+	char buf[CAM_LOG_BUF_LEN] = {0,};
+	int len = 0;
+
 	va_list args;
 
 	if (!type)
 		return;
 
 	va_start(args, fmt);
-	__cam_print_log(type, fmt, args);
+	len = vscnprintf(buf, CAM_LOG_BUF_LEN, fmt, args);
+	__cam_print_log(type, __CAM_LOG_FMT,
+		CAM_LOG_TAG_NAME(tag), CAM_DBG_MOD_NAME(module), func,
+		line, buf);
 	va_end(args);
 }

+ 15 - 9
drivers/cam_utils/cam_debug_util.h

@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
  * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #ifndef _CAM_DEBUG_UTIL_H_
@@ -18,6 +18,8 @@ extern unsigned int debug_drv;
 
 #define CAM_IS_NULL_TO_STR(ptr) ((ptr) ? "Non-NULL" : "NULL")
 
+#define CAM_LOG_BUF_LEN                  512
+
 /* Module IDs used for debug logging */
 enum cam_debug_module_id {
 	CAM_CDM,                 /* bit 0 */
@@ -192,24 +194,28 @@ enum cam_log_print_type {
 	CAM_PRINT_BOTH  = 0x3,
 };
 
-#define __CAM_LOG_FMT KERN_INFO "%s: %s: %s: %d "
+#define __CAM_LOG_FMT KERN_INFO "%s: %s: %s: %d: %s "
 
 /**
  * cam_print_log() - function to print logs (internal use only, use macros instead)
  *
- * @type: corresponds to enum cam_log_print_type, selects if logs are printed in log buffer,
+ * @type:      Corresponds to enum cam_log_print_type, selects if logs are printed in log buffer,
  *        trace buffers or both
- * @fmt:  formatting string
- * @args: arguments corresponding to formatting string
+ * @module_id: Module calling the log macro
+ * @tag:       Tag for log level
+ * @func:      Function string
+ * @line:      Line number
+ * @fmt:       Formatting string
  */
 
-void cam_print_log(int type, const char *fmt, ...);
+void cam_print_log(int type, int module, int tag, const char *func,
+	int line, const char *fmt, ...);
 
 #define __CAM_LOG(type, tag, module_id, fmt, args...)                               \
 ({                                                                                  \
-	cam_print_log(type, __CAM_LOG_FMT fmt,                                      \
-		__CAM_LOG_TAG_NAME(tag), __CAM_DBG_MOD_NAME(module_id), __func__,   \
-		__LINE__, ##args);                                                  \
+	cam_print_log(type,                                      \
+		module_id, tag, __func__,   \
+		__LINE__,  fmt, ##args);                                                  \
 })
 
 #define CAM_LOG(tag, module_id, fmt, args...) \