From patchwork Wed Nov 13 00:44:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1193904 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="ljfEFbkE"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 47CQr92ryMz9sPh for ; Wed, 13 Nov 2019 11:45:13 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 214C2C21F59; Wed, 13 Nov 2019 00:45:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 7D442C21E7D; Wed, 13 Nov 2019 00:45:07 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 663DCC21E79; Wed, 13 Nov 2019 00:45:06 +0000 (UTC) Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by lists.denx.de (Postfix) with ESMTPS id B45B4C21E85 for ; Wed, 13 Nov 2019 00:45:05 +0000 (UTC) Received: by mail-pf1-f194.google.com with SMTP id s5so321506pfh.9 for ; Tue, 12 Nov 2019 16:45:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CkYdXGE6h8mSl4kYnjXaTzlMAzHZkKBiKI7RswRWr1s=; b=ljfEFbkESFyFO15vIkPaI2EzQm/moGNDIWZuZFzD+pRlNhg+zXgfw/6M0mH+0MT1ei 2wfz7Iqk4U1o7cWpnFk2zVSIbZO0kzhlwo828LM2VzrIAXCwR011k+xSyLvbWBCpQ1M3 aklV3KlchA05hz19rdl6sbLl5TWaY2a761cxeBquuPdD3P0jQpX/SBj5+CUA9tlYPkDS E3715Szq3wflmEv7WlenlUEJQRRfU8R9x5jl+g1rCOJ5E3dJRxkqCOa2lO27oG/DlMw7 f+yQlLhfH5FLB533hOsa0CQ8Bjoqjia2vFo+kmrC0kSacu8NOJueoFCHK12rwOehCzoE PONw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CkYdXGE6h8mSl4kYnjXaTzlMAzHZkKBiKI7RswRWr1s=; b=C2to89Bxx/U71SIlxjTUHZ4KElPfza32mCV02PKMhaPtyGmK81ywo0uwsWzU4z6yDD Cg2/ElEhBVzaE4IJvoffJfrip7B2d+1jA7vB1znsycSfkKbPiUm5lvGXFBL7i/V+GpqL GZO62lIopjyoiROXojX5ivrjYFw54aFWEonPG+739TmRJAssA3HMr+ZbtzJH3HrOLdPe JJ9Irlqyh1kegm8s3TKK9/XGd4rJosW27udkfxyZ7l6akVW//a9pEfcQ0l0X64/r3Bkj CF0IE238dGzlrUmCxLGKKCQau2ol1aHh+CZ8QJQucQ6/dEu/bnV0oASSZFWM/ow8zSqd 2dXg== X-Gm-Message-State: APjAAAU0pQ1FmssdPUiZ5SGXkZALoer+zP2R9wYPDzj9EB50DWShJLxN t//a/X1tMrBOHj3+yd2RfwdFSw== X-Google-Smtp-Source: APXvYqwsjUFGZJv6CMFuIwVgQVQu0IwXKfbuNjpOkwaNEyyKrAOQ0PZcVsspZ7c1zz7fiB1+dHxAxA== X-Received: by 2002:aa7:8d93:: with SMTP id i19mr945768pfr.26.1573605904058; Tue, 12 Nov 2019 16:45:04 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id f8sm180301pgd.64.2019.11.12.16.45.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Nov 2019 16:45:03 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, xypron.glpk@gmx.de, agraf@csgraf.de Date: Wed, 13 Nov 2019 09:44:47 +0900 Message-Id: <20191113004502.29986-2-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191113004502.29986-1-takahiro.akashi@linaro.org> References: <20191113004502.29986-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de, mail@patrick-wildt.de Subject: [U-Boot] [PATCH v3 01/16] linux_compat: move kmemdup() from ubifs.c to linux_compat.c X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" linux_compat.c is the best place for kmemdup(), which is currenly used only in ubifs.c, but will also be used when other kernel files (in my case, lib/crypto/x509_cert_parser.c and pkcs7_parser.c) will be imported. So just move it. Signed-off-by: AKASHI Takahiro Reviewed-by: Heinrich Schuchardt --- fs/ubifs/ubifs.c | 19 +------------------ lib/linux_compat.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c index 67a0e8caae70..1ffdfe0d9089 100644 --- a/fs/ubifs/ubifs.c +++ b/fs/ubifs/ubifs.c @@ -18,6 +18,7 @@ #include "ubifs.h" #include +#include #include #include @@ -70,24 +71,6 @@ struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT]; #ifdef __UBOOT__ -/* from mm/util.c */ - -/** - * kmemdup - duplicate region of memory - * - * @src: memory region to duplicate - * @len: memory region length - * @gfp: GFP mask to use - */ -void *kmemdup(const void *src, size_t len, gfp_t gfp) -{ - void *p; - - p = kmalloc(len, gfp); - if (p) - memcpy(p, src, len); - return p; -} struct crypto_comp { int compressor; diff --git a/lib/linux_compat.c b/lib/linux_compat.c index 81ea8fb126fa..3f440deaa0d8 100644 --- a/lib/linux_compat.c +++ b/lib/linux_compat.c @@ -40,3 +40,22 @@ void *kmem_cache_alloc(struct kmem_cache *obj, int flag) { return malloc_cache_aligned(obj->sz); } + +/** + * kmemdup - duplicate region of memory + * + * @src: memory region to duplicate + * @len: memory region length + * @gfp: GFP mask to use + * + * Return: newly allocated copy of @src or %NULL in case of error + */ +void *kmemdup(const void *src, size_t len, gfp_t gfp) +{ + void *p; + + p = kmalloc(len, gfp); + if (p) + memcpy(p, src, len); + return p; +}