Hello :)
May I suggest to convert this function to a specific soc ops to be put
in the struct exynos_tmu_data ?
Like this?
static void exynos4210_sanitize_temp_error(struct exynos_tmu_data *data,
u32 trim_info)
{
data->temp_error1 = trim_info & EXYNOS_TMU_TEMP_MASK;
if (!data->temp_error1 ||
(data->min_efuse_value > data->temp_error1) ||
(data->temp_error1 > data->max_efuse_value))
data->temp_error1 = data->efuse_value & EXYNOS_TMU_TEMP_MASK;
WARN_ON_ONCE(data->cal_type == TYPE_TWO_POINT_TRIMMING);
}
static void exynos5433_sanitize_temp_error(struct exynos_tmu_data *data,
u32 trim_info)
{
data->temp_error1 = trim_info & EXYNOS_TMU_TEMP_MASK;
if (!data->temp_error1 ||
(data->min_efuse_value > data->temp_error1) ||
(data->temp_error1 > data->max_efuse_value))
data->temp_error1 = data->efuse_value & EXYNOS_TMU_TEMP_MASK;
if (data->cal_type == TYPE_TWO_POINT_TRIMMING) {
data->temp_error2 = (trim_info >> EXYNOS_TRIMINFO_85_SHIFT) &
EXYNOS_TMU_TEMP_MASK;
if (!data->temp_error2)
data->temp_error2 = (data->efuse_value >>
EXYNOS_TRIMINFO_85_SHIFT) &
EXYNOS_TMU_TEMP_MASK;
}
}
static void exynos7_sanitize_temp_error(struct exynos_tmu_data *data,
u32 trim_info)
{
data->temp_error1 = trim_info & EXYNOS7_TMU_TEMP_MASK;
if (!data->temp_error1 ||
(data->min_efuse_value > data->temp_error1) ||
(data->temp_error1 > data->max_efuse_value))
data->temp_error1 = data->efuse_value & EXYNOS7_TMU_TEMP_MASK;
WARN_ON_ONCE(data->cal_type == TYPE_TWO_POINT_TRIMMING);
}
static void exynos850_sanitize_temp_error(struct exynos_tmu_data *data,
u32 trim_info)
{
data->temp_error1 = trim_info & EXYNOS7_TMU_TEMP_MASK;
if (!data->temp_error1 ||
(data->min_efuse_value > data->temp_error1) ||
(data->temp_error1 > data->max_efuse_value))
data->temp_error1 = data->efuse_value & EXYNOS7_TMU_TEMP_MASK;
if (data->cal_type == TYPE_TWO_POINT_TRIMMING) {
data->temp_error2 = (trim_info >> EXYNOS7_TMU_TEMP_SHIFT) &
EXYNOS7_TMU_TEMP_MASK;
if (!data->temp_error2)
data->temp_error2 = (data->efuse_value >>
EXYNOS7_TMU_TEMP_SHIFT) &
EXYNOS_TMU_TEMP_MASK;
}
}
Or maybe we could put tmu_temp_mask and tmu_85_shift in data instead,
and have one function like this:
static void sanitize_temp_error(struct exynos_tmu_data *data, u32 trim_info)
{
data->temp_error1 = trim_info & data->tmu_temp_mask;
if (!data->temp_error1 || (data->min_efuse_value > data->temp_error1) ||
(data->temp_error1 > data->max_efuse_value))
data->temp_error1 = data->efuse_value & data->tmu_temp_mask;
if (data->cal_type == TYPE_TWO_POINT_TRIMMING) {
data->temp_error2 = (trim_info >> data->tmu_85_shift) &
data->tmu_temp_mask;
if (!data->temp_error2)
data->temp_error2 =
(data->efuse_value >> data->tmu_85_shift) &
data->tmu_temp_mask;
}
}
Thank you,
Mateusz