msm: camera: add/update debug macros and dynamic group selection
Add/updte common logging debug macros, and add dynamic group
selection in order to choose debugging module/modules at runtime.
Sysfs entry can be found under
/sys/module/cam_debug_util/parameters/
Sysfs entry usage with root privilege:
- adb root
- adb remount
- adb shell "echo 0x(module/modules_flag)/Decimal_value >
"/sys/module/cam_debug_util/parameters/debug_mdl"
CRs-Fixed: 2056624
Change-Id: Ifc093a0f290e110466f4a03b7bbd4d3dea06f571
Signed-off-by: Jigarkumar Zala <jzala@codeaurora.org>
diff --git a/drivers/media/platform/msm/camera/cam_utils/cam_debug_util.h b/drivers/media/platform/msm/camera/cam_utils/cam_debug_util.h
index 34adb0e..b542b67 100644
--- a/drivers/media/platform/msm/camera/cam_utils/cam_debug_util.h
+++ b/drivers/media/platform/msm/camera/cam_utils/cam_debug_util.h
@@ -28,7 +28,6 @@
#define CAM_FLASH (1 << 12)
#define STR_BUFFER_MAX_LENGTH 1024
-#define GROUP 0x0000
enum cam_debug_level {
CAM_LEVEL_INFO,
@@ -40,61 +39,61 @@
/*
* cam_debug_log()
*
- * @brief: Get the Module name form module ID and print
- * respective debug logs
+ * @brief : Get the Module name from module ID and print
+ * respective debug logs
*
* @module_id : Respective Module ID which is calling this function
* @dbg_level : Debug level from cam_module_debug_level enum entries
- * @func : Function which is calling to print logs
- * @line : Line number associated with the function which is calling
+ * @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
+ * @fmt : Formatted string which needs to be print in the log
*
*/
void cam_debug_log(unsigned int module_id, enum cam_debug_level dbg_level,
const char *func, const int line, const char *fmt, ...);
/*
+ * cam_get_module_name()
+ *
+ * @brief : Get the module name from module ID
+ *
+ * @module_id : Module ID which is using this function
+ */
+const char *cam_get_module_name(unsigned int module_id);
+
+/*
* CAM_ERR
- * @brief : This Macro will print error logs
+ * @brief : This Macro will print error logs
*
* @__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
+ * @fmt : Formatted string which needs to be print in log
+ * @args : Arguments which needs to be print in log
*/
#define CAM_ERR(__module, fmt, args...) \
- { \
- cam_debug_log(__module, CAM_LEVEL_ERR, \
- __func__, __LINE__, fmt, ##args); \
- }
+ cam_debug_log(__module, CAM_LEVEL_ERR, __func__, __LINE__, fmt, ##args)
/*
* CAM_WARN
- * @brief : This Macro will print warning logs
+ * @brief : This Macro will print warning logs
*
* @__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_WARN(__module, fmt, args...) \
- { \
- cam_debug_log(__module, CAM_LEVEL_WARN, \
- __func__, __LINE__, fmt, ##args); \
- }
+ cam_debug_log(__module, CAM_LEVEL_WARN, __func__, __LINE__, fmt, ##args)
/*
* CAM_INFO
- * @brief : This Macro will print Information logs
+ * @brief : This Macro will print Information logs
*
* @__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_INFO(__module, fmt, args...) \
- { \
- cam_debug_log(__module, CAM_LEVEL_INFO, \
- __func__, __LINE__, fmt, ##args); \
- }
+ cam_debug_log(__module, CAM_LEVEL_INFO, __func__, __LINE__, fmt, ##args)
/*
* CAM_DBG
@@ -105,11 +104,14 @@
* @args : Arguments which needs to be print in log
*/
#define CAM_DBG(__module, fmt, args...) \
- do { \
- if (GROUP & __module) { \
- cam_debug_log(__module, CAM_LEVEL_DBG, \
- __func__, __LINE__, fmt, ##args); \
- } \
- } while (0)
+ cam_debug_log(__module, CAM_LEVEL_DBG, __func__, __LINE__, fmt, ##args)
+
+/*
+ * CAM_ERR_RATE_LIMIT
+ * @brief : This Macro will prevent error print logs with ratelimit
+ */
+#define CAM_ERR_RATE_LIMIT(__module, fmt, args...) \
+ pr_err_ratelimited("CAM_ERR: %s: %s: %d\n" fmt, \
+ cam_get_module_name(__module), __func__, __LINE__, ##args)
#endif /* _CAM_DEBUG_UTIL_H_ */