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

amd/powerplay: use kmemdup instead of kmalloc + memcpy

Save a few clocks by replacing calls to kmalloc followed by memcpy
with a single call to kmemdup.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Edward O'Callaghan and committed by
Alex Deucher
efdf7a93 41698abb

+3 -6
+3 -6
drivers/gpu/drm/amd/powerplay/amd_powerplay.c
··· 764 764 PP_CHECK_HW(hwmgr); 765 765 766 766 if (!hwmgr->hardcode_pp_table) { 767 - hwmgr->hardcode_pp_table = 768 - kzalloc(hwmgr->soft_pp_table_size, GFP_KERNEL); 767 + hwmgr->hardcode_pp_table = kmemdup(hwmgr->soft_pp_table, 768 + hwmgr->soft_pp_table_size, 769 + GFP_KERNEL); 769 770 770 771 if (!hwmgr->hardcode_pp_table) 771 772 return -ENOMEM; 772 - 773 - /* to avoid powerplay crash when hardcode pptable is empty */ 774 - memcpy(hwmgr->hardcode_pp_table, hwmgr->soft_pp_table, 775 - hwmgr->soft_pp_table_size); 776 773 } 777 774 778 775 memcpy(hwmgr->hardcode_pp_table, buf, size);