mirror of
https://github.com/Fishwaldo/opensbi.git
synced 2025-03-15 19:31:32 +00:00
lib: sbi: Fix __atomic_op_bit_ord and comments
The original code returns the value of the word before modification. When modifying the upper 32 bits under RV64, the value returned via int return will have no meaning. Corrected to return the value of the bit. And modify the function description. Signed-off-by: Xiang W <wxjstz@126.com> Reviewed-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
parent
6b9a849482
commit
11bf49b444
2 changed files with 9 additions and 9 deletions
|
@ -39,14 +39,14 @@ unsigned int atomic_raw_xchg_uint(volatile unsigned int *ptr,
|
|||
unsigned long atomic_raw_xchg_ulong(volatile unsigned long *ptr,
|
||||
unsigned long newval);
|
||||
/**
|
||||
* Set a bit in an atomic variable and return the new value.
|
||||
* Set a bit in an atomic variable and return the value of bit before modify.
|
||||
* @nr : Bit to set.
|
||||
* @atom: atomic variable to modify
|
||||
*/
|
||||
int atomic_set_bit(int nr, atomic_t *atom);
|
||||
|
||||
/**
|
||||
* Clear a bit in an atomic variable and return the new value.
|
||||
* Clear a bit in an atomic variable and return the value of bit before modify.
|
||||
* @nr : Bit to set.
|
||||
* @atom: atomic variable to modify
|
||||
*/
|
||||
|
@ -54,14 +54,14 @@ int atomic_set_bit(int nr, atomic_t *atom);
|
|||
int atomic_clear_bit(int nr, atomic_t *atom);
|
||||
|
||||
/**
|
||||
* Set a bit in any address and return the new value .
|
||||
* Set a bit in any address and return the value of bit before modify.
|
||||
* @nr : Bit to set.
|
||||
* @addr: Address to modify
|
||||
*/
|
||||
int atomic_raw_set_bit(int nr, volatile unsigned long *addr);
|
||||
|
||||
/**
|
||||
* Clear a bit in any address and return the new value .
|
||||
* Clear a bit in any address and return the value of bit before modify.
|
||||
* @nr : Bit to set.
|
||||
* @addr: Address to modify
|
||||
*/
|
||||
|
|
|
@ -124,7 +124,7 @@ unsigned long atomic_raw_xchg_ulong(volatile unsigned long *ptr,
|
|||
: "=r"(__res), "+A"(addr[BIT_WORD(nr)]) \
|
||||
: "r"(mod(__mask)) \
|
||||
: "memory"); \
|
||||
__res; \
|
||||
__res & __mask ? 1 : 0; \
|
||||
})
|
||||
|
||||
#define __atomic_op_bit(op, mod, nr, addr) \
|
||||
|
@ -134,22 +134,22 @@ unsigned long atomic_raw_xchg_ulong(volatile unsigned long *ptr,
|
|||
#define __NOP(x) (x)
|
||||
#define __NOT(x) (~(x))
|
||||
|
||||
inline int atomic_raw_set_bit(int nr, volatile unsigned long *addr)
|
||||
int atomic_raw_set_bit(int nr, volatile unsigned long *addr)
|
||||
{
|
||||
return __atomic_op_bit(or, __NOP, nr, addr);
|
||||
}
|
||||
|
||||
inline int atomic_raw_clear_bit(int nr, volatile unsigned long *addr)
|
||||
int atomic_raw_clear_bit(int nr, volatile unsigned long *addr)
|
||||
{
|
||||
return __atomic_op_bit(and, __NOT, nr, addr);
|
||||
}
|
||||
|
||||
inline int atomic_set_bit(int nr, atomic_t *atom)
|
||||
int atomic_set_bit(int nr, atomic_t *atom)
|
||||
{
|
||||
return atomic_raw_set_bit(nr, (unsigned long *)&atom->counter);
|
||||
}
|
||||
|
||||
inline int atomic_clear_bit(int nr, atomic_t *atom)
|
||||
int atomic_clear_bit(int nr, atomic_t *atom)
|
||||
{
|
||||
return atomic_raw_clear_bit(nr, (unsigned long *)&atom->counter);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue