From nobody Mon Oct 17 20:41:38 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MrpnG4JVVz4fQfQ; Mon, 17 Oct 2022 20:41:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MrpnG3gX7z45vc; Mon, 17 Oct 2022 20:41:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666039298; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=b+9u5PQ6XNeydR8Estg9z8e9gNx5z0kqwcBNH09krCo=; b=XdWf25K00wFwC1sjIAEGmuvqHNXklT/k/7JlOaVdn4GZWmpFPrppXU1Um0yHYQiIDRrTf+ XYvZOJVhC4a0YtsxJZKbQPtcV0qr0FDaI+WntVY3jHJkgyOAB3w6Tidg17OmTcMqgWmxAW T2tG/XsJVNozBLmo8edk2CDqdtCSeYQk3H1CwL3l5zhcoFEM7cMyN3fWovxCIA4SXzFkYq 9J4qhR+otvgvgHx1rbxcu2Vq38mpr9m1iUhzytV030jz45YaS4mjsIxB7ZEGqc89d4TpmY 94Eg6lrschZoRffRbDJFFJHW2bEo5pQMhpoTqpPkmZ8dq3w5oDpMkewXzmwABg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MrpnG2dVMzxDm; Mon, 17 Oct 2022 20:41:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 29HKfcKh096525; Mon, 17 Oct 2022 20:41:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29HKfcES096524; Mon, 17 Oct 2022 20:41:38 GMT (envelope-from git) Date: Mon, 17 Oct 2022 20:41:38 GMT Message-Id: <202210172041.29HKfcES096524@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 3b81d409b97b - stable/13 - LinuxKPI: device.h add devm_kmemdup() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3b81d409b97b94c3064a47d5cc0ca07a6fc01482 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666039298; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=b+9u5PQ6XNeydR8Estg9z8e9gNx5z0kqwcBNH09krCo=; b=qb3uL5yxVguOpI+O3oPNfkYrHDG2oUCwRL3hLXFTUqYq/ZMvrcFhUEz/kvlx1wNpQwA7Lp RtX5Ja1gMg3Y5lM362+SpmeqiAF5y1RA+RsuOm5+vYo3yOlbpwV8ac6kJL64dr50F8+9Hm Mlo0cPbFVeutpET8U0ofCXUYo02SaZETXc/cm7cN92vrEQ7aT8a7MRRGBXsuTl8Jeq/cRH 2riQUhEr+pq3UbFpcblFyCTGmzK3CRKfBuyq0QWR6nQfClvqrgJTyrnqY7Ktv3f535LrFX +6vAwJcsACp4Z1fr9f9xFG6BNAlN2NaQ1MOLknDnSQkssJw0z+vVt+8ZJZCFXQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1666039298; a=rsa-sha256; cv=none; b=l7NP+5vLPuo1iz1RK9Lj2KwU6Us1g/kD+RZDBqWYEgqPikNUQ+OmJW9AJ8xs1JYiRZBqwL Eqy73IaYAssDzunoqoG2XUmhMTcj6hAXvkFzWTYbyQVfIoFmh6nCQnvoL7YvrMG6Pkq+Oa Yar7xCg3fEgxdYaK6Lqz9cS2YODp7ZfvWaxDEl0UFV0aV7bRwkdrPFwShZUMpm9gVbIlBL N45Kt9Tc0xaeB63YhuXpn0ZTBwnxSs23d3zxnUF2Lk7RrsMTiSxfzInvd8kaNy5vdFFGnB bemZZfkn2lRd2rTmQbA2z31R/JffBtSiL32k/gkf1u8HFZxCBqriDNJsLqShBQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=3b81d409b97b94c3064a47d5cc0ca07a6fc01482 commit 3b81d409b97b94c3064a47d5cc0ca07a6fc01482 Author: Bjoern A. Zeeb AuthorDate: 2022-09-21 19:33:30 +0000 Commit: Bjoern A. Zeeb 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)