[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240903071957.2577486-1-m.majewski2@samsung.com>
Date: Tue, 3 Sep 2024 09:19:55 +0200
From: Mateusz Majewski <m.majewski2@...sung.com>
To: Daniel Lezcano <daniel.lezcano@...aro.org>
Cc: Mateusz Majewski <m.majewski2@...sung.com>, linux-pm@...r.kernel.org,
linux-samsung-soc@...r.kernel.org, devicetree@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
Bartlomiej Zolnierkiewicz <bzolnier@...il.com>, Krzysztof Kozlowski
<krzk@...nel.org>, "Rafael J. Wysocki" <rafael@...nel.org>, Zhang Rui
<rui.zhang@...el.com>, Lukasz Luba <lukasz.luba@....com>, Rob Herring
<robh@...nel.org>, Conor Dooley <conor+dt@...nel.org>, Alim Akhtar
<alim.akhtar@...sung.com>, Sam Protsenko <semen.protsenko@...aro.org>, Anand
Moon <linux.amoon@...il.com>
Subject: Re: [PATCH v3 3/6] drivers/thermal/exynos: improve
sanitize_temp_error
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
Powered by blists - more mailing lists