thermal: Use for_each_trip() in some places
cover thermal: Use for_each_trip() in some places
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!
PATCH 1/3 thermal: trip: Use for_each_trip() in __thermal_zone_set_trips()
From: Rafael J. Wysocki <[email protected]>
Make __thermal_zone_set_trips() use for_each_trip() instead of an open- coded loop over trip indices.
No intentional functional impact.
--- drivers/thermal/thermal_trip.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
drivers/thermal/thermal_trip.c +7 -11
@@ -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; } }
Re: [PATCH v1 1/3] thermal: trip: Use for_each_trip() in __thermal_zone_set_trips()
Quoted 9 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Make
__thermal_zone_set_trips()usefor_each_trip()instead of an open- coded loop over trip indices.No intentional functional impact.
Signed-off-by Rafael J. Wysocki <[email protected]>---
Signature · 5 lines
<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
PATCH 2/3 thermal: helpers: Use for_each_trip() in __thermal_zone_get_temp()
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Make __thermal_zone_get_temp() use for_each_trip() instead of an open- coded loop over trip indices.
No intentional functional impact.
--- drivers/thermal/thermal_helpers.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/thermal/thermal_helpers.c +5 -7
@@ -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 ; } }
Re: [PATCH v1 2/3] thermal: helpers: Use for_each_trip() in __thermal_zone_get_temp()
Quoted 9 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Make
__thermal_zone_get_temp()usefor_each_trip()instead of an open- coded loop over trip indices.No intentional functional impact.
Signed-off-by Rafael J. Wysocki <[email protected]>---
Signature · 5 lines
<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
PATCH 3/3 thermal: netlink: Use for_each_trip() in thermal_genl_cmd_tz_get_trip()
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Make thermal_genl_cmd_tz_get_trip() use for_each_trip() instead of an open- coded loop over trip indices.
No intentional functional impact.
--- drivers/thermal/thermal_netlink.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)
drivers/thermal/thermal_netlink.c +8 -12
@@ -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; }
Re: [PATCH v1 3/3] thermal: netlink: Use for_each_trip() in thermal_genl_cmd_tz_get_trip()
Quoted 9 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Make
thermal_genl_cmd_tz_get_trip()usefor_each_trip()instead of an open- coded loop over trip indices.No intentional functional impact.
Signed-off-by Rafael J. Wysocki <[email protected]>---
Signature · 5 lines
<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
Rafael J. Wysocki
maintainerQuoted 5 lines · Rafael J. Wysocki
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!
Hi Rafael,
Quoted 4 lines · Rafael J. Wysocki
Quoted 3 lines · Rafael J. Wysocki
Hi,
Quoted 8 lines
Quoted 2 lines
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:
Regards,
Lukasz