lkml.org 
[lkml]   [2018]   [Dec]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] arm/mach-lpc32xx/pm : use kmemdup instead of duplicating
Date
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 --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
\
 
 \ /
  Last update: 2018-12-28 01:38    [W:0.028 / U:13.804 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site