Skip to content

Commit 9782dd1

Browse files
committed
thermal: testing: Simplify tt_get_tt_zone()
Notice that tt_get_tt_zone() need not use the ret variable in the tt_thermal_zones list walk and make it return right after incrementing the reference counter of the matching entry. No functional impact. Signed-off-by: Rafael J. Wysocki <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent c285b11 commit 9782dd1

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

drivers/thermal/testing/zone.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -288,19 +288,14 @@ static struct tt_thermal_zone *tt_get_tt_zone(const char *arg)
288288

289289
guard(mutex)(&tt_thermal_zones_lock);
290290

291-
ret = -EINVAL;
292291
list_for_each_entry(tt_zone, &tt_thermal_zones, list_node) {
293292
if (tt_zone->id == id) {
294293
tt_zone->refcount++;
295-
ret = 0;
296-
break;
294+
return tt_zone;
297295
}
298296
}
299297

300-
if (ret)
301-
return ERR_PTR(ret);
302-
303-
return tt_zone;
298+
return ERR_PTR(-EINVAL);
304299
}
305300

306301
static void tt_put_tt_zone(struct tt_thermal_zone *tt_zone)

0 commit comments

Comments
 (0)