Skip to content

Commit cc1b92e

Browse files
pizi-nordiccarlescufi
authored andcommitted
drivers: entropy: Use likely()/unlikely() macros to speed up the API
This commit introduces usage of likely()/unlikely() macros in order to speed up the entropy_get_entropy_isr() API. Signed-off-by: Piotr Zięcik <[email protected]>
1 parent 615efcc commit cc1b92e

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

drivers/entropy/entropy_nrf5.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ static int entropy_nrf5_get_entropy_isr(struct device *dev, u8_t *buf, u16_t len
256256
/* Check if this API is called on correct driver instance. */
257257
__ASSERT_NO_MSG(&entropy_nrf5_data == DEV_DATA(dev));
258258

259-
if (!(flags & ENTROPY_BUSYWAIT)) {
259+
if (likely((flags & ENTROPY_BUSYWAIT) == 0)) {
260260
return rng_pool_get((struct rng_pool *)(entropy_nrf5_data.isr),
261261
buf, len);
262262
}

include/entropy.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@ static inline int entropy_get_entropy_isr(struct device *dev,
9696
{
9797
const struct entropy_driver_api *api = dev->driver_api;
9898

99-
if (!api->get_entropy_isr) {
99+
if (unlikely(!api->get_entropy_isr)) {
100100
return -ENOTSUP;
101101
}
102+
102103
return api->get_entropy_isr(dev, buffer, length, flags);
103104
}
104105

0 commit comments

Comments
 (0)