aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorAndreas Färber <afaerber@suse.de>2013-07-27 14:07:22 +0200
committerAndreas Färber <afaerber@suse.de>2013-07-29 21:07:01 +0200
commit3efc10e17d41779bbdaf27a304c8e39f744e530f (patch)
tree2687cf2a8f4ef114e3993c7ec2998d724e281025 /hw
parent3d29bceec1357702b2ce0909c6eb8107b806159e (diff)
xilinx_spi: QOM cast cleanup
Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'hw')
-rw-r--r--hw/ssi/xilinx_spi.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/hw/ssi/xilinx_spi.c b/hw/ssi/xilinx_spi.c
index 7a9fd81583..d44caae8ad 100644
--- a/hw/ssi/xilinx_spi.c
+++ b/hw/ssi/xilinx_spi.c
@@ -73,8 +73,12 @@
#define FIFO_CAPACITY 256
+#define TYPE_XILINX_SPI "xlnx.xps-spi"
+#define XILINX_SPI(obj) OBJECT_CHECK(XilinxSPI, (obj), TYPE_XILINX_SPI)
+
typedef struct XilinxSPI {
- SysBusDevice busdev;
+ SysBusDevice parent_obj;
+
MemoryRegion mmio;
qemu_irq irq;
@@ -109,7 +113,7 @@ static void rxfifo_reset(XilinxSPI *s)
static void xlx_spi_update_cs(XilinxSPI *s)
{
- int i;
+ int i;
for (i = 0; i < s->num_cs; ++i) {
qemu_set_irq(s->cs_lines[i], !(~s->regs[R_SPISSR] & 1 << i));
@@ -154,7 +158,7 @@ static void xlx_spi_do_reset(XilinxSPI *s)
static void xlx_spi_reset(DeviceState *d)
{
- xlx_spi_do_reset(DO_UPCAST(XilinxSPI, busdev.qdev, d));
+ xlx_spi_do_reset(XILINX_SPI(d));
}
static inline int spi_master_enabled(XilinxSPI *s)
@@ -314,25 +318,26 @@ static const MemoryRegionOps spi_ops = {
}
};
-static int xilinx_spi_init(SysBusDevice *dev)
+static int xilinx_spi_init(SysBusDevice *sbd)
{
+ DeviceState *dev = DEVICE(sbd);
+ XilinxSPI *s = XILINX_SPI(dev);
int i;
- XilinxSPI *s = FROM_SYSBUS(typeof(*s), dev);
DB_PRINT("\n");
- s->spi = ssi_create_bus(&dev->qdev, "spi");
+ s->spi = ssi_create_bus(dev, "spi");
- sysbus_init_irq(dev, &s->irq);
+ sysbus_init_irq(sbd, &s->irq);
s->cs_lines = g_new(qemu_irq, s->num_cs);
- ssi_auto_connect_slaves(DEVICE(s), s->cs_lines, s->spi);
+ ssi_auto_connect_slaves(dev, s->cs_lines, s->spi);
for (i = 0; i < s->num_cs; ++i) {
- sysbus_init_irq(dev, &s->cs_lines[i]);
+ sysbus_init_irq(sbd, &s->cs_lines[i]);
}
memory_region_init_io(&s->mmio, OBJECT(s), &spi_ops, s,
"xilinx-spi", R_MAX * 4);
- sysbus_init_mmio(dev, &s->mmio);
+ sysbus_init_mmio(sbd, &s->mmio);
s->irqline = -1;
@@ -372,7 +377,7 @@ static void xilinx_spi_class_init(ObjectClass *klass, void *data)
}
static const TypeInfo xilinx_spi_info = {
- .name = "xlnx.xps-spi",
+ .name = TYPE_XILINX_SPI,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(XilinxSPI),
.class_init = xilinx_spi_class_init,