Browse Source

msm: camera: csiphy: Remove config counter

Currently config counter is being maintained at improper places
as it is increment at configuration parser and decrease at release
dev IOCTL. There are usecase where configuration can come multiple
times without release dev IOCTL being called, in this case config
counter will be out of sync with operation. Also, config counter
is not being use anywhere in any decision making. This change removes
config counter attributes to reduce the future maintenance and better
code readabiltiy. Also, acquire count is correct check to make decision
whether all device are release or not and with that reason update
correct check in release dev IOCTL.

CRs-Fixed: 2759031
Change-Id: Id0f36bc661ef1ae8070cc8d4fc148409c13e30bc
Signed-off-by: Jigarkumar Zala <[email protected]>
Jigarkumar Zala 5 years ago
parent
commit
5bd4d81525

+ 20 - 21
drivers/cam_sensor_module/cam_csiphy/cam_csiphy_core.c

@@ -63,6 +63,19 @@ int32_t cam_csiphy_get_instance_offset(
 	return i;
 }
 
+static void cam_csiphy_reset_phyconfig_param(struct csiphy_device *csiphy_dev,
+	int32_t index)
+{
+	CAM_DBG(CAM_CSIPHY, "Resetting phyconfig param at index: %d", index);
+	csiphy_dev->csiphy_info[index].lane_cnt = 0;
+	csiphy_dev->csiphy_info[index].lane_assign = 0;
+	csiphy_dev->csiphy_info[index].lane_enable = 0;
+	csiphy_dev->csiphy_info[index].settle_time = 0;
+	csiphy_dev->csiphy_info[index].data_rate = 0;
+	csiphy_dev->csiphy_info[index].secure_mode = 0;
+	csiphy_dev->csiphy_info[index].hdl_data.device_hdl = -1;
+}
+
 void cam_csiphy_query_cap(struct csiphy_device *csiphy_dev,
 	struct cam_csiphy_query_cap *csiphy_cap)
 {
@@ -389,8 +402,6 @@ int32_t cam_cmd_buf_parser(struct csiphy_device *csiphy_dev,
 		cam_csiphy_update_secure_info(csiphy_dev,
 			index);
 
-	csiphy_dev->config_count++;
-
 	CAM_DBG(CAM_CSIPHY,
 		"phy version:%d, phy_idx: %d",
 		csiphy_dev->hw_version,
@@ -411,13 +422,7 @@ int32_t cam_cmd_buf_parser(struct csiphy_device *csiphy_dev,
 	return rc;
 
 reset_settings:
-	csiphy_dev->csiphy_info[index].lane_cnt = 0;
-	csiphy_dev->csiphy_info[index].lane_assign = 0;
-	csiphy_dev->csiphy_info[index].lane_enable = 0;
-	csiphy_dev->csiphy_info[index].settle_time = 0;
-	csiphy_dev->csiphy_info[index].data_rate = 0;
-	csiphy_dev->csiphy_info[index].secure_mode = 0;
-	csiphy_dev->csiphy_info[index].hdl_data.device_hdl = -1;
+	cam_csiphy_reset_phyconfig_param(csiphy_dev, index);
 
 	return rc;
 }
@@ -881,9 +886,7 @@ void cam_csiphy_shutdown(struct csiphy_device *csiphy_dev)
 			csiphy_dev->csiphy_info[i].secure_mode =
 				CAM_SECURE_MODE_NON_SECURE;
 
-			csiphy_dev->csiphy_info[i].csiphy_cpas_cp_reg_mask = 0;
-			csiphy_dev->csiphy_info[i].settle_time = 0;
-			csiphy_dev->csiphy_info[i].data_rate = 0;
+			cam_csiphy_reset_phyconfig_param(csiphy_dev, i);
 		}
 
 		cam_csiphy_reset(csiphy_dev);
@@ -1258,24 +1261,20 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
 		csiphy_dev->csiphy_info[offset].hdl_data.device_hdl = -1;
 		csiphy_dev->csiphy_info[offset].hdl_data.session_hdl = -1;
 
-		csiphy_dev->config_count--;
+		cam_csiphy_reset_phyconfig_param(csiphy_dev, offset);
+
 		if (csiphy_dev->acquire_count) {
 			csiphy_dev->acquire_count--;
 			CAM_DBG(CAM_CSIPHY, "Acquire_cnt: %d",
 				csiphy_dev->acquire_count);
 		}
 
-		if (csiphy_dev->start_dev_count == 0) {
+		if (csiphy_dev->acquire_count == 0) {
 			CAM_DBG(CAM_CSIPHY, "All PHY devices released");
-			csiphy_dev->csiphy_state = CAM_CSIPHY_INIT;
-		}
-		if (csiphy_dev->config_count == 0) {
-			CAM_DBG(CAM_CSIPHY, "reset csiphy_info");
-			csiphy_dev->csiphy_info[offset].lane_cnt = 0;
-			csiphy_dev->csiphy_info[offset].lane_assign = 0;
-			csiphy_dev->csiphy_info[offset].csiphy_3phase = -1;
 			csiphy_dev->combo_mode = 0;
+			csiphy_dev->csiphy_state = CAM_CSIPHY_INIT;
 		}
+
 		break;
 	}
 	case CAM_CONFIG_DEV: {

+ 0 - 2
drivers/cam_sensor_module/cam_csiphy/cam_csiphy_dev.h

@@ -268,7 +268,6 @@ struct cam_csiphy_param {
  * @start_dev_count:            Start count
  * @soc_info:                   SOC information
  * @cpas_handle:                CPAS handle
- * @config_count:               Config reg count
  * @current_data_rate:          Data rate in mbps
  * @csiphy_3phase:              To identify DPHY or CPHY at top level
  * @combo_mode:                 Info regarding combo_mode is enable / disable
@@ -298,7 +297,6 @@ struct csiphy_device {
 	uint32_t                       start_dev_count;
 	struct cam_hw_soc_info         soc_info;
 	uint32_t                       cpas_handle;
-	uint32_t                       config_count;
 	uint64_t                       current_data_rate;
 	uint64_t                       csiphy_cpas_cp_reg_mask[
 					CSIPHY_MAX_INSTANCES_PER_PHY];