git: 3b81d409b97b - stable/13 - LinuxKPI: device.h add devm_kmemdup()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 17 Oct 2022 20:41:38 UTC
The branch stable/13 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=3b81d409b97b94c3064a47d5cc0ca07a6fc01482 commit 3b81d409b97b94c3064a47d5cc0ca07a6fc01482 Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2022-09-21 19:33:30 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2022-10-17 20:37:04 +0000 LinuxKPI: device.h add devm_kmemdup() Add devm_kmemdup() as needed by a networking driver. Sponsored by: The FreeBSD Foundation eviewed by: hselasky, emaste Differential Revision: https://reviews.freebsd.org/D36652 (cherry picked from commit e999fbf0776208f9ecbc2926fd088427d766b014) --- sys/compat/linuxkpi/common/include/linux/device.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/device.h b/sys/compat/linuxkpi/common/include/linux/device.h index 4083c50c79eb..6c76836c4d94 100644 --- a/sys/compat/linuxkpi/common/include/linux/device.h +++ b/sys/compat/linuxkpi/common/include/linux/device.h @@ -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)