From patchwork Fri Oct 25 10:07:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1183972 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="FTCcNTYA"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4700GK0QY9z9sQm for ; Fri, 25 Oct 2019 21:09:44 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id BEFB1C21DB3; Fri, 25 Oct 2019 10:09:20 +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 892CCC21E9F; Fri, 25 Oct 2019 10:08:13 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 9951DC21E70; Fri, 25 Oct 2019 10:08:00 +0000 (UTC) Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by lists.denx.de (Postfix) with ESMTPS id E5271C21EA2 for ; Fri, 25 Oct 2019 10:07:56 +0000 (UTC) Received: by mail-pg1-f194.google.com with SMTP id 23so1246539pgk.3 for ; Fri, 25 Oct 2019 03:07:56 -0700 (PDT) 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=mLxkhLdGM4vXYIQDAEmr9sFFENIb1tYDunXLDkslRVY=; b=FTCcNTYAfGnMRB9/SKrhNtWuL6cvpfTw9qRQLV4WGZ+GeMnuwyXKTK0YXp4SJcsNRO S+6IXIPqxgUwIZlI3d/Qb7hAkf97lvy33/LrSHpcqwrwB5ebuz8TQUAogrx9Rw5OPiCO +mTwc9oquXTRuNgx/Q+gXT3wFwBpigVtEUu4/kG+eK3KmPrVXlWDf1tAYP41Ahyjap4L w9ffePBAznR1HknOptps+1g3vrY1QopGKY7KgC+PCsxJjvWNTE1tbm3UQUwmohAX+WVg HOvvYA+lHvIkkGJoeMB25Jc7hQXimDRoPITXFiPohcKjsCTuo8glZOnVSrkm5dmpuDf3 jh4w== 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=mLxkhLdGM4vXYIQDAEmr9sFFENIb1tYDunXLDkslRVY=; b=It2XOckJ33O5ymt0adDIzHgxJgx4bfu2GUpPdA63EDYPHLViqN4tdYOzy6fhtm5Cq2 1dt526lYMkf8UEp8ZyMNr79KfaoSx8qD8y+fbZjurGgybwiX1eC6kv2DIa5aJ9fmqse2 274WRBb6I73vLYK8hEViqeYZxqExB7ovYkvDp+Z7iFX/s8wAigs51r5jxSAwSBBueFbm 17M2CsAoRjfMSWnYeNaGJdAz2+SIXIKKnjn9t1jFT2+jdKUZFU7i9LH3DAOET72KzX85 ZVtk4ZtUcbsh44wQLGtw5hHfJIB201tAQaOrhvJaekAhusZiQcvFlSVjmEFPeZbnd2x6 6ysw== X-Gm-Message-State: APjAAAUMeph+6PpreI1pFRaEdD/ptVGW6FnpdRjms+ozsYcWmkIoytsS YTxKoIvERzqTGdmsLbpYpWtNnQ== X-Google-Smtp-Source: APXvYqytN7y0hu0cq/OLqA8XvKIqjTv7LRJ3jd0W3bGQvwZoITVakaA6lKSZaPSv+fwwYpO0kRAYuQ== X-Received: by 2002:a17:90a:b285:: with SMTP id c5mr3050198pjr.123.1571998075104; Fri, 25 Oct 2019 03:07:55 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id y2sm2282766pfe.126.2019.10.25.03.07.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Oct 2019 03:07:54 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, xypron.glpk@gmx.de, agraf@csgraf.de Date: Fri, 25 Oct 2019 19:07:33 +0900 Message-Id: <20191025100749.16165-2-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191025100749.16165-1-takahiro.akashi@linaro.org> References: <20191025100749.16165-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 01/17] 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 | 17 +++++++++++++++++ 2 files changed, 18 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 6373b4451eb3..1f8ef4266613 100644 --- a/lib/linux_compat.c +++ b/lib/linux_compat.c @@ -40,3 +40,20 @@ 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 + */ +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; +}