LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/3] thermal: Use for_each_trip() in some places
@ 2023-12-04 19:38 Rafael J. Wysocki
  2023-12-04 19:41 ` [PATCH v1 1/3] thermal: trip: Use for_each_trip() in __thermal_zone_set_trips() Rafael J. Wysocki
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Rafael J. Wysocki @ 2023-12-04 19:38 UTC (permalink / raw
  To: Daniel Lezcano, Lukasz Luba
  Cc: Linux PM, LKML, Srinivas Pandruvada, Zhang Rui

Hi,

This series changes the code to use the for_each_trip() macro in a few
places instead of open-coded loops over trip indices.

Thanks!





^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v1 1/3] thermal: trip: Use for_each_trip() in __thermal_zone_set_trips()
  2023-12-04 19:38 [PATCH v1 0/3] thermal: Use for_each_trip() in some places Rafael J. Wysocki
@ 2023-12-04 19:41 ` Rafael J. Wysocki
  2023-12-13 10:23   ` Daniel Lezcano
  2023-12-04 19:46 ` [PATCH v1 2/3] thermal: helpers: Use for_each_trip() in __thermal_zone_get_temp() Rafael J. Wysocki
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Rafael J. Wysocki @ 2023-12-04 19:41 UTC (permalink / raw
  To: Daniel Lezcano, Lukasz Luba
  Cc: Linux PM, LKML, Srinivas Pandruvada, Zhang Rui

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Make __thermal_zone_set_trips() use for_each_trip() instead of an open-
coded loop over trip indices.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/thermal/thermal_trip.c |   18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

Index: linux-pm/drivers/thermal/thermal_trip.c
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_trip.c
+++ linux-pm/drivers/thermal/thermal_trip.c
@@ -63,25 +63,21 @@ EXPORT_SYMBOL_GPL(thermal_zone_get_num_t
  */
 void __thermal_zone_set_trips(struct thermal_zone_device *tz)
 {
-	struct thermal_trip trip;
+	const struct thermal_trip *trip;
 	int low = -INT_MAX, high = INT_MAX;
 	bool same_trip = false;
-	int i, ret;
+	int ret;
 
 	lockdep_assert_held(&tz->lock);
 
 	if (!tz->ops->set_trips)
 		return;
 
-	for (i = 0; i < tz->num_trips; i++) {
+	for_each_trip(tz, trip) {
 		bool low_set = false;
 		int trip_low;
 
-		ret = __thermal_zone_get_trip(tz, i , &trip);
-		if (ret)
-			return;
-
-		trip_low = trip.temperature - trip.hysteresis;
+		trip_low = trip->temperature - trip->hysteresis;
 
 		if (trip_low < tz->temperature && trip_low > low) {
 			low = trip_low;
@@ -89,9 +85,9 @@ void __thermal_zone_set_trips(struct the
 			same_trip = false;
 		}
 
-		if (trip.temperature > tz->temperature &&
-		    trip.temperature < high) {
-			high = trip.temperature;
+		if (trip->temperature > tz->temperature &&
+		    trip->temperature < high) {
+			high = trip->temperature;
 			same_trip = low_set;
 		}
 	}




^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v1 2/3] thermal: helpers: Use for_each_trip() in __thermal_zone_get_temp()
  2023-12-04 19:38 [PATCH v1 0/3] thermal: Use for_each_trip() in some places Rafael J. Wysocki
  2023-12-04 19:41 ` [PATCH v1 1/3] thermal: trip: Use for_each_trip() in __thermal_zone_set_trips() Rafael J. Wysocki
@ 2023-12-04 19:46 ` Rafael J. Wysocki
  2023-12-13 10:24   ` Daniel Lezcano
  2023-12-04 19:49 ` [PATCH v1 3/3] thermal: netlink: Use for_each_trip() in thermal_genl_cmd_tz_get_trip() Rafael J. Wysocki
  2023-12-12 18:59 ` [PATCH v1 0/3] thermal: Use for_each_trip() in some places Rafael J. Wysocki
  3 siblings, 1 reply; 9+ messages in thread
From: Rafael J. Wysocki @ 2023-12-04 19:46 UTC (permalink / raw
  To: Daniel Lezcano, Lukasz Luba
  Cc: Linux PM, LKML, Srinivas Pandruvada, Zhang Rui

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Make __thermal_zone_get_temp() use for_each_trip() instead of an open-
coded loop over trip indices.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/thermal/thermal_helpers.c |   12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Index: linux-pm/drivers/thermal/thermal_helpers.c
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_helpers.c
+++ linux-pm/drivers/thermal/thermal_helpers.c
@@ -82,20 +82,18 @@ EXPORT_SYMBOL(get_thermal_instance);
  */
 int __thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
 {
-	int ret = -EINVAL;
-	int count;
+	const struct thermal_trip *trip;
 	int crit_temp = INT_MAX;
-	struct thermal_trip trip;
+	int ret = -EINVAL;
 
 	lockdep_assert_held(&tz->lock);
 
 	ret = tz->ops->get_temp(tz, temp);
 
 	if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) {
-		for (count = 0; count < tz->num_trips; count++) {
-			ret = __thermal_zone_get_trip(tz, count, &trip);
-			if (!ret && trip.type == THERMAL_TRIP_CRITICAL) {
-				crit_temp = trip.temperature;
+		for_each_trip(tz, trip) {
+			if (trip->type == THERMAL_TRIP_CRITICAL) {
+				crit_temp = trip->temperature;
 				break;
 			}
 		}




^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v1 3/3] thermal: netlink: Use for_each_trip() in thermal_genl_cmd_tz_get_trip()
  2023-12-04 19:38 [PATCH v1 0/3] thermal: Use for_each_trip() in some places Rafael J. Wysocki
  2023-12-04 19:41 ` [PATCH v1 1/3] thermal: trip: Use for_each_trip() in __thermal_zone_set_trips() Rafael J. Wysocki
  2023-12-04 19:46 ` [PATCH v1 2/3] thermal: helpers: Use for_each_trip() in __thermal_zone_get_temp() Rafael J. Wysocki
@ 2023-12-04 19:49 ` Rafael J. Wysocki
  2023-12-13 10:25   ` Daniel Lezcano
  2023-12-12 18:59 ` [PATCH v1 0/3] thermal: Use for_each_trip() in some places Rafael J. Wysocki
  3 siblings, 1 reply; 9+ messages in thread
From: Rafael J. Wysocki @ 2023-12-04 19:49 UTC (permalink / raw
  To: Daniel Lezcano, Lukasz Luba
  Cc: Linux PM, LKML, Srinivas Pandruvada, Zhang Rui

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Make thermal_genl_cmd_tz_get_trip() use for_each_trip() instead of an open-
coded loop over trip indices.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/thermal/thermal_netlink.c |   20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

Index: linux-pm/drivers/thermal/thermal_netlink.c
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_netlink.c
+++ linux-pm/drivers/thermal/thermal_netlink.c
@@ -450,10 +450,10 @@ out_cancel_nest:
 static int thermal_genl_cmd_tz_get_trip(struct param *p)
 {
 	struct sk_buff *msg = p->msg;
+	const struct thermal_trip *trip;
 	struct thermal_zone_device *tz;
 	struct nlattr *start_trip;
-	struct thermal_trip trip;
-	int ret, i, id;
+	int id;
 
 	if (!p->attrs[THERMAL_GENL_ATTR_TZ_ID])
 		return -EINVAL;
@@ -470,16 +470,12 @@ static int thermal_genl_cmd_tz_get_trip(
 
 	mutex_lock(&tz->lock);
 
-	for (i = 0; i < tz->num_trips; i++) {
-
-		ret = __thermal_zone_get_trip(tz, i, &trip);
-		if (ret)
-			goto out_cancel_nest;
-
-		if (nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_ID, i) ||
-		    nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TYPE, trip.type) ||
-		    nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TEMP, trip.temperature) ||
-		    nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_HYST, trip.hysteresis))
+	for_each_trip(tz, trip) {
+		if (nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_ID,
+				thermal_zone_trip_id(tz, trip)) ||
+		    nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TYPE, trip->type) ||
+		    nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TEMP, trip->temperature) ||
+		    nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_HYST, trip->hysteresis))
 			goto out_cancel_nest;
 	}
 




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 0/3] thermal: Use for_each_trip() in some places
  2023-12-04 19:38 [PATCH v1 0/3] thermal: Use for_each_trip() in some places Rafael J. Wysocki
                   ` (2 preceding siblings ...)
  2023-12-04 19:49 ` [PATCH v1 3/3] thermal: netlink: Use for_each_trip() in thermal_genl_cmd_tz_get_trip() Rafael J. Wysocki
@ 2023-12-12 18:59 ` Rafael J. Wysocki
  2023-12-13  8:43   ` Lukasz Luba
  3 siblings, 1 reply; 9+ messages in thread
From: Rafael J. Wysocki @ 2023-12-12 18:59 UTC (permalink / raw
  To: Linux PM
  Cc: Daniel Lezcano, Lukasz Luba, LKML, Srinivas Pandruvada, Zhang Rui

On Mon, Dec 4, 2023 at 8:49 PM Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
>
> Hi,
>
> This series changes the code to use the for_each_trip() macro in a few
> places instead of open-coded loops over trip indices.

From the lack of comments I gather that the changes in this series are
fine with everyone, so I'm going to queue it up for 6.8.

Thanks!

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 0/3] thermal: Use for_each_trip() in some places
  2023-12-12 18:59 ` [PATCH v1 0/3] thermal: Use for_each_trip() in some places Rafael J. Wysocki
@ 2023-12-13  8:43   ` Lukasz Luba
  0 siblings, 0 replies; 9+ messages in thread
From: Lukasz Luba @ 2023-12-13  8:43 UTC (permalink / raw
  To: Rafael J. Wysocki
  Cc: Daniel Lezcano, LKML, Srinivas Pandruvada, Zhang Rui, Linux PM

Hi Rafael,

On 12/12/23 18:59, Rafael J. Wysocki wrote:
> On Mon, Dec 4, 2023 at 8:49 PM Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
>>
>> Hi,
>>
>> This series changes the code to use the for_each_trip() macro in a few
>> places instead of open-coded loops over trip indices.
> 
>  From the lack of comments I gather that the changes in this series are
> fine with everyone, so I'm going to queue it up for 6.8.
> 
> Thanks!
> 

Somehow I missed that series. Although, I've checked them today
and LGTM. So feel free to add my tag to thepatches if it's not too late:

Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>

Regards,
Lukasz

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 1/3] thermal: trip: Use for_each_trip() in __thermal_zone_set_trips()
  2023-12-04 19:41 ` [PATCH v1 1/3] thermal: trip: Use for_each_trip() in __thermal_zone_set_trips() Rafael J. Wysocki
@ 2023-12-13 10:23   ` Daniel Lezcano
  0 siblings, 0 replies; 9+ messages in thread
From: Daniel Lezcano @ 2023-12-13 10:23 UTC (permalink / raw
  To: Rafael J. Wysocki, Lukasz Luba
  Cc: Linux PM, LKML, Srinivas Pandruvada, Zhang Rui

On 04/12/2023 20:41, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> Make __thermal_zone_set_trips() use for_each_trip() instead of an open-
> coded loop over trip indices.
> 
> No intentional functional impact.
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---

Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>


-- 
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 2/3] thermal: helpers: Use for_each_trip() in __thermal_zone_get_temp()
  2023-12-04 19:46 ` [PATCH v1 2/3] thermal: helpers: Use for_each_trip() in __thermal_zone_get_temp() Rafael J. Wysocki
@ 2023-12-13 10:24   ` Daniel Lezcano
  0 siblings, 0 replies; 9+ messages in thread
From: Daniel Lezcano @ 2023-12-13 10:24 UTC (permalink / raw
  To: Rafael J. Wysocki, Lukasz Luba
  Cc: Linux PM, LKML, Srinivas Pandruvada, Zhang Rui

On 04/12/2023 20:46, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> Make __thermal_zone_get_temp() use for_each_trip() instead of an open-
> coded loop over trip indices.
> 
> No intentional functional impact.
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---

Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>


-- 
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 3/3] thermal: netlink: Use for_each_trip() in thermal_genl_cmd_tz_get_trip()
  2023-12-04 19:49 ` [PATCH v1 3/3] thermal: netlink: Use for_each_trip() in thermal_genl_cmd_tz_get_trip() Rafael J. Wysocki
@ 2023-12-13 10:25   ` Daniel Lezcano
  0 siblings, 0 replies; 9+ messages in thread
From: Daniel Lezcano @ 2023-12-13 10:25 UTC (permalink / raw
  To: Rafael J. Wysocki, Lukasz Luba
  Cc: Linux PM, LKML, Srinivas Pandruvada, Zhang Rui

On 04/12/2023 20:49, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> Make thermal_genl_cmd_tz_get_trip() use for_each_trip() instead of an open-
> coded loop over trip indices.
> 
> No intentional functional impact.
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---

Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>

-- 
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-12-13 10:25 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-04 19:38 [PATCH v1 0/3] thermal: Use for_each_trip() in some places Rafael J. Wysocki
2023-12-04 19:41 ` [PATCH v1 1/3] thermal: trip: Use for_each_trip() in __thermal_zone_set_trips() Rafael J. Wysocki
2023-12-13 10:23   ` Daniel Lezcano
2023-12-04 19:46 ` [PATCH v1 2/3] thermal: helpers: Use for_each_trip() in __thermal_zone_get_temp() Rafael J. Wysocki
2023-12-13 10:24   ` Daniel Lezcano
2023-12-04 19:49 ` [PATCH v1 3/3] thermal: netlink: Use for_each_trip() in thermal_genl_cmd_tz_get_trip() Rafael J. Wysocki
2023-12-13 10:25   ` Daniel Lezcano
2023-12-12 18:59 ` [PATCH v1 0/3] thermal: Use for_each_trip() in some places Rafael J. Wysocki
2023-12-13  8:43   ` Lukasz Luba

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 read-only IMAP folder(s) and NNTP newsgroup(s).