From: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Linux PM <linux-pm@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Lukasz Luba <lukasz.luba@arm.com>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Masami Hiramatsu <mhiramat@kernel.org>
Subject: Re: [PATCH v1 12/14] thermal: uniphier: Use thermal_zone_for_each_trip() for walking trip points
Date: Tue, 18 Jun 2024 13:03:51 +0900 [thread overview]
Message-ID: <e54a7a9b-3fc7-457f-9f30-d6ab3a58c2b0@socionext.com> (raw)
In-Reply-To: <2148114.bB369e8A3T@kreacher>
Hi Rafael,
On 2024/06/18 3:07, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> It is generally inefficient to iterate over trip indices and call
> thermal_zone_get_trip() every time to get the struct thermal_trip
> corresponding to the given trip index, so modify the uniphier thermal
> driver to use thermal_zone_for_each_trip() for walking trips.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> drivers/thermal/uniphier_thermal.c | 37
> +++++++++++++++++++++++--------------
> 1 file changed, 23 insertions(+), 14 deletions(-)
>
> Index: linux-pm/drivers/thermal/uniphier_thermal.c
> ===================================================================
> --- linux-pm.orig/drivers/thermal/uniphier_thermal.c
> +++ linux-pm/drivers/thermal/uniphier_thermal.c
> @@ -239,13 +239,32 @@ static irqreturn_t uniphier_tm_alarm_irq
> return IRQ_HANDLED;
> }
>
> +struct trip_walk_data {
> + struct uniphier_tm_dev *tdev;
> + int crit_temp;
> + int index;
> +};
> +
> +static int uniphier_tm_trip_walk_cb(struct thermal_trip *trip, void *arg)
> +{
> + struct trip_walk_data *twd = arg;
> +
> + if (trip->type == THERMAL_TRIP_CRITICAL &&
> + trip->temperature < twd->crit_temp)
> + twd->crit_temp = trip->temperature;
> +
> + uniphier_tm_set_alert(twd->tdev, twd->index, trip->temperature);
> + twd->tdev->alert_en[twd->index++] = true;
> +}
> +
> static int uniphier_tm_probe(struct platform_device *pdev)
> {
> + struct trip_walk_data twd = { .crit_temp = INT_MAX, .index = 0 };
> struct device *dev = &pdev->dev;
> struct regmap *regmap;
> struct device_node *parent;
> struct uniphier_tm_dev *tdev;
> - int i, ret, irq, crit_temp = INT_MAX;
> + int i, ret, irq;
>
> tdev = devm_kzalloc(dev, sizeof(*tdev), GFP_KERNEL);
> if (!tdev)
> @@ -293,20 +312,10 @@ static int uniphier_tm_probe(struct plat
> }
>
> /* set alert temperatures */
> - for (i = 0; i < thermal_zone_get_num_trips(tdev->tz_dev); i++) {
> - struct thermal_trip trip;
> + twd.tdev = tdev;
> + thermal_zone_for_each_trip(tdev->tz_dev, uniphier_tm_trip_walk_cb, &twd);
>
> - ret = thermal_zone_get_trip(tdev->tz_dev, i, &trip);
> - if (ret)
> - return ret;
> -
> - if (trip.type == THERMAL_TRIP_CRITICAL &&
> - trip.temperature < crit_temp)
> - crit_temp = trip.temperature;
> - uniphier_tm_set_alert(tdev, i, trip.temperature);
> - tdev->alert_en[i] = true;
> - }
> - if (crit_temp > CRITICAL_TEMP_LIMIT) {
> + if (twd.crit_temp > CRITICAL_TEMP_LIMIT) {
> dev_err(dev, "critical trip is over limit(>%d), or not set\n",
> CRITICAL_TEMP_LIMIT);
> return -EINVAL;
I confirmed the updated code using the helper function is equivalent
to the original.
Reviewed-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Thank you,
---
Best Regards
Kunihiko Hayashi
next prev parent reply other threads:[~2024-06-18 4:05 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-17 17:41 [PATCH v1 00/14] thermal: Eliminate trip IDs from thermal driver interface Rafael J. Wysocki
2024-06-17 17:48 ` [PATCH v1 01/14] thermal: imx: Drop critical trip check from imx_set_trip_temp() Rafael J. Wysocki
2024-06-17 17:49 ` [PATCH v1 02/14] thermal: helpers: Introduce thermal_trip_is_bound_to_cdev() Rafael J. Wysocki
2024-06-17 17:56 ` [PATCH v1 03/14] thermal: trip: Add conversion macros for thermal trip priv field Rafael J. Wysocki
2024-06-17 17:56 ` [PATCH v1 04/14] thermal: trip: Pass trip pointer to .set_trip_temp() thermal zone callback Rafael J. Wysocki
2024-06-17 17:56 ` [PATCH v1 05/14] thermal: trip: Fold __thermal_zone_get_trip() into its caller Rafael J. Wysocki
2024-06-17 17:57 ` [PATCH v1 06/14] thermal: broadcom: Use thermal_zone_get_crit_temp() in bcm2835_thermal_probe() Rafael J. Wysocki
2024-06-17 17:58 ` [PATCH v1 07/14] thermal: hisi: Use thermal_zone_for_each_trip() in hisi_thermal_register_sensor() Rafael J. Wysocki
2024-06-17 18:00 ` [PATCH v1 08/14] thermal: qcom: Use thermal_zone_get_crit_temp() in qpnp_tm_init() Rafael J. Wysocki
2024-06-17 18:02 ` [PATCH v1 09/14] thermal: tegra: Introduce struct trip_temps for critical and hot trips Rafael J. Wysocki
2024-06-17 18:03 ` [PATCH v1 10/14] thermal: tegra: Use thermal_zone_for_each_trip() for walking trip points Rafael J. Wysocki
2024-06-17 18:05 ` [PATCH v1 11/14] thermal: helpers: Drop get_thermal_instance() Rafael J. Wysocki
2024-06-17 18:07 ` [PATCH v1 12/14] thermal: uniphier: Use thermal_zone_for_each_trip() for walking trip points Rafael J. Wysocki
2024-06-18 4:03 ` Kunihiko Hayashi [this message]
2024-06-18 13:06 ` Rafael J. Wysocki
2024-06-17 18:11 ` [PATCH v1 13/14] thermal: trip: Replace thermal_zone_get_num_trips() Rafael J. Wysocki
2024-06-17 18:39 ` Niklas Söderlund
2024-06-17 18:55 ` Rafael J. Wysocki
2024-06-17 19:02 ` Rafael J. Wysocki
2024-06-17 18:12 ` [PATCH v1 14/14] thermal: trip: Drop thermal_zone_get_trip() Rafael J. Wysocki
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=e54a7a9b-3fc7-457f-9f30-d6ab3a58c2b0@socionext.com \
--to=hayashi.kunihiko@socionext.com \
--cc=daniel.lezcano@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=mhiramat@kernel.org \
--cc=rafael@kernel.org \
--cc=rjw@rjwysocki.net \
/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
all inboxes | Powered by JetHome®