@@ -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
kmemdup has implemented the function that kmalloc() + memcpy(). Prefer to kmemdup rather than code opened implementation. Signed-off-by: Peng Hao <peng.hao2@zte.com.cn> --- arch/arm/mach-lpc32xx/pm.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)