git: 3fd7fd4974c8 - main - linuxkpi: Add `__assign_bit()`

From: Jean-Sébastien Pédron <dumbbell_at_FreeBSD.org>
Date: Fri, 31 Jan 2025 16:03:17 UTC
The branch main has been updated by dumbbell:

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

commit 3fd7fd4974c8000148360af2f02002f1c083681a
Author:     Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
AuthorDate: 2024-12-27 00:33:08 +0000
Commit:     Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
CommitDate: 2025-01-31 16:00:48 +0000

    linuxkpi: Add `__assign_bit()`
    
    [Why]
    This function is used by the i915 DRM driver in Linux 6.7.
    
    Reviewed by:    manu
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D48752
---
 sys/compat/linuxkpi/common/include/linux/bitops.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/sys/compat/linuxkpi/common/include/linux/bitops.h b/sys/compat/linuxkpi/common/include/linux/bitops.h
index 1415d5224084..23aabb546cb2 100644
--- a/sys/compat/linuxkpi/common/include/linux/bitops.h
+++ b/sys/compat/linuxkpi/common/include/linux/bitops.h
@@ -288,6 +288,15 @@ find_next_zero_bit(const unsigned long *addr, unsigned long size,
 #define	test_bit(i, a)							\
     !!(READ_ONCE(((volatile const unsigned long *)(a))[BIT_WORD(i)]) & BIT_MASK(i))
 
+static inline void
+__assign_bit(long bit, volatile unsigned long *addr, bool value)
+{
+	if (value)
+		__set_bit(bit, addr);
+	else
+		__clear_bit(bit, addr);
+}
+
 static inline int
 test_and_clear_bit(long bit, volatile unsigned long *var)
 {