On 25/9/25 02:58, Coco Li wrote:
Signed-off-by: Coco Li <[email protected]>
Reviewed-by: Hao Wu <[email protected]>
---
  hw/gpio/npcm8xx_sgpio.c          | 134 ++++++++++++++++++++---
  include/hw/gpio/npcm8xx_sgpio.h  |   4 +-
  tests/qtest/npcm8xx_sgpio-test.c | 180 ++++++++++++++++++++++++++-----
  3 files changed, 274 insertions(+), 44 deletions(-)

diff --git a/hw/gpio/npcm8xx_sgpio.c b/hw/gpio/npcm8xx_sgpio.c


+static uint8_t get_even_bits(uint16_t n)
+{
+    n &= 0x5555;
+
+    n = (n | (n >> 1)) & 0x3333;
+    n = (n | (n >> 2)) & 0x0F0F;
+    n = (n | (n >> 4)) & 0x00FF;
+
+    return (uint8_t)n;
+}
+
+static uint8_t get_odd_bits(uint16_t n)
+{
+    return get_even_bits(n >> 1);
+}

Candidates for "include/qemu/bitops.h"?

Reply via email to