OSDN Git Service

amd/powerplay: use kmemdup instead of kmalloc + memcpy
authorEdward O'Callaghan <funfunctor@folklore1984.net>
Sun, 4 Sep 2016 02:36:19 +0000 (12:36 +1000)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 14 Sep 2016 19:10:36 +0000 (15:10 -0400)
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>
drivers/gpu/drm/amd/powerplay/amd_powerplay.c

index 3e7235f..b1d1940 100644 (file)
@@ -764,15 +764,12 @@ static int pp_dpm_set_pp_table(void *handle, const char *buf, size_t size)
        PP_CHECK_HW(hwmgr);
 
        if (!hwmgr->hardcode_pp_table) {
-               hwmgr->hardcode_pp_table =
-                               kzalloc(hwmgr->soft_pp_table_size, GFP_KERNEL);
+               hwmgr->hardcode_pp_table = kmemdup(hwmgr->soft_pp_table,
+                                                  hwmgr->soft_pp_table_size,
+                                                  GFP_KERNEL);
 
                if (!hwmgr->hardcode_pp_table)
                        return -ENOMEM;
-
-               /* to avoid powerplay crash when hardcode pptable is empty */
-               memcpy(hwmgr->hardcode_pp_table, hwmgr->soft_pp_table,
-                               hwmgr->soft_pp_table_size);
        }
 
        memcpy(hwmgr->hardcode_pp_table, buf, size);