qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alistair Francis <alistair23@gmail.com>
To: Wilfred Mallawa <wilfred.mallawa@opensource.wdc.com>
Cc: alistair@alistair23.me, qemu-devel@nongnu.org,
	 Wilfred Mallawa <wilfred.mallawa@wdc.com>
Subject: Re: [RFC v2] hw/registerfields: add `FIELDx_1CLEAR()` macro
Date: Mon, 10 Oct 2022 11:29:55 +1000	[thread overview]
Message-ID: <CAKmqyKNc2OWytDTq7JNix1NKjvufFKnCMyHCgXNSv+EoM-mfQg@mail.gmail.com> (raw)
In-Reply-To: <20220927005429.146974-1-wilfred.mallawa@opensource.wdc.com>

On Tue, Sep 27, 2022 at 10:58 AM Wilfred Mallawa
<wilfred.mallawa@opensource.wdc.com> wrote:
>
> From: Wilfred Mallawa <wilfred.mallawa@wdc.com>
>
> Changes from V1:
>         * Instead of needing all field bits to be set
>           we clear the field if any are set. If the field is
>           0/clear then no change.

The changelog should go

>
> Adds a helper macro that implements the register `w1c`
> functionality.
>
> Ex:
>   uint32_t data = FIELD32_1CLEAR(val, REG, FIELD);
>
> If ANY bits of the specified `FIELD` is set
> then the respective field is cleared and returned to `data`.
>
> If the field is cleared (0), then no change and
> val is returned.
>
> Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
> ---

Below this line.

Otherwise the patch looks good. Do you mind adding it to a series that
converts the OT SPI to use these macros?

>  include/hw/registerfields.h | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
>
> diff --git a/include/hw/registerfields.h b/include/hw/registerfields.h
> index 1330ca77de..4a6a228339 100644
> --- a/include/hw/registerfields.h
> +++ b/include/hw/registerfields.h
> @@ -115,6 +115,28 @@
>                    R_ ## reg ## _ ## field ## _LENGTH, _v.v);              \
>      _d; })
>
> +/*
> + * Clear the specified field in reg_val if
> + * any field bits are set, else no changes made. Implements
> + * single/multi-bit `w1c`
> + *
> + */
> +#define FIELD8_1CLEAR(reg_val, reg, field)                                \

These should probably match the other macros with:

(storage, reg, field)

Alistair


  reply	other threads:[~2022-10-10  1:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-27  0:54 [RFC v2] hw/registerfields: add `FIELDx_1CLEAR()` macro Wilfred Mallawa
2022-10-10  1:29 ` Alistair Francis [this message]
2022-10-10  1:53   ` Wilfred Mallawa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKmqyKNc2OWytDTq7JNix1NKjvufFKnCMyHCgXNSv+EoM-mfQg@mail.gmail.com \
    --to=alistair23@gmail.com \
    --cc=alistair@alistair23.me \
    --cc=qemu-devel@nongnu.org \
    --cc=wilfred.mallawa@opensource.wdc.com \
    --cc=wilfred.mallawa@wdc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).