public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: rafael@kernel.org, Amit Kucheria <amitk@kernel.org>,
	Zhang Rui <rui.zhang@intel.com>,
	"open list:THERMAL" <linux-pm@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] thermal/drivers/armada: Use the thermal_zone_get_crit_temp()
Date: Tue, 24 Jan 2023 12:50:27 +0100	[thread overview]
Message-ID: <20230124125027.2dba0f1a@xps-13> (raw)
In-Reply-To: <4225f833-0f15-5780-5ef4-4cd9e05eca70@linaro.org>

Hi Daniel,

daniel.lezcano@linaro.org wrote on Tue, 24 Jan 2023 12:36:22 +0100:

> On 24/01/2023 12:04, Miquel Raynal wrote:
> > Hi Daniel,
> > 
> > daniel.lezcano@linaro.org wrote on Wed, 18 Jan 2023 23:26:10 +0100:
> >   
> >> The driver browses the trip point to find out the critical trip
> >> temperature. However the function thermal_zone_get_crit_temp() does
> >> already that, so the routine is pointless in the driver.
> >>
> >> Use thermal_zone_get_crit_temp() instead of inspecting all the trip
> >> points.
> >>
> >> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> >> ---
> >>   drivers/thermal/armada_thermal.c | 38 +++++++++++++-------------------
> >>   1 file changed, 15 insertions(+), 23 deletions(-)
> >>
> >> diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
> >> index db040dbdaa0a..c6d51d8acbf0 100644
> >> --- a/drivers/thermal/armada_thermal.c
> >> +++ b/drivers/thermal/armada_thermal.c
> >> @@ -784,34 +784,26 @@ static int armada_configure_overheat_int(struct armada_thermal_priv *priv,
> >>   					 int sensor_id)
> >>   {
> >>   	/* Retrieve the critical trip point to enable the overheat interrupt */
> >> -	struct thermal_trip trip;
> >> +	int temperature;
> >>   	int ret;
> >> -	int i;
> >> -
> >> -	for (i = 0; i < thermal_zone_get_num_trips(tz); i++) {
> >> -
> >> -		ret = thermal_zone_get_trip(tz, i, &trip);
> >> -		if (ret)
> >> -			return ret;
> >> -
> >> -		if (trip.type != THERMAL_TRIP_CRITICAL)
> >> -			continue;
> >> -
> >> -		ret = armada_select_channel(priv, sensor_id);
> >> -		if (ret)
> >> -			return ret;  
> >>   >> -		armada_set_overheat_thresholds(priv, trip.temperature,  
> >> -					       trip.hysteresis);
> >> -		priv->overheat_sensor = tz;
> >> -		priv->interrupt_source = sensor_id;
> >> +	ret = thermal_zone_get_crit_temp(tz, &temperature);
> >> +	if (ret)
> >> +		return ret;  
> >>   >> -		armada_enable_overheat_interrupt(priv);  
> >> +	ret = armada_select_channel(priv, sensor_id);
> >> +	if (ret)
> >> +		return ret;  
> >>   >> -		return 0;  
> >> -	}
> >> +	/*
> >> +	 * A critical temperature does not have a hysteresis
> >> +	 */  
> > 
> > Makes sense.
> > 
> > Nit: I would actually put that comment in the commit log rather than
> > keeping it in the code, but whatever, that's a nice simplification.  
> 
> Oh, actually, I added the comment because of the third parameter change for armada_set_overheat_thresholds(..., 0);

Yes, that's why I proposed to mention it in the commit log rather than
in the code. If having no threshold here makes sense (and it does), I
don't see the point in explaining it in a comment. I usually use
comments to explain what could appear strange/unclear when looking at
the code.

Here, while the parameter change is intended and legitimate, I feel
like it is worth justifying, but doing so in the commit logs feels
enough.

But that's minor tbh, so feel free to do it like you prefer.

> >> +	armada_set_overheat_thresholds(priv, temperature, 0);  
> 
> I think it makes sense to keep the comment to clarify why we pass this zero temperature argument.

Thanks,
Miquèl

      reply	other threads:[~2023-01-24 11:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-18 22:26 [PATCH] thermal/drivers/armada: Use the thermal_zone_get_crit_temp() Daniel Lezcano
2023-01-24 11:04 ` Miquel Raynal
2023-01-24 11:31   ` Daniel Lezcano
2023-01-24 11:36   ` Daniel Lezcano
2023-01-24 11:50     ` Miquel Raynal [this message]

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=20230124125027.2dba0f1a@xps-13 \
    --to=miquel.raynal@bootlin.com \
    --cc=amitk@kernel.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=rui.zhang@intel.com \
    /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