Skip to content

Commit 183b641

Browse files
committed
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: Rafael J. Wysocki <[email protected]> Acked-by: Daniel Lezcano <[email protected]> Reviewed-by: Lukasz Luba <[email protected]>
1 parent 2e3e7da commit 183b641

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

drivers/thermal/thermal_netlink.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -450,10 +450,10 @@ static int thermal_genl_cmd_tz_get_id(struct param *p)
450450
static int thermal_genl_cmd_tz_get_trip(struct param *p)
451451
{
452452
struct sk_buff *msg = p->msg;
453+
const struct thermal_trip *trip;
453454
struct thermal_zone_device *tz;
454455
struct nlattr *start_trip;
455-
struct thermal_trip trip;
456-
int ret, i, id;
456+
int id;
457457

458458
if (!p->attrs[THERMAL_GENL_ATTR_TZ_ID])
459459
return -EINVAL;
@@ -470,16 +470,12 @@ static int thermal_genl_cmd_tz_get_trip(struct param *p)
470470

471471
mutex_lock(&tz->lock);
472472

473-
for (i = 0; i < tz->num_trips; i++) {
474-
475-
ret = __thermal_zone_get_trip(tz, i, &trip);
476-
if (ret)
477-
goto out_cancel_nest;
478-
479-
if (nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_ID, i) ||
480-
nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TYPE, trip.type) ||
481-
nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TEMP, trip.temperature) ||
482-
nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_HYST, trip.hysteresis))
473+
for_each_trip(tz, trip) {
474+
if (nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_ID,
475+
thermal_zone_trip_id(tz, trip)) ||
476+
nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TYPE, trip->type) ||
477+
nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TEMP, trip->temperature) ||
478+
nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_HYST, trip->hysteresis))
483479
goto out_cancel_nest;
484480
}
485481

0 commit comments

Comments
 (0)