Эх сурвалжийг харах

msm: camera: common: Enable debugfs compile check

Guards debugfs features in camera driver to only be compiled when
CONFIG_DEBUG_FS is enabled.

CRs-Fixed: 2717236
Change-Id: I0de77741301d259cbec64e8a2e27830981b2b69d
Signed-off-by: Karthik Jayakumar <[email protected]>
Karthik Jayakumar 5 жил өмнө
parent
commit
7c8204a42d

+ 19 - 22
drivers/cam_cpas/cam_cpas_hw.c

@@ -2025,30 +2025,29 @@ static int cam_cpas_util_get_internal_ops(struct platform_device *pdev,
 	return rc;
 }
 
-static int cam_cpas_util_create_debugfs(
-	struct cam_cpas *cpas_core)
+static int cam_cpas_util_create_debugfs(struct cam_cpas *cpas_core)
 {
 	int rc = 0;
+	struct dentry *dbgfileptr = NULL;
 
-	cpas_core->dentry = debugfs_create_dir("camera_cpas", NULL);
-	if (!cpas_core->dentry)
-		return -ENOMEM;
-
-	if (!debugfs_create_bool("ahb_bus_scaling_disable",
-		0644,
-		cpas_core->dentry,
-		&cpas_core->ahb_bus_scaling_disable)) {
-		CAM_ERR(CAM_CPAS,
-			"failed to create ahb_bus_scaling_disable entry");
-		rc = -ENOMEM;
-		goto err;
+	dbgfileptr = debugfs_create_dir("camera_cpas", NULL);
+	if (!dbgfileptr) {
+		CAM_ERR(CAM_CPAS,"DebugFS could not create directory!");
+		rc = -ENOENT;
+		goto end;
 	}
+	/* Store parent inode for cleanup in caller */
+	cpas_core->dentry = dbgfileptr;
 
-	return 0;
-
-err:
-	debugfs_remove_recursive(cpas_core->dentry);
-	cpas_core->dentry = NULL;
+	dbgfileptr = debugfs_create_bool("ahb_bus_scaling_disable", 0644,
+		cpas_core->dentry, &cpas_core->ahb_bus_scaling_disable);
+	if (IS_ERR(dbgfileptr)) {
+		if (PTR_ERR(dbgfileptr) == -ENODEV)
+			CAM_WARN(CAM_CPAS, "DebugFS not enabled in kernel!");
+		else
+			rc = PTR_ERR(dbgfileptr);
+	}
+end:
 	return rc;
 }
 
@@ -2195,9 +2194,7 @@ int cam_cpas_hw_probe(struct platform_device *pdev,
 	if (rc)
 		goto axi_cleanup;
 
-	rc  = cam_cpas_util_create_debugfs(cpas_core);
-	if (rc)
-		CAM_WARN(CAM_CPAS, "Failed to create dentry");
+	rc = cam_cpas_util_create_debugfs(cpas_core);
 
 	*hw_intf = cpas_hw_intf;
 	return 0;

+ 30 - 67
drivers/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c

@@ -1885,83 +1885,47 @@ DEFINE_SIMPLE_ATTRIBUTE(cam_icp_debug_fw_dump, cam_icp_get_a5_fw_dump_lvl,
 static int cam_icp_hw_mgr_create_debugfs_entry(void)
 {
 	int rc = 0;
+	struct dentry *dbgfileptr = NULL;
 
-	icp_hw_mgr.dentry = debugfs_create_dir("camera_icp", NULL);
-	if (IS_ERR_OR_NULL(icp_hw_mgr.dentry)) {
-		CAM_ERR(CAM_ICP, "Debugfs entry dir: %s failed",
-			"camrea_icp");
-		return -ENOMEM;
+	dbgfileptr = debugfs_create_dir("camera_icp", NULL);
+	if (!dbgfileptr) {
+		CAM_ERR(CAM_ICP,"DebugFS could not create directory!");
+		rc = -ENOENT;
+		goto end;
 	}
+	/* Store parent inode for cleanup in caller */
+	icp_hw_mgr.dentry = dbgfileptr;
 
-	if (!debugfs_create_bool("icp_pc",
-		0644,
-		icp_hw_mgr.dentry,
-		&icp_hw_mgr.icp_pc_flag)) {
-		CAM_ERR(CAM_ICP, "failed to create icp_pc entry");
-		rc = -ENOMEM;
-		goto err;
-	}
+	dbgfileptr = debugfs_create_bool("icp_pc", 0644, icp_hw_mgr.dentry,
+		&icp_hw_mgr.icp_pc_flag);
 
-	if (!debugfs_create_bool("ipe_bps_pc",
-		0644,
-		icp_hw_mgr.dentry,
-		&icp_hw_mgr.ipe_bps_pc_flag)) {
-		CAM_ERR(CAM_ICP, "failed to create ipe_bps_pc entry");
-		rc = -ENOMEM;
-		goto err;
-	}
+	dbgfileptr = debugfs_create_bool("ipe_bps_pc", 0644, icp_hw_mgr.dentry,
+		&icp_hw_mgr.ipe_bps_pc_flag);
 
-	if (!debugfs_create_file("icp_debug_clk",
-		0644,
-		icp_hw_mgr.dentry, NULL,
-		&cam_icp_debug_default_clk)) {
-		CAM_ERR(CAM_ICP, "failed to create icp_debug_clk entry");
-		rc = -ENOMEM;
-		goto err;
-	}
+	dbgfileptr = debugfs_create_file("icp_debug_clk", 0644,
+		icp_hw_mgr.dentry, NULL, &cam_icp_debug_default_clk);
 
-	if (!debugfs_create_bool("a5_jtag_debug",
-		0644,
-		icp_hw_mgr.dentry,
-		&icp_hw_mgr.a5_jtag_debug)) {
-		rc = -ENOMEM;
-		goto err;
-	}
+	dbgfileptr = debugfs_create_bool("a5_jtag_debug", 0644,
+		icp_hw_mgr.dentry, &icp_hw_mgr.a5_jtag_debug);
 
-	if (!debugfs_create_file("a5_debug_type",
-		0644,
-		icp_hw_mgr.dentry,
-		NULL, &cam_icp_debug_type_fs)) {
-		CAM_ERR(CAM_ICP, "failed to create a5_debug_type");
-		rc = -ENOMEM;
-		goto err;
-	}
+	dbgfileptr = debugfs_create_file("a5_debug_type", 0644,
+		icp_hw_mgr.dentry, NULL, &cam_icp_debug_type_fs);
 
-	if (!debugfs_create_file("a5_debug_lvl",
-		0644,
-		icp_hw_mgr.dentry,
-		NULL, &cam_icp_debug_fs)) {
-		CAM_ERR(CAM_ICP, "failed to create a5_dbg_lvl");
-		rc = -ENOMEM;
-		goto err;
-	}
+	dbgfileptr = debugfs_create_file("a5_debug_lvl", 0644,
+		icp_hw_mgr.dentry, NULL, &cam_icp_debug_fs);
 
-	if (!debugfs_create_file("a5_fw_dump_lvl",
-		0644,
-		icp_hw_mgr.dentry,
-		NULL, &cam_icp_debug_fw_dump)) {
-		CAM_ERR(CAM_ICP, "failed to create a5_fw_dump_lvl");
-		rc = -ENOMEM;
-		goto err;
+	dbgfileptr = debugfs_create_file("a5_fw_dump_lvl", 0644,
+		icp_hw_mgr.dentry, NULL, &cam_icp_debug_fw_dump);
+	if (IS_ERR(dbgfileptr)) {
+		if (PTR_ERR(dbgfileptr) == -ENODEV)
+			CAM_WARN(CAM_ICP, "DebugFS not enabled in kernel!");
+		else
+			rc = PTR_ERR(dbgfileptr);
 	}
-
+end:
 	/* Set default hang dump lvl */
 	icp_hw_mgr.a5_fw_dump_lvl = HFI_FW_DUMP_ON_FAILURE;
 	return rc;
-err:
-	debugfs_remove_recursive(icp_hw_mgr.dentry);
-	icp_hw_mgr.dentry = NULL;
-	return rc;
 }
 
 static int cam_icp_mgr_process_cmd(void *priv, void *data)
@@ -6017,10 +5981,9 @@ static int cam_icp_mgr_create_wq(void)
 	}
 
 	rc = cam_icp_hw_mgr_create_debugfs_entry();
-	if (rc) {
-		CAM_ERR(CAM_ICP, "create_debugfs_entry fail= rc: %d", rc);
+	if (rc)
 		goto debugfs_create_failed;
-	}
+
 	for (i = 0; i < ICP_WORKQ_NUM_TASK; i++)
 		icp_hw_mgr.msg_work->task.pool[i].payload =
 				&icp_hw_mgr.msg_work_data[i];

+ 18 - 17
drivers/cam_isp/cam_isp_context.c

@@ -5306,27 +5306,28 @@ static int cam_isp_context_dump_active_request(void *data, unsigned long iova,
 
 static int cam_isp_context_debug_register(void)
 {
-	isp_ctx_debug.dentry = debugfs_create_dir("camera_isp_ctx",
-		NULL);
+	int rc = 0;
+	struct dentry *dbgfileptr = NULL;
 
-	if (IS_ERR_OR_NULL(isp_ctx_debug.dentry)) {
-		CAM_ERR(CAM_ISP, "failed to create dentry");
-		return -ENOMEM;
+	dbgfileptr = debugfs_create_dir("camera_isp_ctx", NULL);
+	if (!dbgfileptr) {
+		CAM_ERR(CAM_ICP,"DebugFS could not create directory!");
+		rc = -ENOENT;
+		goto end;
 	}
+	/* Store parent inode for cleanup in caller */
+	isp_ctx_debug.dentry = dbgfileptr;
 
-	if (!debugfs_create_u32("enable_state_monitor_dump",
-		0644,
-		isp_ctx_debug.dentry,
-		&isp_ctx_debug.enable_state_monitor_dump)) {
-		CAM_ERR(CAM_ISP, "failed to create enable_state_monitor_dump");
-		goto err;
+	dbgfileptr = debugfs_create_u32("enable_state_monitor_dump", 0644,
+		isp_ctx_debug.dentry, &isp_ctx_debug.enable_state_monitor_dump);
+	if (IS_ERR(dbgfileptr)) {
+		if (PTR_ERR(dbgfileptr) == -ENODEV)
+			CAM_WARN(CAM_ICP, "DebugFS not enabled in kernel!");
+		else
+			rc = PTR_ERR(dbgfileptr);
 	}
-
-	return 0;
-
-err:
-	debugfs_remove_recursive(isp_ctx_debug.dentry);
-	return -ENOMEM;
+end:
+	return rc;
 }
 
 int cam_isp_context_init(struct cam_isp_context *ctx,

+ 26 - 49
drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c

@@ -7818,61 +7818,40 @@ DEFINE_SIMPLE_ATTRIBUTE(cam_ife_camif_debug,
 
 static int cam_ife_hw_mgr_debug_register(void)
 {
-	g_ife_hw_mgr.debug_cfg.dentry = debugfs_create_dir("camera_ife",
-		NULL);
-
-	if (!g_ife_hw_mgr.debug_cfg.dentry) {
-		CAM_ERR(CAM_ISP, "failed to create dentry");
-		return -ENOMEM;
-	}
+	int rc = 0;
+	struct dentry *dbgfileptr = NULL;
 
-	if (!debugfs_create_file("ife_csid_debug",
-		0644,
-		g_ife_hw_mgr.debug_cfg.dentry, NULL,
-		&cam_ife_csid_debug)) {
-		CAM_ERR(CAM_ISP, "failed to create cam_ife_csid_debug");
-		goto err;
+	dbgfileptr = debugfs_create_dir("camera_ife", NULL);
+	if (!dbgfileptr) {
+		CAM_ERR(CAM_ISP,"DebugFS could not create directory!");
+		rc = -ENOENT;
+		goto end;
 	}
+	/* Store parent inode for cleanup in caller */
+	g_ife_hw_mgr.debug_cfg.dentry = dbgfileptr;
 
-	if (!debugfs_create_u32("enable_recovery",
-		0644,
+	dbgfileptr = debugfs_create_file("ife_csid_debug", 0644,
+		g_ife_hw_mgr.debug_cfg.dentry, NULL, &cam_ife_csid_debug);
+	dbgfileptr = debugfs_create_u32("enable_recovery", 0644,
 		g_ife_hw_mgr.debug_cfg.dentry,
-		&g_ife_hw_mgr.debug_cfg.enable_recovery)) {
-		CAM_ERR(CAM_ISP, "failed to create enable_recovery");
-		goto err;
-	}
-
-	if (!debugfs_create_bool("enable_req_dump",
-		0644,
+		&g_ife_hw_mgr.debug_cfg.enable_recovery);
+	dbgfileptr = debugfs_create_bool("enable_req_dump", 0644,
 		g_ife_hw_mgr.debug_cfg.dentry,
-		&g_ife_hw_mgr.debug_cfg.enable_req_dump)) {
-		CAM_ERR(CAM_ISP, "failed to create enable_req_dump");
-		goto err;
-	}
-
-	if (!debugfs_create_file("ife_camif_debug",
-		0644,
-		g_ife_hw_mgr.debug_cfg.dentry, NULL,
-		&cam_ife_camif_debug)) {
-		CAM_ERR(CAM_ISP, "failed to create cam_ife_camif_debug");
-		goto err;
-	}
-
-	if (!debugfs_create_bool("per_req_reg_dump",
-		0644,
+		&g_ife_hw_mgr.debug_cfg.enable_req_dump);
+	dbgfileptr = debugfs_create_file("ife_camif_debug", 0644,
+		g_ife_hw_mgr.debug_cfg.dentry, NULL, &cam_ife_camif_debug);
+	dbgfileptr = debugfs_create_bool("per_req_reg_dump", 0644,
 		g_ife_hw_mgr.debug_cfg.dentry,
-		&g_ife_hw_mgr.debug_cfg.per_req_reg_dump)) {
-		CAM_ERR(CAM_ISP, "failed to create per_req_reg_dump entry");
-		goto err;
+		&g_ife_hw_mgr.debug_cfg.per_req_reg_dump);
+	if (IS_ERR(dbgfileptr)) {
+		if (PTR_ERR(dbgfileptr) == -ENODEV)
+			CAM_WARN(CAM_ISP, "DebugFS not enabled in kernel!");
+		else
+			rc = PTR_ERR(dbgfileptr);
 	}
-
+end:
 	g_ife_hw_mgr.debug_cfg.enable_recovery = 0;
-
-	return 0;
-
-err:
-	debugfs_remove_recursive(g_ife_hw_mgr.debug_cfg.dentry);
-	return -ENOMEM;
+	return rc;
 }
 
 static void cam_req_mgr_process_workq_cam_ife_worker(struct work_struct *w)
@@ -7888,8 +7867,6 @@ int cam_ife_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf, int *iommu_hdl)
 	struct cam_ife_hw_mgr_ctx *ctx_pool;
 	struct cam_isp_hw_mgr_res *res_list_ife_out;
 
-	CAM_DBG(CAM_ISP, "Enter");
-
 	memset(&g_ife_hw_mgr, 0, sizeof(g_ife_hw_mgr));
 
 	mutex_init(&g_ife_hw_mgr.ctx_mutex);

+ 34 - 47
drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.c

@@ -5263,65 +5263,52 @@ DEFINE_DEBUGFS_ATTRIBUTE(cam_tfe_camif_debug,
 	cam_tfe_get_camif_debug,
 	cam_tfe_set_camif_debug, "%16llu");
 
+#if IS_ENABLED(CONFIG_DEBUG_FS)
 static int cam_tfe_hw_mgr_debug_register(void)
 {
-	g_tfe_hw_mgr.debug_cfg.dentry = debugfs_create_dir("camera_tfe",
-		NULL);
-
-	if (!g_tfe_hw_mgr.debug_cfg.dentry) {
-		CAM_ERR(CAM_ISP, "failed to create dentry");
-		return -ENOMEM;
-	}
+	int rc = 0;
+	struct dentry *dbgfileptr = NULL;
 
-	if (!debugfs_create_file("tfe_csid_debug",
-		0644,
-		g_tfe_hw_mgr.debug_cfg.dentry, NULL,
-		&cam_tfe_csid_debug)) {
-		CAM_ERR(CAM_ISP, "failed to create cam_tfe_csid_debug");
-		goto err;
+	dbgfileptr = debugfs_create_dir("camera_ife", NULL);
+	if (!dbgfileptr) {
+		CAM_ERR(CAM_ISP,"DebugFS could not create directory!");
+		rc = -ENOENT;
+		goto end;
 	}
+	/* Store parent inode for cleanup in caller */
+	g_tfe_hw_mgr.debug_cfg.dentry = dbgfileptr;
 
-	if (!debugfs_create_u32("enable_recovery",
-		0644,
+	dbgfileptr = debugfs_create_file("tfe_csid_debug", 0644,
+		g_tfe_hw_mgr.debug_cfg.dentry, NULL, &cam_tfe_csid_debug);
+	dbgfileptr = debugfs_create_u32("enable_recovery", 0644,
 		g_tfe_hw_mgr.debug_cfg.dentry,
-		&g_tfe_hw_mgr.debug_cfg.enable_recovery)) {
-		CAM_ERR(CAM_ISP, "failed to create enable_recovery");
-		goto err;
-	}
-
-	if (!debugfs_create_u32("enable_reg_dump",
-		0644,
+		&g_tfe_hw_mgr.debug_cfg.enable_recovery);
+	dbgfileptr = debugfs_create_u32("enable_reg_dump", 0644,
 		g_tfe_hw_mgr.debug_cfg.dentry,
-		&g_tfe_hw_mgr.debug_cfg.enable_reg_dump)) {
-		CAM_ERR(CAM_ISP, "failed to create enable_reg_dump");
-		goto err;
-	}
-
-	if (!debugfs_create_file("tfe_camif_debug",
-		0644,
-		g_tfe_hw_mgr.debug_cfg.dentry, NULL,
-		&cam_tfe_camif_debug)) {
-		CAM_ERR(CAM_ISP, "failed to create cam_tfe_camif_debug");
-		goto err;
-	}
-
-	if (!debugfs_create_u32("per_req_reg_dump",
-		0644,
+		&g_tfe_hw_mgr.debug_cfg.enable_reg_dump);
+	dbgfileptr = debugfs_create_file("tfe_camif_debug", 0644,
+		g_tfe_hw_mgr.debug_cfg.dentry, NULL, &cam_tfe_camif_debug);
+	dbgfileptr = debugfs_create_u32("per_req_reg_dump", 0644,
 		g_tfe_hw_mgr.debug_cfg.dentry,
-		&g_tfe_hw_mgr.debug_cfg.per_req_reg_dump)) {
-		CAM_ERR(CAM_ISP, "failed to create per_req_reg_dump entry");
-		goto err;
+		&g_tfe_hw_mgr.debug_cfg.per_req_reg_dump);
+	if (IS_ERR(dbgfileptr)) {
+		if (PTR_ERR(dbgfileptr) == -ENODEV)
+			CAM_WARN(CAM_ISP, "DebugFS not enabled in kernel!");
+		else
+			rc = PTR_ERR(dbgfileptr);
 	}
-
-
+end:
 	g_tfe_hw_mgr.debug_cfg.enable_recovery = 0;
-
+	return rc;
+}
+#else
+static inline int cam_tfe_hw_mgr_debug_register(void)
+{
+	g_tfe_hw_mgr.debug_cfg.enable_recovery = 0;
+	CAM_WARN(CAM_ISP, "DebugFS not enabled in kernel");
 	return 0;
-
-err:
-	debugfs_remove_recursive(g_tfe_hw_mgr.debug_cfg.dentry);
-	return -ENOMEM;
 }
+#endif
 
 static void cam_req_mgr_process_tfe_worker(struct work_struct *w)
 {

+ 16 - 16
drivers/cam_lrme/lrme_hw_mgr/cam_lrme_hw_mgr.c

@@ -1016,28 +1016,28 @@ static int cam_lrme_mgr_hw_config(void *hw_mgr_priv,
 static int cam_lrme_mgr_create_debugfs_entry(void)
 {
 	int rc = 0;
+	struct dentry *dbgfileptr = NULL;
 
-	g_lrme_hw_mgr.debugfs_entry.dentry =
-		debugfs_create_dir("camera_lrme", NULL);
-	if (!g_lrme_hw_mgr.debugfs_entry.dentry) {
-		CAM_ERR(CAM_LRME, "failed to create dentry");
-		return -ENOMEM;
+	dbgfileptr = debugfs_create_dir("camera_lrme", NULL);
+	if (!dbgfileptr) {
+		CAM_ERR(CAM_ISP,"DebugFS could not create directory!");
+		rc = -ENOENT;
+		goto end;
 	}
+	/* Store parent inode for cleanup in caller */
+	g_lrme_hw_mgr.debugfs_entry.dentry = dbgfileptr;
 
-	if (!debugfs_create_bool("dump_register",
-		0644,
+	dbgfileptr = debugfs_create_bool("dump_register", 0644,
 		g_lrme_hw_mgr.debugfs_entry.dentry,
-		&g_lrme_hw_mgr.debugfs_entry.dump_register)) {
-		CAM_ERR(CAM_LRME, "failed to create dump register entry");
-		rc = -ENOMEM;
-		goto err;
+		&g_lrme_hw_mgr.debugfs_entry.dump_register);
+	if (IS_ERR(dbgfileptr)) {
+		if (PTR_ERR(dbgfileptr) == -ENODEV)
+			CAM_WARN(CAM_LRME, "DebugFS not enabled in kernel!");
+		else
+			rc = PTR_ERR(dbgfileptr);
 	}
 
-	return rc;
-
 err:
-	debugfs_remove_recursive(g_lrme_hw_mgr.debugfs_entry.dentry);
-	g_lrme_hw_mgr.debugfs_entry.dentry = NULL;
 	return rc;
 }
 
@@ -1145,6 +1145,7 @@ int cam_lrme_mgr_deregister_device(int device_index)
 int cam_lrme_hw_mgr_deinit(void)
 {
 	mutex_destroy(&g_lrme_hw_mgr.hw_mgr_mutex);
+	debugfs_remove_recursive(g_lrme_hw_mgr.debugfs_entry.dentry);
 	memset(&g_lrme_hw_mgr, 0x0, sizeof(g_lrme_hw_mgr));
 
 	return 0;
@@ -1199,7 +1200,6 @@ int cam_lrme_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf,
 	hw_mgr_intf->hw_dump = cam_lrme_mgr_hw_dump;
 
 	cam_lrme_mgr_create_debugfs_entry();
-
 	CAM_DBG(CAM_LRME, "Hw mgr init done");
 	return rc;
 }

+ 19 - 16
drivers/cam_req_mgr/cam_mem_mgr.c

@@ -154,25 +154,28 @@ static int cam_mem_util_unmap_cpu_va(struct dma_buf *dmabuf,
 
 static int cam_mem_mgr_create_debug_fs(void)
 {
-	tbl.dentry = debugfs_create_dir("camera_memmgr", NULL);
-	if (!tbl.dentry) {
-		CAM_ERR(CAM_MEM, "failed to create dentry");
-		return -ENOMEM;
-	}
+	int rc = 0;
+	struct dentry *dbgfileptr = NULL;
 
-	if (!debugfs_create_bool("alloc_profile_enable",
-		0644,
-		tbl.dentry,
-		&tbl.alloc_profile_enable)) {
-		CAM_ERR(CAM_MEM,
-			"failed to create alloc_profile_enable");
-		goto err;
+	dbgfileptr = debugfs_create_dir("camera_memmgr", NULL);
+	if (!dbgfileptr) {
+		CAM_ERR(CAM_MEM,"DebugFS could not create directory!");
+		rc = -ENOENT;
+		goto end;
 	}
+	/* Store parent inode for cleanup in caller */
+	tbl.dentry = dbgfileptr;
 
-	return 0;
-err:
-	debugfs_remove_recursive(tbl.dentry);
-	return -ENOMEM;
+	dbgfileptr = debugfs_create_bool("alloc_profile_enable", 0644,
+		tbl.dentry, &tbl.alloc_profile_enable);
+	if (IS_ERR(dbgfileptr)) {
+		if (PTR_ERR(dbgfileptr) == -ENODEV)
+			CAM_WARN(CAM_MEM, "DebugFS not enabled in kernel!");
+		else
+			rc = PTR_ERR(dbgfileptr);
+	}
+end:
+	return rc;
 }
 
 int cam_mem_mgr_init(void)

+ 26 - 24
drivers/cam_req_mgr/cam_req_mgr_debug.c

@@ -8,7 +8,6 @@
 #define MAX_SESS_INFO_LINE_BUFF_LEN 256
 
 static char sess_info_buffer[MAX_SESS_INFO_LINE_BUFF_LEN];
-static struct dentry  *debugfs_root;
 
 static int cam_req_mgr_debug_set_bubble_recovery(void *data, u64 val)
 {
@@ -111,32 +110,35 @@ static const struct file_operations session_info = {
 	.write = session_info_write,
 };
 
+static struct dentry *debugfs_root;
 int cam_req_mgr_debug_register(struct cam_req_mgr_core_device *core_dev)
 {
-	char dirname[32] = {0};
-	snprintf(dirname, sizeof(dirname), "cam_req_mgr");
-	debugfs_root = debugfs_create_dir(dirname, NULL);
-	if (IS_ERR_OR_NULL(debugfs_root)) {
-		CAM_ERR(CAM_CRM, "Failed to create cam_req_mgr debugfs dir");
-		return -ENOMEM;
-	}
+	int rc = 0;
+	struct dentry *dbgfileptr = NULL;
 
-	if (!debugfs_create_file("sessions_info", 0644,
-		debugfs_root, core_dev, &session_info))
-		CAM_WARN(CAM_CRM,
-			"Failed to create sessions_info debugfs file");
-
-	if (!debugfs_create_file("bubble_recovery", 0644,
-		debugfs_root, core_dev, &bubble_recovery))
-		CAM_WARN(CAM_CRM,
-			"Failed to create bubble_recovery debugfs file");
-
-	if (!debugfs_create_bool("recovery_on_apply_fail",
-		0644, debugfs_root,
-		&core_dev->recovery_on_apply_fail))
-		CAM_WARN(CAM_CRM,
-			"Failed to create recovery_on_apply_fail debugfs bool");
-	return 0;
+	dbgfileptr = debugfs_create_dir("cam_req_mgr", NULL);
+	if (!dbgfileptr) {
+		CAM_ERR(CAM_MEM,"DebugFS could not create directory!");
+		rc = -ENOENT;
+		goto end;
+	}
+	/* Store parent inode for cleanup in caller */
+	debugfs_root = dbgfileptr;
+
+	dbgfileptr = debugfs_create_file("sessions_info", 0644, debugfs_root,
+		core_dev, &session_info);
+	dbgfileptr = debugfs_create_file("bubble_recovery", 0644,
+		debugfs_root, core_dev, &bubble_recovery);
+	dbgfileptr = debugfs_create_bool("recovery_on_apply_fail", 0644,
+		debugfs_root, &core_dev->recovery_on_apply_fail);
+	if (IS_ERR(dbgfileptr)) {
+		if (PTR_ERR(dbgfileptr) == -ENODEV)
+			CAM_WARN(CAM_MEM, "DebugFS not enabled in kernel!");
+		else
+			rc = PTR_ERR(dbgfileptr);
+	}
+end:
+	return rc;
 }
 
 void cam_req_mgr_debug_unregister(void)

+ 20 - 26
drivers/cam_smmu/cam_smmu_api.c

@@ -3921,36 +3921,30 @@ cb_init_fail:
 
 static int cam_smmu_create_debug_fs(void)
 {
-	iommu_cb_set.dentry = debugfs_create_dir("camera_smmu",
-		NULL);
-
-	if (!iommu_cb_set.dentry) {
-		CAM_ERR(CAM_SMMU, "failed to create dentry");
-		return -ENOMEM;
-	}
+	int rc = 0;
+	struct dentry *dbgfileptr = NULL;
 
-	if (!debugfs_create_bool("cb_dump_enable",
-		0644,
-		iommu_cb_set.dentry,
-		&iommu_cb_set.cb_dump_enable)) {
-		CAM_ERR(CAM_SMMU,
-			"failed to create dump_enable_debug");
-		goto err;
+	dbgfileptr = debugfs_create_dir("camera_smmu", NULL);
+	if (!dbgfileptr) {
+		CAM_ERR(CAM_SMMU,"DebugFS could not create directory!");
+		rc = -ENOENT;
+		goto end;
 	}
+	/* Store parent inode for cleanup in caller */
+	iommu_cb_set.dentry = dbgfileptr;
 
-	if (!debugfs_create_bool("map_profile_enable",
-		0644,
-		iommu_cb_set.dentry,
-		&iommu_cb_set.map_profile_enable)) {
-		CAM_ERR(CAM_SMMU,
-			"failed to create map_profile_enable");
-		goto err;
+	dbgfileptr = debugfs_create_bool("cb_dump_enable", 0644,
+		iommu_cb_set.dentry, &iommu_cb_set.cb_dump_enable);
+	dbgfileptr = debugfs_create_bool("map_profile_enable", 0644,
+		iommu_cb_set.dentry, &iommu_cb_set.map_profile_enable);
+	if (IS_ERR(dbgfileptr)) {
+		if (PTR_ERR(dbgfileptr) == -ENODEV)
+			CAM_WARN(CAM_MEM, "DebugFS not enabled in kernel!");
+		else
+			rc = PTR_ERR(dbgfileptr);
 	}
-
-	return 0;
-err:
-	debugfs_remove_recursive(iommu_cb_set.dentry);
-	return -ENOMEM;
+end:
+	return rc;
 }
 
 static int cam_smmu_fw_dev_component_bind(struct device *dev,

+ 19 - 13
drivers/cam_sync/cam_sync.c

@@ -1018,22 +1018,28 @@ static void cam_sync_init_entity(struct sync_device *sync_dev)
 
 static int cam_sync_create_debugfs(void)
 {
-	sync_dev->dentry = debugfs_create_dir("camera_sync", NULL);
+	int rc = 0;
+	struct dentry *dbgfileptr = NULL;
 
-	if (!sync_dev->dentry) {
-		CAM_ERR(CAM_SYNC, "Failed to create sync dir");
-		return -ENOMEM;
+	dbgfileptr = debugfs_create_dir("camera_sync", NULL);
+	if (!dbgfileptr) {
+		CAM_ERR(CAM_SYNC,"DebugFS could not create directory!");
+		rc = -ENOENT;
+		goto end;
 	}
-
-	if (!debugfs_create_bool("trigger_cb_without_switch",
-		0644, sync_dev->dentry,
-		&trigger_cb_without_switch)) {
-		CAM_ERR(CAM_SYNC,
-			"failed to create trigger_cb_without_switch entry");
-		return -ENOMEM;
+	/* Store parent inode for cleanup in caller */
+	sync_dev->dentry = dbgfileptr;
+
+	dbgfileptr = debugfs_create_bool("trigger_cb_without_switch", 0644,
+		sync_dev->dentry, &trigger_cb_without_switch);
+	if (IS_ERR(dbgfileptr)) {
+		if (PTR_ERR(dbgfileptr) == -ENODEV)
+			CAM_WARN(CAM_SYNC, "DebugFS not enabled in kernel!");
+		else
+			rc = PTR_ERR(dbgfileptr);
 	}
-
-	return 0;
+end:
+	return rc;
 }
 
 #if IS_REACHABLE(CONFIG_MSM_GLOBAL_SYNX)

+ 25 - 37
drivers/cam_utils/cam_soc_util.c

@@ -14,7 +14,6 @@
 #include "cam_mem_mgr.h"
 
 static char supported_clk_info[256];
-static char debugfs_dir_name[64];
 
 int cam_soc_util_get_clk_level(struct cam_hw_soc_info *soc_info,
 	int64_t clk_rate, int clk_idx, int32_t *clk_lvl)
@@ -181,53 +180,43 @@ DEFINE_SIMPLE_ATTRIBUTE(cam_soc_util_clk_lvl_control,
  *
  * @return:     Success or failure
  */
-static int cam_soc_util_create_clk_lvl_debugfs(
-	struct cam_hw_soc_info *soc_info)
+static int cam_soc_util_create_clk_lvl_debugfs(struct cam_hw_soc_info *soc_info)
 {
-	if (!soc_info) {
-		CAM_ERR(CAM_UTIL, "soc info is NULL");
-		return -EINVAL;
-	}
+	char debugfs_dir_name[64];
+	int rc = 0;
+	struct dentry *dbgfileptr = NULL;
 
-	if (soc_info->dentry) {
-		CAM_DBG(CAM_UTIL, "Debubfs entry for %s already exist",
+	if (!soc_info->dentry) {
+		CAM_DBG(CAM_UTIL, "Debugfs entry for %s already exist",
 			soc_info->dev_name);
-		return 0;
+		goto end;
 	}
 
 	memset(debugfs_dir_name, 0, sizeof(debugfs_dir_name));
 	strlcat(debugfs_dir_name, "clk_dir_", sizeof(debugfs_dir_name));
 	strlcat(debugfs_dir_name, soc_info->dev_name, sizeof(debugfs_dir_name));
 
-	soc_info->dentry = debugfs_create_dir(debugfs_dir_name, NULL);
-	if (IS_ERR_OR_NULL(soc_info->dentry)) {
-		CAM_ERR(CAM_UTIL, "failed to create debug directory");
-		return -ENOMEM;
-	}
-
-	if (!debugfs_create_file("clk_lvl_options", 0444,
-		soc_info->dentry, soc_info, &cam_soc_util_clk_lvl_options)) {
-		CAM_ERR(CAM_UTIL, "failed to create clk_lvl_options");
-		goto err;
+	dbgfileptr = debugfs_create_dir(debugfs_dir_name, NULL);
+	if (!dbgfileptr) {
+		CAM_ERR(CAM_UTIL,"DebugFS could not create directory!");
+		rc = -ENOENT;
+		goto end;
 	}
+	/* Store parent inode for cleanup in caller */
+	soc_info->dentry = dbgfileptr;
 
-	if (!debugfs_create_file("clk_lvl_control", 0644,
-		soc_info->dentry, soc_info, &cam_soc_util_clk_lvl_control)) {
-		CAM_ERR(CAM_UTIL, "failed to create clk_lvl_control");
-		goto err;
+	dbgfileptr = debugfs_create_file("clk_lvl_options", 0444,
+		soc_info->dentry, soc_info, &cam_soc_util_clk_lvl_options);
+	dbgfileptr = debugfs_create_file("clk_lvl_control", 0644,
+		soc_info->dentry, soc_info, &cam_soc_util_clk_lvl_control);
+	if (IS_ERR(dbgfileptr)) {
+		if (PTR_ERR(dbgfileptr) == -ENODEV)
+			CAM_WARN(CAM_UTIL, "DebugFS not enabled in kernel!");
+		else
+			rc = PTR_ERR(dbgfileptr);
 	}
-
-	CAM_DBG(CAM_UTIL, "clk lvl debugfs for %s successfully created",
-		soc_info->dev_name);
-
-	return 0;
-
-err:
-	CAM_ERR(CAM_UTIL, "Error in creating Debugfs Entry: %s",
-		soc_info->dev_name);
-	debugfs_remove_recursive(soc_info->dentry);
-	soc_info->dentry = NULL;
-	return -ENOMEM;
+end:
+	return rc;
 }
 
 /**
@@ -243,7 +232,6 @@ static void cam_soc_util_remove_clk_lvl_debugfs(
 	struct cam_hw_soc_info *soc_info)
 {
 	debugfs_remove_recursive(soc_info->dentry);
-	soc_info->dentry = NULL;
 }
 
 int cam_soc_util_get_level_from_string(const char *string,