You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
devres: introduce API "devm_kmemdup
Introduce devm_kmemdup, which uses resource managed kmalloc. There are several request from maintainers to add this instead of using kmemdup. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This commit is contained in:
committed by
Jonathan Cameron
parent
37aa48368f
commit
3046365bb4
@@ -831,3 +831,24 @@ void devm_kfree(struct device *dev, void *p)
|
||||
WARN_ON(rc);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(devm_kfree);
|
||||
|
||||
/**
|
||||
* devm_kmemdup - Resource-managed kmemdup
|
||||
* @dev: Device this memory belongs to
|
||||
* @src: Memory region to duplicate
|
||||
* @len: Memory region length
|
||||
* @gfp: GFP mask to use
|
||||
*
|
||||
* Duplicate region of a memory using resource managed kmalloc
|
||||
*/
|
||||
void *devm_kmemdup(struct device *dev, const void *src, size_t len, gfp_t gfp)
|
||||
{
|
||||
void *p;
|
||||
|
||||
p = devm_kmalloc(dev, len, gfp);
|
||||
if (p)
|
||||
memcpy(p, src, len);
|
||||
|
||||
return p;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(devm_kmemdup);
|
||||
|
||||
Reference in New Issue
Block a user