* [PATCH v1] thermal: testing: Rearrange variable declarations involving __free()
@ 2025-09-03 14:52 Rafael J. Wysocki
2025-09-03 15:09 ` Krzysztof Kozlowski
0 siblings, 1 reply; 2+ messages in thread
From: Rafael J. Wysocki @ 2025-09-03 14:52 UTC (permalink / raw)
To: Linux PM; +Cc: LKML, Lukasz Luba, Daniel Lezcano, Krzysztof Kozlowski
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
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>
---
drivers/thermal/testing/zone.c | 31 +++++++++++--------------------
1 file changed, 11 insertions(+), 20 deletions(-)
--- a/drivers/thermal/testing/zone.c
+++ b/drivers/thermal/testing/zone.c
@@ -184,15 +184,14 @@ static void tt_add_tz_work_fn(struct wor
int tt_add_tz(void)
{
- struct tt_thermal_zone *tt_zone __free(kfree);
- struct tt_work *tt_work __free(kfree) = NULL;
int ret;
- tt_zone = kzalloc(sizeof(*tt_zone), GFP_KERNEL);
+ struct tt_thermal_zone *tt_zone __free(kfree) = kzalloc(sizeof(*tt_zone),
+ GFP_KERNEL);
if (!tt_zone)
return -ENOMEM;
- tt_work = kzalloc(sizeof(*tt_work), GFP_KERNEL);
+ struct tt_work *tt_work __free(kfree) = kzalloc(sizeof(*tt_work), GFP_KERNEL);
if (!tt_work)
return -ENOMEM;
@@ -237,7 +236,6 @@ static void tt_zone_unregister_tz(struct
int tt_del_tz(const char *arg)
{
- struct tt_work *tt_work __free(kfree) = NULL;
struct tt_thermal_zone *tt_zone, *aux;
int ret;
int id;
@@ -246,7 +244,7 @@ int tt_del_tz(const char *arg)
if (ret != 1)
return -EINVAL;
- tt_work = kzalloc(sizeof(*tt_work), GFP_KERNEL);
+ struct tt_work *tt_work __free(kfree) = kzalloc(sizeof(*tt_work), GFP_KERNEL);
if (!tt_work)
return -ENOMEM;
@@ -330,20 +328,17 @@ static void tt_zone_add_trip_work_fn(str
int tt_zone_add_trip(const char *arg)
{
- struct tt_thermal_zone *tt_zone __free(put_tt_zone) = NULL;
- struct tt_trip *tt_trip __free(kfree) = NULL;
- struct tt_work *tt_work __free(kfree);
int id;
- tt_work = kzalloc(sizeof(*tt_work), GFP_KERNEL);
+ struct tt_work *tt_work __free(kfree) = kzalloc(sizeof(*tt_work), GFP_KERNEL);
if (!tt_work)
return -ENOMEM;
- tt_trip = kzalloc(sizeof(*tt_trip), GFP_KERNEL);
+ struct tt_trip *tt_trip __free(kfree) = kzalloc(sizeof(*tt_trip), GFP_KERNEL);
if (!tt_trip)
return -ENOMEM;
- tt_zone = tt_get_tt_zone(arg);
+ struct tt_thermal_zone *tt_zone __free(put_tt_zone) = tt_get_tt_zone(arg);
if (IS_ERR(tt_zone))
return PTR_ERR(tt_zone);
@@ -387,7 +382,6 @@ static const struct thermal_zone_device_
static int tt_zone_register_tz(struct tt_thermal_zone *tt_zone)
{
- struct thermal_trip *trips __free(kfree) = NULL;
struct thermal_zone_device *tz;
struct tt_trip *tt_trip;
int i;
@@ -397,7 +391,8 @@ static int tt_zone_register_tz(struct tt
if (tt_zone->tz)
return -EINVAL;
- trips = kcalloc(tt_zone->num_trips, sizeof(*trips), GFP_KERNEL);
+ struct thermal_trip *trips __free(kfree) = kcalloc(tt_zone->num_trips,
+ sizeof(*trips), GFP_KERNEL);
if (!trips)
return -ENOMEM;
@@ -421,9 +416,7 @@ static int tt_zone_register_tz(struct tt
int tt_zone_reg(const char *arg)
{
- struct tt_thermal_zone *tt_zone __free(put_tt_zone);
-
- tt_zone = tt_get_tt_zone(arg);
+ struct tt_thermal_zone *tt_zone __free(put_tt_zone) = tt_get_tt_zone(arg);
if (IS_ERR(tt_zone))
return PTR_ERR(tt_zone);
@@ -432,9 +425,7 @@ int tt_zone_reg(const char *arg)
int tt_zone_unreg(const char *arg)
{
- struct tt_thermal_zone *tt_zone __free(put_tt_zone);
-
- tt_zone = tt_get_tt_zone(arg);
+ struct tt_thermal_zone *tt_zone __free(put_tt_zone) = tt_get_tt_zone(arg);
if (IS_ERR(tt_zone))
return PTR_ERR(tt_zone);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v1] thermal: testing: Rearrange variable declarations involving __free()
2025-09-03 14:52 [PATCH v1] thermal: testing: Rearrange variable declarations involving __free() Rafael J. Wysocki
@ 2025-09-03 15:09 ` Krzysztof Kozlowski
0 siblings, 0 replies; 2+ messages in thread
From: Krzysztof Kozlowski @ 2025-09-03 15:09 UTC (permalink / raw)
To: Rafael J. Wysocki, Linux PM; +Cc: LKML, Lukasz Luba, Daniel Lezcano
On 03/09/2025 16:52, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> 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>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-09-03 15:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-03 14:52 [PATCH v1] thermal: testing: Rearrange variable declarations involving __free() Rafael J. Wysocki
2025-09-03 15:09 ` Krzysztof Kozlowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).