git: c8cf6a7706a0 - stable/14 - LinuxKPI: add FIELD_PREP_CONST()

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Wed, 12 Jun 2024 16:41:18 UTC
The branch stable/14 has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=c8cf6a7706a090a821fdbc77d5b9b0a6474c8473

commit c8cf6a7706a090a821fdbc77d5b9b0a6474c8473
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2024-05-13 17:40:26 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2024-06-12 13:57:37 +0000

    LinuxKPI: add FIELD_PREP_CONST()
    
    Add FIELD_PREP_CONST() like FIELD_PREP() without any extra checks likely
    expected on this version in Linux.  This is called by an updated wireless
    driver.
    
    Sposnored by:   The FreeBSD Foundation
    MFC after:      3 days
    Differential Revision: https://reviews.freebsd.org/D45180
    
    (cherry picked from commit bb025df257386c5d1087b652e8ed951bceb89862)
---
 sys/compat/linuxkpi/common/include/linux/bitfield.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/bitfield.h b/sys/compat/linuxkpi/common/include/linux/bitfield.h
index a2020d247489..8a91b0663f37 100644
--- a/sys/compat/linuxkpi/common/include/linux/bitfield.h
+++ b/sys/compat/linuxkpi/common/include/linux/bitfield.h
@@ -1,7 +1,7 @@
 /*-
  * SPDX-License-Identifier: BSD-2-Clause
  *
- * Copyright (c) 2020 The FreeBSD Foundation
+ * Copyright (c) 2020-2024 The FreeBSD Foundation
  *
  * This software was developed by Björn Zeeb under sponsorship from
  * the FreeBSD Foundation.
@@ -131,6 +131,10 @@ _uX_replace_bits(8)
 #define	FIELD_PREP(_mask, _value)					\
 	(((typeof(_mask))(_value) << __bf_shf(_mask)) & (_mask))
 
+/* Likely would need extra sanity checks compared to FIELD_PREP()? */
+#define	FIELD_PREP_CONST(_mask, _value)					\
+	(((typeof(_mask))(_value) << __bf_shf(_mask)) & (_mask))
+
 #define	FIELD_GET(_mask, _value)					\
 	((typeof(_mask))(((_value) & (_mask)) >> __bf_shf(_mask)))