drm/amd/display: Clean up allocation in initialize_backlight_caps()
PATCH 1/1 drm/amd/display: Clean up allocation in initialize_backlight_caps()
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.
--- drivers/gpu/drm/amd/display/modules/power/power.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/display/modules/power/power.c +4 -8
@@ -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;
Signature · 1 line
2.53.0
Quoted 6 lines
Just a small cleanup:
1) Remove unnecessary initialization.
2) Use the newkzalloc_obj()macro.
3) Reformat the NULL check to make checkpatch happy.
4) Remove the unnecessary NULL check beforekfree()since the pointer is not NULL and anywaykfree()accepts NULL pointers.
Do these source code adjustments represent a patch squashing approach?
How good does it fit to known development requirements?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v7.1#n81
Regards,
Markus