Received: from eggs.gnu.org ([2001:4830:134:3::10]:39628) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBkcI-0007Ys-32 for qemu-devel@nongnu.org; Tue, 29 Nov 2016 10:46:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cBkcH-0005NG-5h for qemu-devel@nongnu.org; Tue, 29 Nov 2016 10:46:46 -0500 Received: from 7.mo1.mail-out.ovh.net ([87.98.158.110]:45321) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cBkcG-0005Mh-VZ for qemu-devel@nongnu.org; Tue, 29 Nov 2016 10:46:45 -0500 Received: from player795.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo1.mail-out.ovh.net (Postfix) with ESMTP id 6FB141F911 for ; Tue, 29 Nov 2016 16:46:43 +0100 (CET) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Date: Tue, 29 Nov 2016 16:43:52 +0100 Message-Id: <1480434248-27138-15-git-send-email-clg@kaod.org> In-Reply-To: <1480434248-27138-1-git-send-email-clg@kaod.org> References: <1480434248-27138-1-git-send-email-clg@kaod.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH for-2.9 14/30] aspeed/smc: rework the prototype of the AspeedSMCFlash helper routines List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Andrew Jeffery , Marcin Krzeminski , Peter Crosthwaite , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Change the routines prototype to use a 'AspeedSMCFlash *' instead of 'AspeedSMCState *'. The result will help in making future changes clearer. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Joel Stanley Reviewed-by: Andrew Jeffery --- hw/ssi/aspeed_smc.c | 36 ++++++++++++++++++++++++------------ include/hw/ssi/aspeed_smc.h | 2 +- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c index 78f5aed53247..66622f198a2f 100644 --- a/hw/ssi/aspeed_smc.c +++ b/hw/ssi/aspeed_smc.c @@ -328,19 +328,30 @@ static const MemoryRegionOps aspeed_smc_flash_defau= lt_ops =3D { }, }; =20 -static inline int aspeed_smc_flash_mode(const AspeedSMCState *s, int cs) +static inline int aspeed_smc_flash_mode(const AspeedSMCFlash *fl) { - return s->regs[s->r_ctrl0 + cs] & CTRL_CMD_MODE_MASK; + AspeedSMCState *s =3D fl->controller; + + return s->regs[s->r_ctrl0 + fl->id] & CTRL_CMD_MODE_MASK; +} + +static inline bool aspeed_smc_is_usermode(const AspeedSMCFlash *fl) +{ + return aspeed_smc_flash_mode(fl) =3D=3D CTRL_USERMODE; } =20 -static inline bool aspeed_smc_is_usermode(const AspeedSMCState *s, int c= s) +static inline bool aspeed_smc_is_ce_stop_active(const AspeedSMCFlash *fl= ) { - return aspeed_smc_flash_mode(s, cs) =3D=3D CTRL_USERMODE; + AspeedSMCState *s =3D fl->controller; + + return s->regs[s->r_ctrl0 + fl->id] & CTRL_CE_STOP_ACTIVE; } =20 -static inline bool aspeed_smc_is_writable(const AspeedSMCState *s, int c= s) +static inline bool aspeed_smc_is_writable(const AspeedSMCFlash *fl) { - return s->regs[s->r_conf] & (1 << (s->conf_enable_w0 + cs)); + AspeedSMCState *s =3D fl->controller; + + return s->regs[s->r_conf] & (1 << (s->conf_enable_w0 + fl->id)); } =20 static uint64_t aspeed_smc_flash_read(void *opaque, hwaddr addr, unsigne= d size) @@ -350,7 +361,7 @@ static uint64_t aspeed_smc_flash_read(void *opaque, h= waddr addr, unsigned size) uint64_t ret =3D 0; int i; =20 - if (aspeed_smc_is_usermode(s, fl->id)) { + if (aspeed_smc_is_usermode(fl)) { for (i =3D 0; i < size; i++) { ret |=3D ssi_transfer(s->spi, 0x0) << (8 * i); } @@ -370,13 +381,13 @@ static void aspeed_smc_flash_write(void *opaque, hw= addr addr, uint64_t data, const AspeedSMCState *s =3D fl->controller; int i; =20 - if (!aspeed_smc_is_writable(s, fl->id)) { + if (!aspeed_smc_is_writable(fl)) { qemu_log_mask(LOG_GUEST_ERROR, "%s: flash is not writable at 0x%= " HWADDR_PRIx "\n", __func__, addr); return; } =20 - if (!aspeed_smc_is_usermode(s, fl->id)) { + if (!aspeed_smc_is_usermode(fl)) { qemu_log_mask(LOG_UNIMP, "%s: usermode not implemented\n", __func__); return; @@ -397,9 +408,10 @@ static const MemoryRegionOps aspeed_smc_flash_ops =3D= { }, }; =20 -static bool aspeed_smc_is_ce_stop_active(const AspeedSMCState *s, int cs= ) +static void aspeed_smc_flash_update_cs(AspeedSMCFlash *fl) { - return s->regs[s->r_ctrl0 + cs] & CTRL_CE_STOP_ACTIVE; + AspeedSMCState *s =3D fl->controller; + qemu_set_irq(s->cs_lines[fl->id], aspeed_smc_is_ce_stop_active(fl)); } =20 static void aspeed_smc_update_cs(const AspeedSMCState *s) @@ -407,7 +419,7 @@ static void aspeed_smc_update_cs(const AspeedSMCState= *s) int i; =20 for (i =3D 0; i < s->num_cs; ++i) { - qemu_set_irq(s->cs_lines[i], aspeed_smc_is_ce_stop_active(s, i))= ; + aspeed_smc_flash_update_cs(&s->flashes[i]); } } =20 diff --git a/include/hw/ssi/aspeed_smc.h b/include/hw/ssi/aspeed_smc.h index bdfbcc0ffa7d..c64954f6103f 100644 --- a/include/hw/ssi/aspeed_smc.h +++ b/include/hw/ssi/aspeed_smc.h @@ -47,7 +47,7 @@ typedef struct AspeedSMCController { } AspeedSMCController; =20 typedef struct AspeedSMCFlash { - const struct AspeedSMCState *controller; + struct AspeedSMCState *controller; =20 uint8_t id; uint32_t size; --=20 2.7.4