diff options
author | Greg Kurz <groug@kaod.org> | 2019-11-15 16:55:49 +0100 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2019-12-17 10:39:47 +1100 |
commit | ee3d27138da0cc44ba29258dc66c85ac9c4a6bad (patch) | |
tree | a41469d1bae1832b226125d1bdc89a9b942df801 /hw/ppc/pnv_occ.c | |
parent | b63f389366fbc586ce82f95ad808a51bc9f95c71 (diff) |
ppc/pnv: Link "psi" property to PnvOCC::psi pointer
The OCC object has both a pointer and a "psi" property pointing to the
PSI object. Confusing bugs could arise if these ever go out of sync.
Change the property definition so that it explicitely sets the pointer.
Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <157383334894.165747.7617090757862105199.stgit@bahia.lan>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'hw/ppc/pnv_occ.c')
-rw-r--r-- | hw/ppc/pnv_occ.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/hw/ppc/pnv_occ.c b/hw/ppc/pnv_occ.c index 785653bb67..765c0a6ce5 100644 --- a/hw/ppc/pnv_occ.c +++ b/hw/ppc/pnv_occ.c @@ -21,7 +21,7 @@ #include "qapi/error.h" #include "qemu/log.h" #include "qemu/module.h" - +#include "hw/qdev-properties.h" #include "hw/ppc/pnv.h" #include "hw/ppc/pnv_xscom.h" #include "hw/ppc/pnv_occ.h" @@ -257,18 +257,10 @@ static void pnv_occ_realize(DeviceState *dev, Error **errp) { PnvOCC *occ = PNV_OCC(dev); PnvOCCClass *poc = PNV_OCC_GET_CLASS(occ); - Object *obj; - Error *local_err = NULL; - occ->occmisc = 0; + assert(occ->psi); - obj = object_property_get_link(OBJECT(dev), "psi", &local_err); - if (!obj) { - error_propagate(errp, local_err); - error_prepend(errp, "required link 'psi' not found: "); - return; - } - occ->psi = PNV_PSI(obj); + occ->occmisc = 0; /* XScom region for OCC registers */ pnv_xscom_region_init(&occ->xscom_regs, OBJECT(dev), poc->xscom_ops, @@ -279,12 +271,18 @@ static void pnv_occ_realize(DeviceState *dev, Error **errp) occ, "occ-common-area", poc->sram_size); } +static Property pnv_occ_properties[] = { + DEFINE_PROP_LINK("psi", PnvOCC, psi, TYPE_PNV_PSI, PnvPsi *), + DEFINE_PROP_END_OF_LIST(), +}; + static void pnv_occ_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); dc->realize = pnv_occ_realize; dc->desc = "PowerNV OCC Controller"; + dc->props = pnv_occ_properties; } static const TypeInfo pnv_occ_type_info = { |