Pārlūkot izejas kodu

Merge "qcom: tz_log: Avoid creating proc node in case of init failures"

qctecmdr 1 gadu atpakaļ
vecāks
revīzija
4ab10179bf
1 mainītis faili ar 17 papildinājumiem un 27 dzēšanām
  1. 17 27
      tz_log/tz_log.c

+ 17 - 27
tz_log/tz_log.c

@@ -414,6 +414,7 @@ struct tzdbg_stat {
 	size_t display_offset;
 	char *name;
 	char *data;
+	bool avail;
 };
 
 struct tzdbg {
@@ -1206,10 +1207,6 @@ static int _disp_tme_log_stats(size_t count)
 	uint32_t log_len = 0;
 	int ret = 0;
 
-	/* Return 0 to close file in case some error in initialising step. */
-	if (!tzdbg.tmelog_virt_iobase || !tmecrashdump_address_offset)
-		return 0;
-
 	/* Return 0 to close the display file */
 	if ((log_start.size == 0x0) && wrap_around) {
 		wrap_around = false;
@@ -1576,20 +1573,6 @@ static void tzdbg_free_encrypted_log_buf(struct platform_device *pdev)
 			enc_qseelog_info.vaddr, enc_qseelog_info.paddr);
 }
 
-static bool is_hyp_dir(int tzdbg_stat_type)
-{
-	switch(tzdbg_stat_type)
-	{
-		case TZDBG_HYP_GENERAL:
-		case TZDBG_HYP_LOG:
-		case TZDBG_RM_LOG:
-			return true;
-		default:
-			return false;
-	}
-	return false;
-}
-
 static int  tzdbg_fs_init(struct platform_device *pdev)
 {
 	int rc = 0;
@@ -1605,14 +1588,9 @@ static int  tzdbg_fs_init(struct platform_device *pdev)
 
 	for (i = 0; i < TZDBG_STATS_MAX; i++) {
 		tzdbg.debug_tz[i] = i;
-		/*
-		 * If hypervisor is disabled, do not create
-		 * hyp_general, hyp_log and rm_log directories,
-		 * as accessing them would give segmentation fault
-		 */
-		if ((!tzdbg.is_hyplog_enabled) && (is_hyp_dir(i))) {
+		if (!tzdbg.stat[i].avail)
 			continue;
-		}
+
 		dent = proc_create_data(tzdbg.stat[i].name,
 				0444, dent_dir,
 				&tzdbg_fops, &tzdbg.debug_tz[i]);
@@ -1799,7 +1777,14 @@ static int tz_log_probe(struct platform_device *pdev)
 	void __iomem *virt_iobase;
 	phys_addr_t tzdiag_phy_iobase;
 	uint32_t *ptr = NULL;
-	int ret = 0;
+	int ret = 0, i;
+
+	/*
+	 * By default all nodes will be created.
+	 * Mark avail as false later selectively if there's need to skip proc node creation.
+	 */
+	for (i = 0; i < TZDBG_STATS_MAX; i++)
+		tzdbg.stat[i].avail = true;
 
 	ret = tzdbg_get_tz_version();
 	if (ret)
@@ -1852,6 +1837,9 @@ static int tz_log_probe(struct platform_device *pdev)
 				return -EINVAL;
 			}
 		} else {
+			tzdbg.stat[TZDBG_HYP_LOG].avail = false;
+			tzdbg.stat[TZDBG_HYP_GENERAL].avail = false;
+			tzdbg.stat[TZDBG_RM_LOG].avail = false;
 			dev_info(&pdev->dev, "Hyp log service not support\n");
 		}
 	} else {
@@ -1895,8 +1883,10 @@ static int tz_log_probe(struct platform_device *pdev)
 
 	/* Init for tme log */
 	ret = tzdbg_init_tme_log(pdev, virt_iobase);
-	if (ret < 0)
+	if (ret < 0) {
+		tzdbg.stat[TZDBG_TME_LOG].avail = false;
 		pr_warn("Tme log initialization failed!\n");
+	}
 
 	/* register unencrypted qsee log buffer */
 	ret = tzdbg_register_qsee_log_buf(pdev);