From 33899faa8bf40f7ddd7909901f296d6b4115d120 Mon Sep 17 00:00:00 2001 From: Jigarkumar Zala Date: Wed, 14 Oct 2020 21:48:12 -0700 Subject: [PATCH] msm: camera: sensor: Power down in case of cci init failure Currently power down is not happening in case of cci_init failure. This can lead to corruption for the next power up, as power down did not happen for the previous session. This change does power down in case of cci failure and as a part of that it can power up resources correctly in next session. CRs-Fixed: 2797857 Change-Id: I9089222cb45834ae895903a4a3e21dd799beb3ed Signed-off-by: Jigarkumar Zala --- .../cam_sensor_module/cam_actuator/cam_actuator_core.c | 9 ++++++++- drivers/cam_sensor_module/cam_eeprom/cam_eeprom_core.c | 7 ++++++- drivers/cam_sensor_module/cam_ois/cam_ois_core.c | 9 ++++++++- drivers/cam_sensor_module/cam_res_mgr/cam_res_mgr.c | 4 ++-- drivers/cam_sensor_module/cam_sensor/cam_sensor_core.c | 10 +++++++++- 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/drivers/cam_sensor_module/cam_actuator/cam_actuator_core.c b/drivers/cam_sensor_module/cam_actuator/cam_actuator_core.c index 7ee27f9f5764..47a261808873 100644 --- a/drivers/cam_sensor_module/cam_actuator/cam_actuator_core.c +++ b/drivers/cam_sensor_module/cam_actuator/cam_actuator_core.c @@ -106,8 +106,15 @@ static int32_t cam_actuator_power_up(struct cam_actuator_ctrl_t *a_ctrl) } rc = camera_io_init(&a_ctrl->io_master_info); - if (rc < 0) + if (rc < 0) { CAM_ERR(CAM_ACTUATOR, "cci init failed: rc: %d", rc); + goto cci_failure; + } + + return rc; +cci_failure: + if (cam_sensor_util_power_down(power_info, soc_info)) + CAM_ERR(CAM_ACTUATOR, "Power down failure"); return rc; } diff --git a/drivers/cam_sensor_module/cam_eeprom/cam_eeprom_core.c b/drivers/cam_sensor_module/cam_eeprom/cam_eeprom_core.c index 8b9bd2adcb63..8e4270373331 100644 --- a/drivers/cam_sensor_module/cam_eeprom/cam_eeprom_core.c +++ b/drivers/cam_sensor_module/cam_eeprom/cam_eeprom_core.c @@ -185,10 +185,15 @@ static int cam_eeprom_power_up(struct cam_eeprom_ctrl_t *e_ctrl, rc = camera_io_init(&(e_ctrl->io_master_info)); if (rc) { CAM_ERR(CAM_EEPROM, "cci_init failed"); - return -EINVAL; + goto cci_failure; } } return rc; +cci_failure: + if (cam_sensor_util_power_down(power_info, soc_info)) + CAM_ERR(CAM_EEPROM, "Power down failure"); + + return rc; } /** diff --git a/drivers/cam_sensor_module/cam_ois/cam_ois_core.c b/drivers/cam_sensor_module/cam_ois/cam_ois_core.c index 9130d595ed06..543f7a9f3eb2 100644 --- a/drivers/cam_sensor_module/cam_ois/cam_ois_core.c +++ b/drivers/cam_sensor_module/cam_ois/cam_ois_core.c @@ -153,8 +153,15 @@ static int cam_ois_power_up(struct cam_ois_ctrl_t *o_ctrl) } rc = camera_io_init(&o_ctrl->io_master_info); - if (rc) + if (rc) { CAM_ERR(CAM_OIS, "cci_init failed: rc: %d", rc); + goto cci_failure; + } + + return rc; +cci_failure: + if (cam_sensor_util_power_down(power_info, soc_info)) + CAM_ERR(CAM_OIS, "Power Down failed"); return rc; } diff --git a/drivers/cam_sensor_module/cam_res_mgr/cam_res_mgr.c b/drivers/cam_sensor_module/cam_res_mgr/cam_res_mgr.c index c5d6c1504fc8..52e164525244 100644 --- a/drivers/cam_sensor_module/cam_res_mgr/cam_res_mgr.c +++ b/drivers/cam_sensor_module/cam_res_mgr/cam_res_mgr.c @@ -462,8 +462,8 @@ int cam_res_mgr_gpio_request(struct device *dev, uint gpio, CAM_DBG(CAM_RES, "gpio: %u not found in gpio_res list", gpio); rc = gpio_request_one(gpio, flags, label); if (rc) { - CAM_ERR(CAM_RES, "gpio %d:%s request fails", - gpio, label); + CAM_ERR(CAM_RES, "gpio %d:%s request fails rc = %d", + gpio, label, rc); goto end; } } diff --git a/drivers/cam_sensor_module/cam_sensor/cam_sensor_core.c b/drivers/cam_sensor_module/cam_sensor/cam_sensor_core.c index 2f2db1e05281..413b5405045d 100644 --- a/drivers/cam_sensor_module/cam_sensor/cam_sensor_core.c +++ b/drivers/cam_sensor_module/cam_sensor/cam_sensor_core.c @@ -1197,10 +1197,18 @@ int cam_sensor_power_up(struct cam_sensor_ctrl_t *s_ctrl) } rc = camera_io_init(&(s_ctrl->io_master_info)); - if (rc < 0) + if (rc < 0) { CAM_ERR(CAM_SENSOR, "cci_init failed: rc: %d", rc); + goto cci_failure; + } return rc; +cci_failure: + if (cam_sensor_util_power_down(power_info, soc_info)) + CAM_ERR(CAM_SENSOR, "power down failure"); + + return rc; + } int cam_sensor_power_down(struct cam_sensor_ctrl_t *s_ctrl)