* [PATCH] drm/amd/display: Clean up allocation in initialize_backlight_caps()
@ 2026-04-23 7:09 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2026-04-23 7:09 UTC (permalink / raw)
To: Harry Wentland
Cc: Leo Li, Rodrigo Siqueira, Alex Deucher, Christian König,
David Airlie, Simona Vetter, Chenyu Chen, Ray Wu, amd-gfx,
dri-devel, linux-kernel, kernel-janitors
Just a small cleanup:
1) Remove unnecessary initialization.
2) Use the new kzalloc_obj() macro.
3) Reformat the NULL check to make checkpatch happy.
4) Remove the unnecessary NULL check before kfree() since the pointer
is not NULL and anyway kfree() accepts NULL pointers.
Signed-off-by: Dan Carpenter <error27@gmail.com>
---
drivers/gpu/drm/amd/display/modules/power/power.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/modules/power/power.c b/drivers/gpu/drm/amd/display/modules/power/power.c
index 6c73fecf57d5..68b5b3b967be 100644
--- a/drivers/gpu/drm/amd/display/modules/power/power.c
+++ b/drivers/gpu/drm/amd/display/modules/power/power.c
@@ -470,7 +470,7 @@ static bool validate_ext_backlight_caps(
static void initialize_backlight_caps(struct core_power *core_power, unsigned int inst)
{
unsigned int i;
- struct dm_acpi_atif_backlight_caps *ext_backlight_caps = NULL;
+ struct dm_acpi_atif_backlight_caps *ext_backlight_caps;
bool custom_curve_present = false;
unsigned int num_levels = 0;
struct dc *dc = NULL;
@@ -486,11 +486,8 @@ static void initialize_backlight_caps(struct core_power *core_power, unsigned in
/* Allocate memory for ATIF output
* (do not want to use 256 bytes on the stack)
*/
- ext_backlight_caps = (struct dm_acpi_atif_backlight_caps *)
- (kzalloc(sizeof(struct dm_acpi_atif_backlight_caps),
- GFP_KERNEL));
-
- if (ext_backlight_caps == NULL)
+ ext_backlight_caps = kzalloc_obj(*ext_backlight_caps);
+ if (!ext_backlight_caps)
return;
/* Retrieve ACPI extended brightness caps */
@@ -611,8 +608,7 @@ static void initialize_backlight_caps(struct core_power *core_power, unsigned in
}
}
- if (ext_backlight_caps != NULL)
- kfree(ext_backlight_caps);
+ kfree(ext_backlight_caps);
/* Successfully initialized */
core_power->bl_prop[inst].backlight_caps_valid = true;
--
2.53.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-04-23 7:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-23 7:09 [PATCH] drm/amd/display: Clean up allocation in initialize_backlight_caps() Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox