Commit 183b6413 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

thermal: netlink: Use for_each_trip() in thermal_genl_cmd_tz_get_trip()

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: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: default avatarLukasz Luba <lukasz.luba@arm.com>
parent 2e3e7dad
...@@ -450,10 +450,10 @@ static int thermal_genl_cmd_tz_get_id(struct param *p) ...@@ -450,10 +450,10 @@ static int thermal_genl_cmd_tz_get_id(struct param *p)
static int thermal_genl_cmd_tz_get_trip(struct param *p) static int thermal_genl_cmd_tz_get_trip(struct param *p)
{ {
struct sk_buff *msg = p->msg; struct sk_buff *msg = p->msg;
const struct thermal_trip *trip;
struct thermal_zone_device *tz; struct thermal_zone_device *tz;
struct nlattr *start_trip; struct nlattr *start_trip;
struct thermal_trip trip; int id;
int ret, i, id;
if (!p->attrs[THERMAL_GENL_ATTR_TZ_ID]) if (!p->attrs[THERMAL_GENL_ATTR_TZ_ID])
return -EINVAL; return -EINVAL;
...@@ -470,16 +470,12 @@ static int thermal_genl_cmd_tz_get_trip(struct param *p) ...@@ -470,16 +470,12 @@ static int thermal_genl_cmd_tz_get_trip(struct param *p)
mutex_lock(&tz->lock); mutex_lock(&tz->lock);
for (i = 0; i < tz->num_trips; i++) { for_each_trip(tz, trip) {
if (nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_ID,
ret = __thermal_zone_get_trip(tz, i, &trip); thermal_zone_trip_id(tz, trip)) ||
if (ret) nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TYPE, trip->type) ||
goto out_cancel_nest; nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TEMP, trip->temperature) ||
nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_HYST, trip->hysteresis))
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))
goto out_cancel_nest; goto out_cancel_nest;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment