diff --git a/core/arch/arm/include/sm/optee_smc.h b/core/arch/arm/include/sm/optee_smc.h index cd45917d776..04a3839a2c1 100644 --- a/core/arch/arm/include/sm/optee_smc.h +++ b/core/arch/arm/include/sm/optee_smc.h @@ -530,7 +530,7 @@ * a0 OPTEE_SMC_RETURN_OK * a1 value * a2 Bit[0]: OPTEE_SMC_ASYNC_NOTIF_VALUE_VALID if the value in a1 is - * valid, else 0 if no values where pending + * valid, else 0 if no values were pending * a2 Bit[1]: OPTEE_SMC_ASYNC_NOTIF_VALUE_PENDING if another value is * pending, else 0. * Bit[31:2]: MBZ diff --git a/lib/libutils/ext/include/bitstring.h b/lib/libutils/ext/include/bitstring.h index e160ae76f3e..bebf092a370 100644 --- a/lib/libutils/ext/include/bitstring.h +++ b/lib/libutils/ext/include/bitstring.h @@ -126,22 +126,34 @@ typedef unsigned char bitstr_t; } while (0) /* find first bit set in name */ -#define bit_ffs(name, nbits, value) do { \ - register bitstr_t *_name = (name); \ - register int _byte, _nbits = (nbits); \ - register int _stopbyte = _bit_byte(_nbits - 1), _value = -1; \ - if (_nbits > 0) \ - for (_byte = 0; _byte <= _stopbyte; ++_byte) \ - if (_name[_byte]) { \ - bitstr_t _lb; \ +#define bit_ffs_from(name, nbits, startbit, value) do { \ + bitstr_t *_name = (name); \ + int _byte = 0; \ + int _nbits = (nbits); \ + int _startbyte = _bit_byte(startbit); \ + int _stopbyte = _bit_byte(_nbits - 1), _value = -1; \ + bitstr_t _test_bit_mask = 0xff << ((startbit) % 8); \ + \ + if (_nbits > 0) { \ + for (_byte = _startbyte; _byte <= _stopbyte; ++_byte) { \ + if (_name[_byte] & _test_bit_mask) { \ + bitstr_t _lb = 0; \ + \ _value = _byte << 3; \ - for (_lb = _name[_byte]; !(_lb&0x1); \ - ++_value, _lb >>= 1); \ + for (_lb = _name[_byte] & _test_bit_mask; \ + !(_lb&0x1); ++_value, _lb >>= 1) \ + ; \ break; \ } \ + _test_bit_mask = 0xff; \ + } \ + } \ if (_value >= nbits) \ _value = -1; \ *(value) = _value; \ } while (0) +#define bit_ffs(name, nbits, value) \ + bit_ffs_from((name), (nbits), 0, (value)) + #endif /* !_SYS_BITSTRING_H_ */ diff --git a/mk/config.mk b/mk/config.mk index 99a5399dd8d..d204a454998 100644 --- a/mk/config.mk +++ b/mk/config.mk @@ -927,7 +927,7 @@ ifeq (y-y,$(CFG_WITH_PAGER)-$(CFG_MEMTAG)) $(error CFG_WITH_PAGER and CFG_MEMTAG are not compatible) endif -# CFG_CORE_ASYNC_NOTIF is defined by the platform to enable enables support +# CFG_CORE_ASYNC_NOTIF is defined by the platform to enable support # for sending asynchronous notifications to normal world. Note that an # interrupt ID must be configurged by the platform too. Currently is only # CFG_CORE_ASYNC_NOTIF_GIC_INTID defined.