bits.h: replace all inline defination of __set_bit/__clear_bit

Signed-off-by: liaoao <liaoao@xiaomi.com>
This commit is contained in:
liaoao 2024-01-26 17:23:37 +08:00 committed by Xiang Xiao
parent b98d68599e
commit d8d7f3c38e
2 changed files with 2 additions and 64 deletions

View File

@ -271,37 +271,6 @@ static struct max7219_dev_s g_max7219dev =
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
/****************************************************************************
* __set_bit - Set a bit in memory
*
* nr - The bit to set
* addr - The address to start counting from
*
* Unlike set_bit(), this function is non-atomic and may be reordered.
* If it's called on the same region of memory simultaneously, the effect
* may be that only one operation succeeds.
*
****************************************************************************/
static inline void __set_bit(int nr, uint8_t *addr)
{
uint8_t mask = BIT_BYTE_MASK(nr);
uint8_t *p = ((FAR uint8_t *)addr) + BIT_BYTE(nr);
*p |= mask;
}
static inline void __clear_bit(int nr, uint8_t *addr)
{
uint8_t mask = BIT_BYTE_MASK(nr);
uint8_t *p = ((FAR uint8_t *)addr) + BIT_BYTE(nr);
*p &= ~mask;
}
static inline int __test_bit(int nr, const volatile uint8_t *addr)
{
return 1 & (addr[BIT_BYTE(nr)] >> (nr & (BITS_PER_BYTE - 1)));
}
/**************************************************************************** /****************************************************************************
* Name: max7219_powerstring * Name: max7219_powerstring
* *
@ -575,7 +544,7 @@ static int max7219_getrun(FAR struct lcd_dev_s *dev, fb_coord_t row,
for (i = 0; i < pixlen; i++) for (i = 0; i < pixlen; i++)
{ {
if (__test_bit(col % 8 + i, ptr)) if (test_bit(col % 8 + i, ptr))
{ {
*buffer |= usrmask; *buffer |= usrmask;
} }

View File

@ -232,37 +232,6 @@ static struct memlcd_dev_s g_memlcddev =
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
/****************************************************************************
* __set_bit - Set a bit in memory
*
* @nr: the bit to set
* @addr: the address to start counting from
*
* This function is not atomic and may be reordered. If it's called on the
* same region of memory simultaneously, the effect may be that only one
* operation succeeds.
*
****************************************************************************/
static inline void __set_bit(int nr, uint8_t *addr)
{
uint8_t mask = BIT_BYTE_MASK(nr);
uint8_t *p = ((FAR uint8_t *)addr) + BIT_BYTE(nr);
*p |= mask;
}
static inline void __clear_bit(int nr, uint8_t *addr)
{
uint8_t mask = BIT_BYTE_MASK(nr);
uint8_t *p = ((FAR uint8_t *)addr) + BIT_BYTE(nr);
*p &= ~mask;
}
static inline int __test_bit(int nr, FAR const volatile uint8_t *addr)
{
return 1 & (addr[BIT_BYTE(nr)] >> (nr & (BITS_PER_BYTE - 1)));
}
/**************************************************************************** /****************************************************************************
* Name: memlcd_worker * Name: memlcd_worker
* *
@ -557,7 +526,7 @@ static int memlcd_getrun(FAR struct lcd_dev_s *dev,
p = pfb + (col >> 3); p = pfb + (col >> 3);
for (i = 0; i < npixels; i++) for (i = 0; i < npixels; i++)
{ {
if (__test_bit(col % 8 + i, p)) if (test_bit(col % 8 + i, p))
{ {
*buffer |= usrmask; *buffer |= usrmask;
} }