From patchwork Fri Aug 10 02:40:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhong jiang X-Patchwork-Id: 10562209 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 50915139A for ; Fri, 10 Aug 2018 02:53:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4183026AE3 for ; Fri, 10 Aug 2018 02:53:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 354B92B355; Fri, 10 Aug 2018 02:53:05 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI 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 9D8F126AE3 for ; Fri, 10 Aug 2018 02:53:04 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=hC92Z2UBx2klsJYeyChEQMbzXZBr+3BxcpZTTs3212o=; b=CQVfA3nQSAZmxM vMu3KZ0yuMQTX/9U2qOOyiMtUocyToMdeoDCC6PmCHpBSk5kAhiONZHX0gHxoLOZZPa8xSOjI5FyU AtgxMhf/8WaJD2rl9v101VrJxBhO6impf+9zkQn4+Q8FEyVo/8lDpXqTpiUovUVPkL4AVm0tq28ZY j2aC5DDuFshE0ItZYiBWPoGDUAEoIFaufzwVWHwDzQBZjQxKcnm5iUOQYBJovrAPEK3uQCxv4/Aef 03oyFSUJde8Odk3O0OKDVfrbnTFvOoMcrfUEM21YKyvBlNo2JmubCBzEwoZ481yV9aBQ9qmjvy0Ib whFyI4phisjXMNVpFOwA==; 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 1fnxXv-0002Oa-Vm; Fri, 10 Aug 2018 02:52:59 +0000 Received: from szxga07-in.huawei.com ([45.249.212.35] helo=huawei.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fnxXs-0002Mb-Pa for linux-arm-kernel@lists.infradead.org; Fri, 10 Aug 2018 02:52:58 +0000 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 3044523C56798; Fri, 10 Aug 2018 10:52:36 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.399.0; Fri, 10 Aug 2018 10:52:34 +0800 From: zhong jiang To: , , Subject: [PATCH] arm:pm: Use kmemdup to replace duplicating its implementation Date: Fri, 10 Aug 2018 10:40:51 +0800 Message-ID: <1533868851-316-1-git-send-email-zhongjiang@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180809_195256_999673_2706BFF5 X-CRM114-Status: GOOD ( 10.01 ) 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: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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 is better than kmalloc() + memcpy(), and we do not like open code. So just use kmemdup instead. Signed-off-by: zhong jiang --- arch/arm/mach-lpc32xx/pm.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-lpc32xx/pm.c b/arch/arm/mach-lpc32xx/pm.c index 6247157..6eefff8 100644 --- a/arch/arm/mach-lpc32xx/pm.c +++ b/arch/arm/mach-lpc32xx/pm.c @@ -86,7 +86,8 @@ static int lpc32xx_pm_enter(suspend_state_t state) void *iram_swap_area; /* Allocate some space for temporary IRAM storage */ - iram_swap_area = kmalloc(lpc32xx_sys_suspend_sz, GFP_KERNEL); + 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 +95,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