[PATCH v2 2/2] hw/registerfields: Use 64-bit bitfield for FIELD_DP64

Joe Komlodi posted 2 patches 4 years, 6 months ago
Maintainers: Alistair Francis <alistair@alistair23.me>
There is a newer version of this series
[PATCH v2 2/2] hw/registerfields: Use 64-bit bitfield for FIELD_DP64
Posted by Joe Komlodi 4 years, 6 months ago
If we have a field that's wider than 32-bits, we need a data type wide enough to
be able to create the bitfield used to deposit the value.

Signed-off-by: Joe Komlodi <joe.komlodi@xilinx.com>
---
 include/hw/registerfields.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/hw/registerfields.h b/include/hw/registerfields.h
index 9a03ac5..f2a3c9c 100644
--- a/include/hw/registerfields.h
+++ b/include/hw/registerfields.h
@@ -95,7 +95,7 @@
     _d; })
 #define FIELD_DP64(storage, reg, field, val) ({                           \
     struct {                                                              \
-        unsigned int v:R_ ## reg ## _ ## field ## _LENGTH;                \
+        uint64_t v:R_ ## reg ## _ ## field ## _LENGTH;                \
     } _v = { .v = val };                                                  \
     uint64_t _d;                                                          \
     _d = deposit64((storage), R_ ## reg ## _ ## field ## _SHIFT,          \
-- 
2.7.4


Re: [PATCH v2 2/2] hw/registerfields: Use 64-bit bitfield for FIELD_DP64
Posted by Alistair Francis 4 years, 6 months ago
On Tue, Jul 20, 2021 at 8:03 AM Joe Komlodi <joe.komlodi@xilinx.com> wrote:
>
> If we have a field that's wider than 32-bits, we need a data type wide enough to
> be able to create the bitfield used to deposit the value.
>
> Signed-off-by: Joe Komlodi <joe.komlodi@xilinx.com>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  include/hw/registerfields.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/hw/registerfields.h b/include/hw/registerfields.h
> index 9a03ac5..f2a3c9c 100644
> --- a/include/hw/registerfields.h
> +++ b/include/hw/registerfields.h
> @@ -95,7 +95,7 @@
>      _d; })
>  #define FIELD_DP64(storage, reg, field, val) ({                           \
>      struct {                                                              \
> -        unsigned int v:R_ ## reg ## _ ## field ## _LENGTH;                \
> +        uint64_t v:R_ ## reg ## _ ## field ## _LENGTH;                \
>      } _v = { .v = val };                                                  \
>      uint64_t _d;                                                          \
>      _d = deposit64((storage), R_ ## reg ## _ ## field ## _SHIFT,          \
> --
> 2.7.4
>
>

Re: [PATCH v2 2/2] hw/registerfields: Use 64-bit bitfield for FIELD_DP64
Posted by Philippe Mathieu-Daudé 4 years, 6 months ago
On 7/20/21 12:02 AM, Joe Komlodi wrote:
> If we have a field that's wider than 32-bits, we need a data type wide enough to
> be able to create the bitfield used to deposit the value.
> 
> Signed-off-by: Joe Komlodi <joe.komlodi@xilinx.com>
> ---
>  include/hw/registerfields.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>