mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-05 03:03:49 +00:00
linux_compat: move kmemdup() from ubifs.c to linux_compat.c
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 <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
This commit is contained in:
parent
31839dc2d2
commit
4839e86892
2 changed files with 20 additions and 18 deletions
|
@ -18,6 +18,7 @@
|
||||||
#include "ubifs.h"
|
#include "ubifs.h"
|
||||||
#include <u-boot/zlib.h>
|
#include <u-boot/zlib.h>
|
||||||
|
|
||||||
|
#include <linux/compat.h>
|
||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
#include <linux/lzo.h>
|
#include <linux/lzo.h>
|
||||||
|
|
||||||
|
@ -70,24 +71,6 @@ struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT];
|
||||||
|
|
||||||
|
|
||||||
#ifdef __UBOOT__
|
#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 {
|
struct crypto_comp {
|
||||||
int compressor;
|
int compressor;
|
||||||
|
|
|
@ -40,3 +40,22 @@ void *kmem_cache_alloc(struct kmem_cache *obj, int flag)
|
||||||
{
|
{
|
||||||
return malloc_cache_aligned(obj->sz);
|
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;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue