diff mbox series

arm/mach-lpc32xx/pm : use kmemdup instead of duplicating

Message ID 1545958679-89146-1-git-send-email-peng.hao2@zte.com.cn (mailing list archive)
State New, archived
Headers show
Series arm/mach-lpc32xx/pm : use kmemdup instead of duplicating | expand

Commit Message

Peng Hao Dec. 28, 2018, 12:57 a.m. UTC
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(-)
diff mbox series

Patch

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