The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Mateusz Majewski <m.majewski2@samsung.com>
To: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Mateusz Majewski <m.majewski2@samsung.com>,
	linux-pm@vger.kernel.org, linux-samsung-soc@vger.kernel.org,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Zhang Rui <rui.zhang@intel.com>,
	Lukasz Luba <lukasz.luba@arm.com>, Rob Herring <robh@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Alim Akhtar <alim.akhtar@samsung.com>,
	Sam Protsenko <semen.protsenko@linaro.org>,
	Anand Moon <linux.amoon@gmail.com>
Subject: Re: [PATCH v3 3/6] drivers/thermal/exynos: improve sanitize_temp_error
Date: Tue,  3 Sep 2024 09:19:55 +0200	[thread overview]
Message-ID: <20240903071957.2577486-1-m.majewski2@samsung.com> (raw)
In-Reply-To: <664344db-5a60-46c4-b108-38ca1b4e1a13@linaro.org>

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

  reply	other threads:[~2024-09-03  7:20 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20240807084901eucas1p1feb6a9a89cd6b358380f35f0e3228dfe@eucas1p1.samsung.com>
2024-08-07  8:48 ` [PATCH v3 0/6] Add initial Exynos850 support to the thermal driver Mateusz Majewski
2024-08-07  8:48   ` [PATCH v3 1/6] drivers/thermal/exynos: use DEFINE_SIMPLE_DEV_PM_OPS Mateusz Majewski
2024-08-07  8:48   ` [PATCH v3 2/6] drivers/thermal/exynos: use pm_sleep_ptr instead of conditional compilation Mateusz Majewski
2024-08-07  8:48   ` [PATCH v3 3/6] drivers/thermal/exynos: improve sanitize_temp_error Mateusz Majewski
2024-09-02 12:50     ` Daniel Lezcano
2024-09-03  7:19       ` Mateusz Majewski [this message]
2024-09-06 10:04         ` Daniel Lezcano
2024-08-07  8:48   ` [PATCH v3 4/6] dt-bindings: thermal: samsung,exynos: add exynos850-tmu string Mateusz Majewski
2024-08-11 12:34     ` Krzysztof Kozlowski
2024-08-07  8:48   ` [PATCH v3 5/6] drivers/thermal/exynos: add initial Exynos850 support Mateusz Majewski
2024-08-07  8:48   ` [PATCH v3 6/6] dt-bindings: thermal: samsung,exynos: remove driver-specific information Mateusz Majewski
2024-08-11 12:35     ` Krzysztof Kozlowski
2024-08-12 16:41     ` Rob Herring (Arm)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240903071957.2577486-1-m.majewski2@samsung.com \
    --to=m.majewski2@samsung.com \
    --cc=alim.akhtar@samsung.com \
    --cc=bzolnier@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux.amoon@gmail.com \
    --cc=lukasz.luba@arm.com \
    --cc=rafael@kernel.org \
    --cc=robh@kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=semen.protsenko@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox