msm: camera: utils: Restructure register address validation
On current scheme, we put validation inside IO function, it's hard to block subsequent accessing when facing invalid address and may increase the number of cycles to do the register accessing as well. This change limits the validation to only for the reg dump, we can take following up operations when accessing wrong address for read rather than printing uncertain logs. CRs-Fixed: 3589725 Change-Id: I7d38a3ddb6c3f8e2915070f3c24629754abf76d7 Signed-off-by: Stark Lin <quic_starlin@quicinc.com> (cherry picked from commit 159f8889a51178a92186e66e24e39bfdb01e87ee)
This commit is contained in:

committad av
Sridhar Gujje

förälder
832696032c
incheckning
314f7dce36
@@ -667,38 +667,6 @@ int cam_soc_util_regulator_disable(struct regulator *rgltr,
|
||||
uint32_t rgltr_min_volt, uint32_t rgltr_max_volt,
|
||||
uint32_t rgltr_op_mode, uint32_t rgltr_delay);
|
||||
|
||||
/**
|
||||
* cam_soc_util_reg_addr_validation()
|
||||
*
|
||||
* @brief: Camera SOC util for validating address to be accessed
|
||||
*
|
||||
* @soc_info: Device soc information
|
||||
* @base_index: Index of register space in the HW block
|
||||
* @offset: Register offset
|
||||
*
|
||||
* @return: 0 or specific error code
|
||||
*/
|
||||
static inline int cam_soc_util_reg_addr_validation(
|
||||
struct cam_hw_soc_info *soc_info,
|
||||
uint32_t base_idx, uint32_t offset)
|
||||
{
|
||||
if (offset > (uint32_t)soc_info->reg_map[base_idx].size) {
|
||||
CAM_ERR(CAM_UTIL,
|
||||
"Reg offset out of range, offset: 0x%X reg_map size: 0x%X",
|
||||
offset,
|
||||
(uint32_t)soc_info->reg_map[base_idx].size);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (offset % 4) {
|
||||
CAM_ERR(CAM_UTIL, "Offset: 0x%X is not memory aligned",
|
||||
offset);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* cam_soc_util_w()
|
||||
*
|
||||
@@ -718,10 +686,6 @@ static inline int cam_soc_util_w(struct cam_hw_soc_info *soc_info,
|
||||
CAM_ERR(CAM_UTIL, "No valid mapped starting address found");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (cam_soc_util_reg_addr_validation(soc_info, base_index, offset))
|
||||
return -EINVAL;
|
||||
|
||||
return cam_io_w(data,
|
||||
CAM_SOC_GET_REG_MAP_START(soc_info, base_index) + offset);
|
||||
}
|
||||
@@ -748,10 +712,6 @@ static inline int cam_soc_util_w_mb(struct cam_hw_soc_info *soc_info,
|
||||
CAM_ERR(CAM_UTIL, "No valid mapped starting address found");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (cam_soc_util_reg_addr_validation(soc_info, base_index, offset))
|
||||
return -EINVAL;
|
||||
|
||||
return cam_io_w_mb(data,
|
||||
CAM_SOC_GET_REG_MAP_START(soc_info, base_index) + offset);
|
||||
}
|
||||
@@ -774,10 +734,6 @@ static inline uint32_t cam_soc_util_r(struct cam_hw_soc_info *soc_info,
|
||||
CAM_ERR(CAM_UTIL, "No valid mapped starting address found");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (cam_soc_util_reg_addr_validation(soc_info, base_index, offset))
|
||||
return 0;
|
||||
|
||||
return cam_io_r(
|
||||
CAM_SOC_GET_REG_MAP_START(soc_info, base_index) + offset);
|
||||
}
|
||||
@@ -803,10 +759,6 @@ static inline uint32_t cam_soc_util_r_mb(struct cam_hw_soc_info *soc_info,
|
||||
CAM_ERR(CAM_UTIL, "No valid mapped starting address found");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (cam_soc_util_reg_addr_validation(soc_info, base_index, offset))
|
||||
return 0;
|
||||
|
||||
return cam_io_r_mb(
|
||||
CAM_SOC_GET_REG_MAP_START(soc_info, base_index) + offset);
|
||||
}
|
||||
|
Referens i nytt ärende
Block a user