From: AKASHI Takahiro Date: Mon, 28 Oct 2019 09:28:01 +0900 Subject: [U-Boot] [PATCH v2 01/17] linux_compat: move kmemdup() from ubifs.c to linux_compat.c In-Reply-To: References: <20191025100749.16165-1-takahiro.akashi@linaro.org> <20191025100749.16165-2-takahiro.akashi@linaro.org> Message-ID: <20191028002800.GM10448@linaro.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Fri, Oct 25, 2019 at 07:38:45PM +0200, Heinrich Schuchardt wrote: > On 10/25/19 12:07 PM, AKASHI Takahiro wrote: > > 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 > > --- > > 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 > > Please add a 'Return:' line here. Linux has: Okay. -Takahiro Akashi > * Return: newly allocated copy of @src or %NULL in case of error > > Otherwise > > Reviewed-by: Heinrich Schuchardt > > > + */ > > +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; > > +} > > >