kmemdup has implemented the function that kmalloc() + memcpy().
Prefer to kmemdup rather than code opened implementation.

Signed-off-by: Peng Hao <peng.h...@zte.com.cn>
---
 arch/arm/mach-lpc32xx/pm.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-lpc32xx/pm.c b/arch/arm/mach-lpc32xx/pm.c
index 6247157..1a2535c 100644
--- a/arch/arm/mach-lpc32xx/pm.c
+++ b/arch/arm/mach-lpc32xx/pm.c
@@ -85,8 +85,11 @@ static int lpc32xx_pm_enter(suspend_state_t state)
        int (*lpc32xx_suspend_ptr) (void);
        void *iram_swap_area;
 
-       /* Allocate some space for temporary IRAM storage */
-       iram_swap_area = kmalloc(lpc32xx_sys_suspend_sz, GFP_KERNEL);
+       /* Allocate some space for temporary IRAM storage. Then
+        * backup a small area of IRAM used for the suspend code.
+        */
+       iram_swap_area = kmemdup((void *) TEMP_IRAM_AREA,
+                                lpc32xx_sys_suspend_sz, GFP_KERNEL);
        if (!iram_swap_area) {
                printk(KERN_ERR
                       "PM Suspend: cannot allocate memory to save portion "
@@ -94,10 +97,6 @@ static int lpc32xx_pm_enter(suspend_state_t state)
                return -ENOMEM;
        }
 
-       /* Backup a small area of IRAM used for the suspend code */
-       memcpy(iram_swap_area, (void *) TEMP_IRAM_AREA,
-               lpc32xx_sys_suspend_sz);
-
        /*
         * Copy code to suspend system into IRAM. The suspend code
         * needs to run from IRAM as DRAM may no longer be available
-- 
1.8.3.1

Reply via email to