linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
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>,
	Geert Uytterhoeven <geert@linux-m68k.org>
Subject: Re: [PATCH v1 13/14] thermal: trip: Replace thermal_zone_get_num_trips()
Date: Mon, 17 Jun 2024 20:39:49 +0200	[thread overview]
Message-ID: <20240617183949.GO382677@ragnatech.se> (raw)
In-Reply-To: <3312460.oiGErgHkdL@kreacher>

Hi Rafael,

Thanks for your patch.

On 2024-06-17 20:11:30 +0200, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> The only existing caller of thermal_zone_get_num_trips(), which is
> rcar_gen3_thermal_probe(), uses this function to check whether or
> not the number of trips in the given thermal zone is nonzero.
> 
> Because it really only needs to know whether or not the given
> thermal zone is tripless, replace thermal_zone_get_num_trips() with
> thermal_zone_is_tripless() that can tell rcar_gen3_thermal_probe()
> exactly what it needs to know and make it call that function.
> 
> No intentional functional impact.
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>  drivers/thermal/renesas/rcar_gen3_thermal.c |    3 +--
>  drivers/thermal/thermal_trip.c              |    6 +++---
>  include/linux/thermal.h                     |    2 +-
>  3 files changed, 5 insertions(+), 6 deletions(-)
> 
> Index: linux-pm/drivers/thermal/renesas/rcar_gen3_thermal.c
> ===================================================================
> --- linux-pm.orig/drivers/thermal/renesas/rcar_gen3_thermal.c
> +++ linux-pm/drivers/thermal/renesas/rcar_gen3_thermal.c
> @@ -563,8 +563,7 @@ static int rcar_gen3_thermal_probe(struc
>  		if (ret)
>  			goto error_unregister;
>  
> -		ret = thermal_zone_get_num_trips(tsc->zone);
> -		if (ret < 0)
> +		if (thermal_zone_is_tripless(tsc->zone))

There are two issues with this change.

1. The original code only jumped to error_unregister if there where a 
   negative number of trip points, presumably to allow for an error to 
   be returned when reading the number of trip points.

   If an negative error was found it was stored in ret, and this was 
   then returned from the probe function after jumping to 
   error_unregister. This change jumps to the error out path, but do not 
   fail probe.

   However it is valid to complete probe without any trip points found.  
   So failing probe on thermal_zone_is_tripless() is not desired.

2. The value returned from thermal_zone_get_num_trips() and stored in 
   ret is used in a dev_info() below, logging how many trip points (if 
   any) where found.

   With this change that is no longer true and it will always log 0 trip 
   points found.

As there is no long (if there ever where) a reason to check for errors 
when reading the number of trip points, and no real use to log the 
number of trip points found maybe a modified patch can do what you want 
(not tested).

- ret = thermal_zone_get_num_trips(tsc->zone);
- if (ret < 0)
-    goto error_unregister;
-
- dev_info(dev, "Sensor %u: Loaded %d trip points\n", i, ret);
+ dev_info(dev, "Sensor %u: Loaded %s trip points\n", i,
+       thermal_zone_is_tripless(tsc->zone) ? "with" : "without");

What do you think?

>  			goto error_unregister;
>  
>  		dev_info(dev, "Sensor %u: Loaded %d trip points\n", i, ret);
> Index: linux-pm/drivers/thermal/thermal_trip.c
> ===================================================================
> --- linux-pm.orig/drivers/thermal/thermal_trip.c
> +++ linux-pm/drivers/thermal/thermal_trip.c
> @@ -55,11 +55,11 @@ int thermal_zone_for_each_trip(struct th
>  }
>  EXPORT_SYMBOL_GPL(thermal_zone_for_each_trip);
>  
> -int thermal_zone_get_num_trips(struct thermal_zone_device *tz)
> +bool thermal_zone_is_tripless(struct thermal_zone_device *tz)
>  {
> -	return tz->num_trips;
> +	return tz->num_trips == 0;
>  }
> -EXPORT_SYMBOL_GPL(thermal_zone_get_num_trips);
> +EXPORT_SYMBOL_GPL(thermal_zone_is_tripless);
>  
>  /**
>   * thermal_zone_set_trips - Computes the next trip points for the driver
> Index: linux-pm/include/linux/thermal.h
> ===================================================================
> --- linux-pm.orig/include/linux/thermal.h
> +++ linux-pm/include/linux/thermal.h
> @@ -210,7 +210,7 @@ int for_each_thermal_trip(struct thermal
>  int thermal_zone_for_each_trip(struct thermal_zone_device *tz,
>  			       int (*cb)(struct thermal_trip *, void *),
>  			       void *data);
> -int thermal_zone_get_num_trips(struct thermal_zone_device *tz);
> +bool thermal_zone_is_tripless(struct thermal_zone_device *tz);
>  void thermal_zone_set_trip_temp(struct thermal_zone_device *tz,
>  				struct thermal_trip *trip, int temp);
>  
> 
> 
> 

-- 
Kind Regards,
Niklas Söderlund

  reply	other threads:[~2024-06-17 18:39 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
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 [this message]
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=20240617183949.GO382677@ragnatech.se \
    --to=niklas.soderlund+renesas@ragnatech.se \
    --cc=daniel.lezcano@linaro.org \
    --cc=geert@linux-m68k.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --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;
as well as URLs for NNTP newsgroup(s).