[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/6] bitops.h: add deposit16 function
From: |
Peter Maydell |
Subject: |
Re: [PATCH 1/6] bitops.h: add deposit16 function |
Date: |
Wed, 13 Nov 2024 15:46:19 +0000 |
On Thu, 7 Nov 2024 at 19:54, Titus Rwantare <titusr@google.com> wrote:
>
> Makes it more explicit that 16 bit values are being used
>
> Signed-off-by: Titus Rwantare <titusr@google.com>
> ---
> include/qemu/bitops.h | 26 ++++++++++++++++++++++++++
> 1 file changed, 26 insertions(+)
>
> diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h
> index 2c0a2fe751..05179e3ded 100644
> --- a/include/qemu/bitops.h
> +++ b/include/qemu/bitops.h
> @@ -459,6 +459,32 @@ static inline int64_t sextract64(uint64_t value, int
> start, int length)
> return ((int64_t)(value << (64 - length - start))) >> (64 - length);
> }
>
> +/**
> + * deposit16:
> + * @value: initial value to insert bit field into
> + * @start: the lowest bit in the bit field (numbered from 0)
> + * @length: the length of the bit field
> + * @fieldval: the value to insert into the bit field
> + *
> + * Deposit @fieldval into the 16 bit @value at the bit field specified
> + * by the @start and @length parameters, and return the modified
> + * @value. Bits of @value outside the bit field are not modified.
> + * Bits of @fieldval above the least significant @length bits are
> + * ignored. The bit field must lie entirely within the 16 bit word.
> + * It is valid to request that all 16 bits are modified (ie @length
> + * 16 and @start 0).
> + *
> + * Returns: the modified @value.
> + */
Why do we need this rather than using deposit32()?
See also the comments in this thread
https://lore.kernel.org/qemu-devel/CAFEAcA9H=w29-8CQStYYNwEU=OEB=NzxpioaqGEgSpc4KnPOHQ@mail.gmail.com/
where a deposit8() was proposed.
thanks
-- PMM
- [PATCH 0/6] Add Quanta GSZ BMC machine and PCA I2C GPIO expanders, Titus Rwantare, 2024/11/07
- [PATCH 1/6] bitops.h: add deposit16 function, Titus Rwantare, 2024/11/07
- [PATCH 2/6] hw/gpio: add PCA953x i2c GPIO expanders, Titus Rwantare, 2024/11/07
- [PATCH 4/6] hw/i2c: add canonical path to i2c event traces, Titus Rwantare, 2024/11/07
- [PATCH 5/6] hw/arm: imply I2C_DEVICES on NPCM7xx, Titus Rwantare, 2024/11/07
- [PATCH 3/6] hw/gpio: add PCA9536 i2c gpio expander, Titus Rwantare, 2024/11/07
- [PATCH 6/6] hw/arm: add Quanta GSZ bmc machine, Titus Rwantare, 2024/11/07