From: Peter Maydell <peter.maydell@linaro.org>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: qemu-devel@nongnu.org, Paul Brook <paul@codesourcery.com>
Subject: [Qemu-devel] [PULL 6/8] block/nand: QOM casting sweep
Date: Tue, 25 Jun 2013 19:21:54 +0100 [thread overview]
Message-ID: <1372184516-32397-7-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1372184516-32397-1-git-send-email-peter.maydell@linaro.org>
From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Define and use standard QOM cast macro. Remove usages of DO_UPCAST and
direct -> style casting.
Cc: afaerber@suse.de
Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/block/nand.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/hw/block/nand.c b/hw/block/nand.c
index 43401a0..861e893 100644
--- a/hw/block/nand.c
+++ b/hw/block/nand.c
@@ -82,6 +82,11 @@ struct NANDFlashState {
uint32_t ioaddr_vmstate;
};
+#define TYPE_NAND "nand"
+
+#define NAND(obj) \
+ OBJECT_CHECK(NANDFlashState, (obj), TYPE_NAND)
+
static void mem_and(uint8_t *dest, const uint8_t *src, size_t n)
{
/* Like memcpy() but we logical-AND the data into the destination */
@@ -224,7 +229,7 @@ static const struct {
static void nand_reset(DeviceState *dev)
{
- NANDFlashState *s = FROM_SYSBUS(NANDFlashState, SYS_BUS_DEVICE(dev));
+ NANDFlashState *s = NAND(dev);
s->cmd = NAND_CMD_READ0;
s->addr = 0;
s->addrlen = 0;
@@ -279,7 +284,7 @@ static void nand_command(NANDFlashState *s)
break;
case NAND_CMD_RESET:
- nand_reset(&s->busdev.qdev);
+ nand_reset(DEVICE(s));
break;
case NAND_CMD_PAGEPROGRAM1:
@@ -319,14 +324,14 @@ static void nand_command(NANDFlashState *s)
static void nand_pre_save(void *opaque)
{
- NANDFlashState *s = opaque;
+ NANDFlashState *s = NAND(opaque);
s->ioaddr_vmstate = s->ioaddr - s->io;
}
static int nand_post_load(void *opaque, int version_id)
{
- NANDFlashState *s = opaque;
+ NANDFlashState *s = NAND(opaque);
if (s->ioaddr_vmstate > sizeof(s->io)) {
return -EINVAL;
@@ -365,7 +370,7 @@ static const VMStateDescription vmstate_nand = {
static int nand_device_init(SysBusDevice *dev)
{
int pagesize;
- NANDFlashState *s = FROM_SYSBUS(NANDFlashState, dev);
+ NANDFlashState *s = NAND(dev);
s->buswidth = nand_flash_ids[s->chip_id].width >> 3;
s->size = nand_flash_ids[s->chip_id].size << 20;
@@ -436,7 +441,7 @@ static void nand_class_init(ObjectClass *klass, void *data)
}
static const TypeInfo nand_info = {
- .name = "nand",
+ .name = TYPE_NAND,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(NANDFlashState),
.class_init = nand_class_init,
@@ -456,7 +461,8 @@ static void nand_register_types(void)
void nand_setpins(DeviceState *dev, uint8_t cle, uint8_t ale,
uint8_t ce, uint8_t wp, uint8_t gnd)
{
- NANDFlashState *s = (NANDFlashState *) dev;
+ NANDFlashState *s = NAND(dev);
+
s->cle = cle;
s->ale = ale;
s->ce = ce;
@@ -477,7 +483,8 @@ void nand_getpins(DeviceState *dev, int *rb)
void nand_setio(DeviceState *dev, uint32_t value)
{
int i;
- NANDFlashState *s = (NANDFlashState *) dev;
+ NANDFlashState *s = NAND(dev);
+
if (!s->ce && s->cle) {
if (nand_flash_ids[s->chip_id].options & NAND_SAMSUNG_LP) {
if (s->cmd == NAND_CMD_READ0 && value == NAND_CMD_LPREAD2)
@@ -581,7 +588,7 @@ uint32_t nand_getio(DeviceState *dev)
{
int offset;
uint32_t x = 0;
- NANDFlashState *s = (NANDFlashState *) dev;
+ NANDFlashState *s = NAND(dev);
/* Allow sequential reading */
if (!s->iolen && s->cmd == NAND_CMD_READ0) {
--
1.7.9.5
next prev parent reply other threads:[~2013-06-25 18:54 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-25 18:21 [Qemu-devel] [PULL 0/8] arm-devs queue Peter Maydell
2013-06-25 18:21 ` [Qemu-devel] [PULL 1/8] ARM: Allow dumping of device tree Peter Maydell
2013-06-25 18:21 ` [Qemu-devel] [PULL 2/8] i.MX: Implement a more complete version of the GPT timer Peter Maydell
2013-06-25 18:42 ` Paolo Bonzini
2013-06-25 20:53 ` Peter Maydell
2013-06-26 6:56 ` Paolo Bonzini
2013-06-26 7:08 ` jcd
2013-06-26 7:11 ` Paolo Bonzini
2013-06-26 7:17 ` jcd
2013-06-26 7:21 ` Peter Crosthwaite
2013-06-26 18:58 ` Jean-Christophe DUBOIS
2013-06-26 21:13 ` Jean-Christophe DUBOIS
2013-06-26 21:18 ` Paolo Bonzini
2013-06-26 21:57 ` Jean-Christophe DUBOIS
2013-06-26 22:15 ` Peter Maydell
2013-06-26 22:32 ` Jean-Christophe DUBOIS
2013-06-27 10:46 ` Peter Maydell
2013-06-26 22:17 ` Andreas Färber
2013-06-25 18:21 ` [Qemu-devel] [PULL 3/8] i.MX: Rework functions/types name and use new style initialization Peter Maydell
2013-06-25 18:21 ` [Qemu-devel] [PULL 4/8] arm/boot: Free dtb blob memory after use Peter Maydell
2013-06-25 18:21 ` [Qemu-devel] [PULL 5/8] i.MX31: Fix PRCS bit test Peter Maydell
2013-06-25 18:21 ` Peter Maydell [this message]
2013-06-25 18:21 ` [Qemu-devel] [PULL 7/8] block/nand: Convert Sysbus::init to Device::realize Peter Maydell
2013-06-25 18:21 ` [Qemu-devel] [PULL 8/8] nand: Don't inherit from Sysbus Peter Maydell
2013-06-25 19:07 ` [Qemu-devel] [PULL 0/8] arm-devs queue Anthony Liguori
2013-06-25 20:49 ` Peter Maydell
2013-06-25 21:45 ` Anthony Liguori
2013-06-25 22:01 ` Peter Maydell
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=1372184516-32397-7-git-send-email-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=aliguori@us.ibm.com \
--cc=paul@codesourcery.com \
--cc=qemu-devel@nongnu.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).