From patchwork Fri Dec 28 00:57:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Hao X-Patchwork-Id: 10744081 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8BF7891E for ; Fri, 28 Dec 2018 00:37:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 714E72890C for ; Fri, 28 Dec 2018 00:37:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 63FBC28B0B; Fri, 28 Dec 2018 00:37:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B86932890C for ; Fri, 28 Dec 2018 00:37:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=VwCR0Wq8LMcIksL7vCYd9Ev5mw4l4apZcqRgp2s3Bco=; b=CKc evRpK3DZ6RanPXWWTpvBZwPxkg4Q5NF1PI0vOBj9aJ06Qj0byNazloGGHg531XnP9Ts4Jw03oTUwK 6XRUTYrFZdWSjqrXPmb7MjJTe+blh3GFkfWNnoMt/DySi1lGEiIaIp5m40wVyScX+OCLFSs3wSoQx 8qDzcZlwQbnrWYULKnavWuUkJ78qHd571nJWBloXb43EMzGO6ev99lrRDB1+BWvb8xbM7J2r2/cMw i8kby+62Derl10cdxfddOT0x2LtStb6qlMCT53xZ5neGjqEtZzV00cBAMw/rMMVuG0Nb65Py1JBga UF3iXnODTaaeK6ETit7N7uCOjswNLXQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gcg9f-0006TP-Tz; Fri, 28 Dec 2018 00:37:35 +0000 Received: from mxhk.zte.com.cn ([63.217.80.70]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gcg9c-0006SX-K8 for linux-arm-kernel@lists.infradead.org; Fri, 28 Dec 2018 00:37:34 +0000 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 02DBD70D09EEB5C69BB0; Fri, 28 Dec 2018 08:37:17 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id wBS0b8bH014847; Fri, 28 Dec 2018 08:37:08 +0800 (GMT-8) (envelope-from peng.hao2@zte.com.cn) Received: from localhost.localdomain.localdomain ([10.74.120.59]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2018122808374251-19198379 ; Fri, 28 Dec 2018 08:37:42 +0800 From: Peng Hao To: vz@mleia.com, slemieux.tyco@gmail.com Subject: [PATCH] arm/mach-lpc32xx/pm : use kmemdup instead of duplicating Date: Fri, 28 Dec 2018 08:57:59 +0800 Message-Id: <1545958679-89146-1-git-send-email-peng.hao2@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2018-12-28 08:37:42, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2018-12-28 08:36:52, Serialize complete at 2018-12-28 08:36:52 X-MAIL: mse01.zte.com.cn wBS0b8bH014847 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181227_163732_814859_A31DDB4C X-CRM114-Status: GOOD ( 12.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peng Hao , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP kmemdup has implemented the function that kmalloc() + memcpy(). Prefer to kmemdup rather than code opened implementation. Signed-off-by: Peng Hao --- 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