diff --git a/drivers/cam_utils/cam_debug_util.c b/drivers/cam_utils/cam_debug_util.c index 7f65442697..beb220599e 100644 --- a/drivers/cam_utils/cam_debug_util.c +++ b/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 @@ -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); } diff --git a/drivers/cam_utils/cam_debug_util.h b/drivers/cam_utils/cam_debug_util.h index 9aafea3e7d..b5044e442d 100644 --- a/drivers/cam_utils/cam_debug_util.h +++ b/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...) \