Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

thermal: testing: Rearrange variable declarations involving __free()

Follow cleanup.h recommendations and always define and assign variables
in one statement when __free() is used.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/5934556.DvuYhMxLoT@rafael.j.wysocki

+11 -20
+11 -20
drivers/thermal/testing/zone.c
··· 184 184 185 185 int tt_add_tz(void) 186 186 { 187 - struct tt_thermal_zone *tt_zone __free(kfree); 188 - struct tt_work *tt_work __free(kfree) = NULL; 189 187 int ret; 190 188 191 - tt_zone = kzalloc(sizeof(*tt_zone), GFP_KERNEL); 189 + struct tt_thermal_zone *tt_zone __free(kfree) = kzalloc(sizeof(*tt_zone), 190 + GFP_KERNEL); 192 191 if (!tt_zone) 193 192 return -ENOMEM; 194 193 195 - tt_work = kzalloc(sizeof(*tt_work), GFP_KERNEL); 194 + struct tt_work *tt_work __free(kfree) = kzalloc(sizeof(*tt_work), GFP_KERNEL); 196 195 if (!tt_work) 197 196 return -ENOMEM; 198 197 ··· 236 237 237 238 int tt_del_tz(const char *arg) 238 239 { 239 - struct tt_work *tt_work __free(kfree) = NULL; 240 240 struct tt_thermal_zone *tt_zone, *aux; 241 241 int ret; 242 242 int id; ··· 244 246 if (ret != 1) 245 247 return -EINVAL; 246 248 247 - tt_work = kzalloc(sizeof(*tt_work), GFP_KERNEL); 249 + struct tt_work *tt_work __free(kfree) = kzalloc(sizeof(*tt_work), GFP_KERNEL); 248 250 if (!tt_work) 249 251 return -ENOMEM; 250 252 ··· 328 330 329 331 int tt_zone_add_trip(const char *arg) 330 332 { 331 - struct tt_thermal_zone *tt_zone __free(put_tt_zone) = NULL; 332 - struct tt_trip *tt_trip __free(kfree) = NULL; 333 - struct tt_work *tt_work __free(kfree); 334 333 int id; 335 334 336 - tt_work = kzalloc(sizeof(*tt_work), GFP_KERNEL); 335 + struct tt_work *tt_work __free(kfree) = kzalloc(sizeof(*tt_work), GFP_KERNEL); 337 336 if (!tt_work) 338 337 return -ENOMEM; 339 338 340 - tt_trip = kzalloc(sizeof(*tt_trip), GFP_KERNEL); 339 + struct tt_trip *tt_trip __free(kfree) = kzalloc(sizeof(*tt_trip), GFP_KERNEL); 341 340 if (!tt_trip) 342 341 return -ENOMEM; 343 342 344 - tt_zone = tt_get_tt_zone(arg); 343 + struct tt_thermal_zone *tt_zone __free(put_tt_zone) = tt_get_tt_zone(arg); 345 344 if (IS_ERR(tt_zone)) 346 345 return PTR_ERR(tt_zone); 347 346 ··· 382 387 383 388 static int tt_zone_register_tz(struct tt_thermal_zone *tt_zone) 384 389 { 385 - struct thermal_trip *trips __free(kfree) = NULL; 386 390 struct thermal_zone_device *tz; 387 391 struct tt_trip *tt_trip; 388 392 int i; ··· 391 397 if (tt_zone->tz) 392 398 return -EINVAL; 393 399 394 - trips = kcalloc(tt_zone->num_trips, sizeof(*trips), GFP_KERNEL); 400 + struct thermal_trip *trips __free(kfree) = kcalloc(tt_zone->num_trips, 401 + sizeof(*trips), GFP_KERNEL); 395 402 if (!trips) 396 403 return -ENOMEM; 397 404 ··· 416 421 417 422 int tt_zone_reg(const char *arg) 418 423 { 419 - struct tt_thermal_zone *tt_zone __free(put_tt_zone); 420 - 421 - tt_zone = tt_get_tt_zone(arg); 424 + struct tt_thermal_zone *tt_zone __free(put_tt_zone) = tt_get_tt_zone(arg); 422 425 if (IS_ERR(tt_zone)) 423 426 return PTR_ERR(tt_zone); 424 427 ··· 425 432 426 433 int tt_zone_unreg(const char *arg) 427 434 { 428 - struct tt_thermal_zone *tt_zone __free(put_tt_zone); 429 - 430 - tt_zone = tt_get_tt_zone(arg); 435 + struct tt_thermal_zone *tt_zone __free(put_tt_zone) = tt_get_tt_zone(arg); 431 436 if (IS_ERR(tt_zone)) 432 437 return PTR_ERR(tt_zone); 433 438