From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Sven Schnelle <svens@stackframe.org>, qemu-devel@nongnu.org
Cc: Fam Zheng <fam@euphon.net>, Paolo Bonzini <pbonzini@redhat.com>,
deller@gmx.de
Subject: Re: [Qemu-devel] [PATCH 2/2] lsi: use ldn_le_p()/stn_le_p()
Date: Mon, 18 Feb 2019 22:39:54 +0100 [thread overview]
Message-ID: <861e47de-978b-b48c-d144-e50040d45bf4@redhat.com> (raw)
In-Reply-To: <20190218175529.11237-2-svens@stackframe.org>
Hi Sven,
On 2/18/19 6:55 PM, Sven Schnelle wrote:
> Signed-off-by: Sven Schnelle <svens@stackframe.org>
> ---
> hw/scsi/lsi53c895a.c | 19 ++-----------------
> 1 file changed, 2 insertions(+), 17 deletions(-)
>
> diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c
> index c493e3c4c7..93c4434bfb 100644
> --- a/hw/scsi/lsi53c895a.c
> +++ b/hw/scsi/lsi53c895a.c
> @@ -2078,29 +2078,14 @@ static void lsi_ram_write(void *opaque, hwaddr addr,
> uint64_t val, unsigned size)
> {
> LSIState *s = opaque;
> - uint32_t newval;
> - uint32_t mask;
> - int shift;
> -
> - newval = s->script_ram[addr >> 2];
> - shift = (addr & 3) * 8;
> - mask = ((uint64_t)1 << (size * 8)) - 1;
> - newval &= ~(mask << shift);
> - newval |= val << shift;
> - s->script_ram[addr >> 2] = newval;
> + stn_le_p(((void*)s->script_ram) + addr, size, val);
If you want to do pointer arithmetic, it is safer to cast to a uintptr_t.
But since you update all the places that use script_ram[], it seems
pointless to keep it as an array of uint32_t. We can simply convert it
to an array of char.
Your patch looks sane otherwise,
Thanks,
Phil.
> }
>
> static uint64_t lsi_ram_read(void *opaque, hwaddr addr,
> unsigned size)
> {
> LSIState *s = opaque;
> - uint32_t val;
> - uint32_t mask;
> -
> - val = s->script_ram[addr >> 2];
> - mask = ((uint64_t)1 << (size * 8)) - 1;
> - val >>= (addr & 3) * 8;
> - return val & mask;
> + return ldn_le_p(((void *)s->script_ram) + addr, size);
> }
>
> static const MemoryRegionOps lsi_ram_ops = {
>
next prev parent reply other threads:[~2019-02-18 21:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-18 17:55 [Qemu-devel] [PATCH 1/2] lsi: 810/895A are always little endian Sven Schnelle
2019-02-18 17:55 ` [Qemu-devel] [PATCH 2/2] lsi: use ldn_le_p()/stn_le_p() Sven Schnelle
2019-02-18 21:39 ` Philippe Mathieu-Daudé [this message]
2019-02-18 21:46 ` Peter Maydell
2019-02-19 7:38 ` Sven Schnelle
2019-03-08 19:40 ` [Qemu-devel] [PATCH 1/2] lsi: 810/895A are always little endian Sven Schnelle
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=861e47de-978b-b48c-d144-e50040d45bf4@redhat.com \
--to=philmd@redhat.com \
--cc=deller@gmx.de \
--cc=fam@euphon.net \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=svens@stackframe.org \
/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).