msm: camera: common: Update clk_get return check condition
Currently, we are checking the clock struct pointer for NULL returned from clk_get functions. certain critical clocks might have NULL returned for clk pointer, since they are enabled during boot itself. Update return check condition for err only and ignore NULL value and skip its usage. CRs-Fixed: 3296865 Change-Id: I5c1852f2348ae8aeeb0508a2f4a052a8c4f1989e Signed-off-by: Mukund Madhusudan Atre <quic_matre@quicinc.com>
This commit is contained in:

committed by
Camera Software Integration

vanhempi
ffea2d3863
commit
8198f7b8f4
@@ -306,8 +306,14 @@ static void cam_eeprom_i2c_component_unbind(struct device *dev,
|
||||
|
||||
CAM_INFO(CAM_EEPROM, "i2c driver remove invoked");
|
||||
soc_info = &e_ctrl->soc_info;
|
||||
for (i = 0; i < soc_info->num_clk; i++)
|
||||
for (i = 0; i < soc_info->num_clk; i++) {
|
||||
if (!soc_info->clk[i]) {
|
||||
CAM_DBG(CAM_EEPROM, "%s handle is NULL skip put",
|
||||
soc_info->clk_name[i]);
|
||||
continue;
|
||||
}
|
||||
devm_clk_put(soc_info->dev, soc_info->clk[i]);
|
||||
}
|
||||
|
||||
mutex_lock(&(e_ctrl->eeprom_mutex));
|
||||
cam_eeprom_shutdown(e_ctrl);
|
||||
@@ -555,8 +561,14 @@ static void cam_eeprom_component_unbind(struct device *dev,
|
||||
CAM_DBG(CAM_EEPROM, "Component unbind called for: %s", pdev->name);
|
||||
soc_info = &e_ctrl->soc_info;
|
||||
|
||||
for (i = 0; i < soc_info->num_clk; i++)
|
||||
for (i = 0; i < soc_info->num_clk; i++) {
|
||||
if (!soc_info->clk[i]) {
|
||||
CAM_DBG(CAM_EEPROM, "%s handle is NULL skip put",
|
||||
soc_info->clk_name[i]);
|
||||
continue;
|
||||
}
|
||||
devm_clk_put(soc_info->dev, soc_info->clk[i]);
|
||||
}
|
||||
|
||||
mutex_lock(&(e_ctrl->eeprom_mutex));
|
||||
cam_eeprom_shutdown(e_ctrl);
|
||||
|
@@ -381,11 +381,15 @@ int cam_eeprom_parse_dt(struct cam_eeprom_ctrl_t *e_ctrl)
|
||||
for (i = 0; i < soc_info->num_clk; i++) {
|
||||
soc_info->clk[i] = devm_clk_get(soc_info->dev,
|
||||
soc_info->clk_name[i]);
|
||||
if (!soc_info->clk[i]) {
|
||||
if (IS_ERR(soc_info->clk[i])) {
|
||||
CAM_ERR(CAM_EEPROM, "get failed for %s",
|
||||
soc_info->clk_name[i]);
|
||||
rc = -ENOENT;
|
||||
return rc;
|
||||
} else if (!soc_info->clk[i]) {
|
||||
CAM_DBG(CAM_EEPROM, "%s handle is NULL skip get",
|
||||
soc_info->clk_name[i]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -271,8 +271,14 @@ static void cam_ois_i2c_component_unbind(struct device *dev,
|
||||
CAM_INFO(CAM_OIS, "i2c driver remove invoked");
|
||||
soc_info = &o_ctrl->soc_info;
|
||||
|
||||
for (i = 0; i < soc_info->num_clk; i++)
|
||||
for (i = 0; i < soc_info->num_clk; i++) {
|
||||
if (!soc_info->clk[i]) {
|
||||
CAM_DBG(CAM_OIS, "%s handle is NULL skip put",
|
||||
soc_info->clk_name[i]);
|
||||
continue;
|
||||
}
|
||||
devm_clk_put(soc_info->dev, soc_info->clk[i]);
|
||||
}
|
||||
|
||||
mutex_lock(&(o_ctrl->ois_mutex));
|
||||
cam_ois_shutdown(o_ctrl);
|
||||
@@ -429,8 +435,14 @@ static void cam_ois_component_unbind(struct device *dev,
|
||||
|
||||
CAM_INFO(CAM_OIS, "platform driver remove invoked");
|
||||
soc_info = &o_ctrl->soc_info;
|
||||
for (i = 0; i < soc_info->num_clk; i++)
|
||||
for (i = 0; i < soc_info->num_clk; i++) {
|
||||
if (!soc_info->clk[i]) {
|
||||
CAM_DBG(CAM_OIS, "%s handle is NULL skip put",
|
||||
soc_info->clk_name[i]);
|
||||
continue;
|
||||
}
|
||||
devm_clk_put(soc_info->dev, soc_info->clk[i]);
|
||||
}
|
||||
|
||||
mutex_lock(&(o_ctrl->ois_mutex));
|
||||
cam_ois_shutdown(o_ctrl);
|
||||
|
@@ -85,11 +85,15 @@ static int cam_ois_get_dt_data(struct cam_ois_ctrl_t *o_ctrl)
|
||||
for (i = 0; i < soc_info->num_clk; i++) {
|
||||
soc_info->clk[i] = devm_clk_get(soc_info->dev,
|
||||
soc_info->clk_name[i]);
|
||||
if (!soc_info->clk[i]) {
|
||||
CAM_ERR(CAM_SENSOR, "get failed for %s",
|
||||
if (IS_ERR(soc_info->clk[i])) {
|
||||
CAM_ERR(CAM_OIS, "get failed for %s",
|
||||
soc_info->clk_name[i]);
|
||||
rc = -ENOENT;
|
||||
return rc;
|
||||
} else if (!soc_info->clk[i]) {
|
||||
CAM_DBG(CAM_OIS, "%s handle is NULL skip get",
|
||||
soc_info->clk_name[i]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -503,8 +503,14 @@ static void cam_sensor_component_unbind(struct device *dev,
|
||||
mutex_unlock(&(s_ctrl->cam_sensor_mutex));
|
||||
cam_unregister_subdev(&(s_ctrl->v4l2_dev_str));
|
||||
soc_info = &s_ctrl->soc_info;
|
||||
for (i = 0; i < soc_info->num_clk; i++)
|
||||
for (i = 0; i < soc_info->num_clk; i++) {
|
||||
if (!soc_info->clk[i]) {
|
||||
CAM_DBG(CAM_SENSOR, "%s handle is NULL skip put",
|
||||
soc_info->clk_name[i]);
|
||||
continue;
|
||||
}
|
||||
devm_clk_put(soc_info->dev, soc_info->clk[i]);
|
||||
}
|
||||
|
||||
kfree(s_ctrl->i2c_data.per_frame);
|
||||
kfree(s_ctrl->i2c_data.frame_skip);
|
||||
|
@@ -296,11 +296,15 @@ int32_t cam_sensor_parse_dt(struct cam_sensor_ctrl_t *s_ctrl)
|
||||
for (i = 0; i < soc_info->num_clk; i++) {
|
||||
soc_info->clk[i] = devm_clk_get(soc_info->dev,
|
||||
soc_info->clk_name[i]);
|
||||
if (!soc_info->clk[i]) {
|
||||
if (IS_ERR(soc_info->clk[i])) {
|
||||
CAM_ERR(CAM_SENSOR, "get failed for %s",
|
||||
soc_info->clk_name[i]);
|
||||
rc = -ENOENT;
|
||||
return rc;
|
||||
} else if (!soc_info->clk[i]) {
|
||||
CAM_DBG(CAM_SENSOR, "%s handle is NULL skip get",
|
||||
soc_info->clk_name[i]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
/* Initialize regulators to default parameters */
|
||||
|
@@ -875,13 +875,15 @@ static int cam_soc_util_set_clk_rate(struct cam_hw_soc_info *soc_info,
|
||||
long clk_rate_round = -1;
|
||||
bool set_rate = false;
|
||||
|
||||
if (!clk || !clk_name) {
|
||||
if (!clk_name) {
|
||||
CAM_ERR(CAM_UTIL, "Invalid input clk %pK clk_name %pK",
|
||||
clk, clk_name);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
CAM_DBG(CAM_UTIL, "set %s, rate %lld", clk_name, clk_rate);
|
||||
if (!clk)
|
||||
return 0;
|
||||
if (clk_rate > 0) {
|
||||
clk_rate_round = clk_round_rate(clk, clk_rate);
|
||||
CAM_DBG(CAM_UTIL, "new_rate %ld", clk_rate_round);
|
||||
@@ -1231,7 +1233,8 @@ int cam_soc_util_clk_enable(struct cam_hw_soc_info *soc_info,
|
||||
if (clk_idx == soc_info->src_clk_idx)
|
||||
is_src_clk = true;
|
||||
}
|
||||
|
||||
if (!clk)
|
||||
return 0;
|
||||
rc = cam_soc_util_set_clk_rate(soc_info, clk, clk_name, clk_rate,
|
||||
CAM_IS_BIT_SET(shared_clk_mask, clk_idx), is_src_clk, clk_id,
|
||||
applied_clock_rate);
|
||||
@@ -1274,6 +1277,8 @@ int cam_soc_util_clk_disable(struct cam_hw_soc_info *soc_info,
|
||||
}
|
||||
|
||||
CAM_DBG(CAM_UTIL, "disable %s", clk_name);
|
||||
if (!clk)
|
||||
return 0;
|
||||
clk_disable_unprepare(clk);
|
||||
|
||||
if (CAM_IS_BIT_SET(shared_clk_mask, clk_idx)) {
|
||||
@@ -2660,11 +2665,15 @@ int cam_soc_util_request_platform_resource(
|
||||
for (i = 0; i < soc_info->num_clk; i++) {
|
||||
soc_info->clk[i] = clk_get(soc_info->dev,
|
||||
soc_info->clk_name[i]);
|
||||
if (!soc_info->clk[i]) {
|
||||
if (IS_ERR(soc_info->clk[i])) {
|
||||
CAM_ERR(CAM_UTIL, "get failed for %s",
|
||||
soc_info->clk_name[i]);
|
||||
rc = -ENOENT;
|
||||
goto put_clk;
|
||||
} else if (!soc_info->clk[i]) {
|
||||
CAM_DBG(CAM_UTIL, "%s handle is NULL skip get",
|
||||
soc_info->clk_name[i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Create a wrapper entry if this is a shared clock */
|
||||
@@ -2796,7 +2805,11 @@ int cam_soc_util_release_platform_resource(struct cam_hw_soc_info *soc_info)
|
||||
if (CAM_IS_BIT_SET(soc_info->shared_clk_mask, i))
|
||||
cam_soc_util_clk_wrapper_unregister_entry(
|
||||
soc_info->clk_id[i], soc_info);
|
||||
|
||||
if (!soc_info->clk[i]) {
|
||||
CAM_DBG(CAM_UTIL, "%s handle is NULL skip put",
|
||||
soc_info->clk_name[i]);
|
||||
continue;
|
||||
}
|
||||
clk_put(soc_info->clk[i]);
|
||||
soc_info->clk[i] = NULL;
|
||||
}
|
||||
|
Viittaa uudesa ongelmassa
Block a user