aboutsummaryrefslogtreecommitdiff
path: root/hw/nvram
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2013-04-07 19:08:16 +0000
committerAlexander Graf <agraf@suse.de>2013-04-26 23:02:41 +0200
commitfd506b4f61cd22793f8c54a9adf5c69345792501 (patch)
treedc56e93e2f809255420ccf8b7248d8cd40ff7962 /hw/nvram
parent9b00ea4906a618756bcd10f09d432780eab87782 (diff)
pseries: Convert VIO code to QOM style type safe(ish) casts
Curerntly the pseries VIO device code contains quite a few explicit uses of DO_UPCAST and plain C casts. This is (obviously) type unsafe, and not the conventional way of doing things in the QOM model. This patch converts the code to use the QOM convention of per-type macros to do verified casts with OBJECT_CHECK(). Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'hw/nvram')
-rw-r--r--hw/nvram/spapr_nvram.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/hw/nvram/spapr_nvram.c b/hw/nvram/spapr_nvram.c
index 0cc6cba0e3..1eb05c9075 100644
--- a/hw/nvram/spapr_nvram.c
+++ b/hw/nvram/spapr_nvram.c
@@ -36,6 +36,10 @@ typedef struct sPAPRNVRAM {
BlockDriverState *drive;
} sPAPRNVRAM;
+#define TYPE_VIO_SPAPR_NVRAM "spapr-nvram"
+#define VIO_SPAPR_NVRAM(obj) \
+ OBJECT_CHECK(sPAPRNVRAM, (obj), TYPE_VIO_SPAPR_NVRAM)
+
#define MIN_NVRAM_SIZE 8192
#define DEFAULT_NVRAM_SIZE 65536
#define MAX_NVRAM_SIZE (UINT16_MAX * 16)
@@ -134,7 +138,7 @@ static void rtas_nvram_store(sPAPREnvironment *spapr,
static int spapr_nvram_init(VIOsPAPRDevice *dev)
{
- sPAPRNVRAM *nvram = (sPAPRNVRAM *)dev;
+ sPAPRNVRAM *nvram = VIO_SPAPR_NVRAM(dev);
if (nvram->drive) {
nvram->size = bdrv_getlength(nvram->drive);
@@ -157,7 +161,7 @@ static int spapr_nvram_init(VIOsPAPRDevice *dev)
static int spapr_nvram_devnode(VIOsPAPRDevice *dev, void *fdt, int node_off)
{
- sPAPRNVRAM *nvram = (sPAPRNVRAM *)dev;
+ sPAPRNVRAM *nvram = VIO_SPAPR_NVRAM(dev);
return fdt_setprop_cell(fdt, node_off, "#bytes", nvram->size);
}
@@ -182,7 +186,7 @@ static void spapr_nvram_class_init(ObjectClass *klass, void *data)
}
static const TypeInfo spapr_nvram_type_info = {
- .name = "spapr-nvram",
+ .name = TYPE_VIO_SPAPR_NVRAM,
.parent = TYPE_VIO_SPAPR_DEVICE,
.instance_size = sizeof(sPAPRNVRAM),
.class_init = spapr_nvram_class_init,