Browse Source

msm: camera: icp: Protect a5 init/deinit calls

Protect a5 init/deinit calls to avoid wrong power up/power down
operations.

CRs-Fixed: 2841729
Change-Id: Ie574bd8b500969704b6dd6834f44625b4effbad3
Signed-off-by: Karthik Anantha Ram <[email protected]>
Karthik Anantha Ram 4 years ago
parent
commit
1c49642a1f
1 changed files with 15 additions and 1 deletions
  1. 15 1
      drivers/cam_icp/icp_hw/a5_hw/a5_core.c

+ 15 - 1
drivers/cam_icp/icp_hw/a5_hw/a5_core.c

@@ -203,6 +203,13 @@ int cam_a5_init_hw(void *device_priv,
 		return -EINVAL;
 	}
 
+	spin_lock_irqsave(&a5_dev->hw_lock, flags);
+	if (a5_dev->hw_state == CAM_HW_STATE_POWER_UP) {
+		spin_unlock_irqrestore(&a5_dev->hw_lock, flags);
+		return 0;
+	}
+	spin_unlock_irqrestore(&a5_dev->hw_lock, flags);
+
 	a5_soc_info = soc_info->soc_private;
 
 	cpas_vote.ahb_vote.type = CAM_VOTE_ABSOLUTE;
@@ -277,7 +284,10 @@ int cam_a5_deinit_hw(void *device_priv,
 	}
 
 	spin_lock_irqsave(&a5_dev->hw_lock, flags);
-	a5_dev->hw_state = CAM_HW_STATE_POWER_DOWN;
+	if (a5_dev->hw_state == CAM_HW_STATE_POWER_DOWN) {
+		spin_unlock_irqrestore(&a5_dev->hw_lock, flags);
+		return 0;
+	}
 	spin_unlock_irqrestore(&a5_dev->hw_lock, flags);
 
 	rc = cam_a5_disable_soc_resources(soc_info);
@@ -291,6 +301,10 @@ int cam_a5_deinit_hw(void *device_priv,
 			core_info->cpas_start = false;
 	}
 
+	spin_lock_irqsave(&a5_dev->hw_lock, flags);
+	a5_dev->hw_state = CAM_HW_STATE_POWER_DOWN;
+	spin_unlock_irqrestore(&a5_dev->hw_lock, flags);
+
 	return rc;
 }