71 lines
2.7 KiB
Diff
71 lines
2.7 KiB
Diff
|
|
From e6b4460566522f1a9d608217bcb1534bf6709cab Mon Sep 17 00:00:00 2001
|
||
|
|
From: Zhang Jiao <zhangjiao2_yewu@cmss.chinamobile.com>
|
||
|
|
Date: Thu, 12 Dec 2024 12:16:01 +0800
|
||
|
|
Subject: [PATCH] hw/misc/nrf51_rng: Don't use BIT_MASK() when we mean BIT()
|
||
|
|
MIME-Version: 1.0
|
||
|
|
Content-Type: text/plain; charset=UTF-8
|
||
|
|
Content-Transfer-Encoding: 8bit
|
||
|
|
|
||
|
|
cheery-pick from a29a9776407e68c5560687e07828925bda710150
|
||
|
|
|
||
|
|
The BIT_MASK() macro from bitops.h provides the mask of a bit
|
||
|
|
within a particular word of a multi-word bit array; it is intended
|
||
|
|
to be used with its counterpart BIT_WORD() that gives the index
|
||
|
|
of the word in the array.
|
||
|
|
|
||
|
|
In nrf51_rng we are using it for cases where we have a bit number
|
||
|
|
that we know is the index of a bit within a single word (in fact, it
|
||
|
|
happens that all the bit numbers we pass to it are zero). This
|
||
|
|
happens to give the right answer, but the macro that actually
|
||
|
|
does the job we want here is BIT().
|
||
|
|
|
||
|
|
Use BIT() instead of BIT_MASK().
|
||
|
|
|
||
|
|
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
||
|
|
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
||
|
|
Message-ID: <20241108135644.4007151-1-peter.maydell@linaro.org>
|
||
|
|
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
||
|
|
Signed-off-by: Zhang Jiao <zhangjiao2_yewu@cmss.chinamobile.com>
|
||
|
|
---
|
||
|
|
hw/misc/nrf51_rng.c | 10 +++++-----
|
||
|
|
1 file changed, 5 insertions(+), 5 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/hw/misc/nrf51_rng.c b/hw/misc/nrf51_rng.c
|
||
|
|
index fc86e1b697..e911b3a3a3 100644
|
||
|
|
--- a/hw/misc/nrf51_rng.c
|
||
|
|
+++ b/hw/misc/nrf51_rng.c
|
||
|
|
@@ -107,25 +107,25 @@ static void rng_write(void *opaque, hwaddr offset,
|
||
|
|
break;
|
||
|
|
case NRF51_RNG_REG_SHORTS:
|
||
|
|
s->shortcut_stop_on_valrdy =
|
||
|
|
- (value & BIT_MASK(NRF51_RNG_REG_SHORTS_VALRDY_STOP)) ? 1 : 0;
|
||
|
|
+ (value & BIT(NRF51_RNG_REG_SHORTS_VALRDY_STOP)) ? 1 : 0;
|
||
|
|
break;
|
||
|
|
case NRF51_RNG_REG_INTEN:
|
||
|
|
s->interrupt_enabled =
|
||
|
|
- (value & BIT_MASK(NRF51_RNG_REG_INTEN_VALRDY)) ? 1 : 0;
|
||
|
|
+ (value & BIT(NRF51_RNG_REG_INTEN_VALRDY)) ? 1 : 0;
|
||
|
|
break;
|
||
|
|
case NRF51_RNG_REG_INTENSET:
|
||
|
|
- if (value & BIT_MASK(NRF51_RNG_REG_INTEN_VALRDY)) {
|
||
|
|
+ if (value & BIT(NRF51_RNG_REG_INTEN_VALRDY)) {
|
||
|
|
s->interrupt_enabled = 1;
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
case NRF51_RNG_REG_INTENCLR:
|
||
|
|
- if (value & BIT_MASK(NRF51_RNG_REG_INTEN_VALRDY)) {
|
||
|
|
+ if (value & BIT(NRF51_RNG_REG_INTEN_VALRDY)) {
|
||
|
|
s->interrupt_enabled = 0;
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
case NRF51_RNG_REG_CONFIG:
|
||
|
|
s->filter_enabled =
|
||
|
|
- (value & BIT_MASK(NRF51_RNG_REG_CONFIG_DECEN)) ? 1 : 0;
|
||
|
|
+ (value & BIT(NRF51_RNG_REG_CONFIG_DECEN)) ? 1 : 0;
|
||
|
|
break;
|
||
|
|
|
||
|
|
default:
|
||
|
|
--
|
||
|
|
2.41.0.windows.1
|
||
|
|
|