LinuxKPI: device.h add devm_kmemdup()
Add devm_kmemdup() as needed by a networking driver. Sponsored by: The FreeBSD Foundation MFC after: 7 days eviewed by: hselasky, emaste Differential Revision: https://reviews.freebsd.org/D36652
This commit is contained in:
parent
91ebcbe02a
commit
e999fbf077
@ -4,6 +4,10 @@
|
||||
* Copyright (c) 2010 Panasas, Inc.
|
||||
* Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2021-2022 The FreeBSD Foundation
|
||||
*
|
||||
* Portions of this software were developed by Björn Zeeb
|
||||
* under sponsorship from the FreeBSD Foundation.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -600,6 +604,21 @@ devm_kmalloc(struct device *dev, size_t size, gfp_t gfp)
|
||||
return (p);
|
||||
}
|
||||
|
||||
static inline void *
|
||||
devm_kmemdup(struct device *dev, const void *src, size_t len, gfp_t gfp)
|
||||
{
|
||||
void *dst;
|
||||
|
||||
if (len == 0)
|
||||
return (NULL);
|
||||
|
||||
dst = devm_kmalloc(dev, len, gfp);
|
||||
if (dst != NULL)
|
||||
memcpy(dst, src, len);
|
||||
|
||||
return (dst);
|
||||
}
|
||||
|
||||
#define devm_kzalloc(_dev, _size, _gfp) \
|
||||
devm_kmalloc((_dev), (_size), (_gfp) | __GFP_ZERO)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user