xref: /dflybsd-src/sys/dev/drm/include/asm/bitops/non-atomic.h (revision a3268cb6a0bf7756350752b1e8c7954fdb650c89)
1e3440f96SFrançois Tigeot /*-
2e3440f96SFrançois Tigeot  * Copyright (c) 2014 François Tigeot
3e3440f96SFrançois Tigeot  * All rights reserved.
4e3440f96SFrançois Tigeot  *
5e3440f96SFrançois Tigeot  * Redistribution and use in source and binary forms, with or without
6e3440f96SFrançois Tigeot  * modification, are permitted provided that the following conditions
7e3440f96SFrançois Tigeot  * are met:
8e3440f96SFrançois Tigeot  * 1. Redistributions of source code must retain the above copyright
9e3440f96SFrançois Tigeot  *    notice unmodified, this list of conditions, and the following
10e3440f96SFrançois Tigeot  *    disclaimer.
11e3440f96SFrançois Tigeot  * 2. Redistributions in binary form must reproduce the above copyright
12e3440f96SFrançois Tigeot  *    notice, this list of conditions and the following disclaimer in the
13e3440f96SFrançois Tigeot  *    documentation and/or other materials provided with the distribution.
14e3440f96SFrançois Tigeot  *
15e3440f96SFrançois Tigeot  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16e3440f96SFrançois Tigeot  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17e3440f96SFrançois Tigeot  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18e3440f96SFrançois Tigeot  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19e3440f96SFrançois Tigeot  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20e3440f96SFrançois Tigeot  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21e3440f96SFrançois Tigeot  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22e3440f96SFrançois Tigeot  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23e3440f96SFrançois Tigeot  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24e3440f96SFrançois Tigeot  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25e3440f96SFrançois Tigeot  */
26e3440f96SFrançois Tigeot 
27e3440f96SFrançois Tigeot #ifndef _ASM_BITOPS_NON_ATOMIC_H_
28e3440f96SFrançois Tigeot #define _ASM_BITOPS_NON_ATOMIC_H_
29e3440f96SFrançois Tigeot 
__set_bit(int nr,volatile unsigned long * addr)30e3440f96SFrançois Tigeot static inline void __set_bit(int nr, volatile unsigned long *addr)
31e3440f96SFrançois Tigeot {
32*a3268cb6SMatthew Dillon 	*(addr + (nr / BITS_PER_LONG)) |= (1LU << (nr % BITS_PER_LONG));
33e3440f96SFrançois Tigeot }
34e3440f96SFrançois Tigeot 
__clear_bit(int nr,volatile unsigned long * addr)35e3440f96SFrançois Tigeot static inline void __clear_bit(int nr, volatile unsigned long *addr)
36e3440f96SFrançois Tigeot {
37*a3268cb6SMatthew Dillon 	*(addr + (nr / BITS_PER_LONG)) &= ~(1LU << (nr % BITS_PER_LONG));
38e3440f96SFrançois Tigeot }
39e3440f96SFrançois Tigeot 
40e3440f96SFrançois Tigeot #endif	/* _ASM_BITOPS_NON_ATOMIC_H_ */
41