On Mon, Jul 23, 2018 at 11:37:06PM +0200, Cédric Le Goater wrote: > On 07/18/2018 08:12 AM, David Gibson wrote: > >> +static void pnv_phb3_get_phb_id(Object *obj, Visitor *v, const char *name, > >> + void *opaque, Error **errp) > >> +{ > >> + Property *prop = opaque; > >> + uint32_t *ptr = qdev_get_prop_ptr(DEVICE(obj), prop); > >> + > >> + visit_type_uint32(v, name, ptr, errp); > >> +} > >> + > >> +static void pnv_phb3_set_phb_id(Object *obj, Visitor *v, const char *name, > >> + void *opaque, Error **errp) > >> +{ > >> + PnvPHB3 *phb = PNV_PHB3(obj); > >> + uint32_t phb_id; > >> + Error *local_err = NULL; > >> + > >> + visit_type_uint32(v, name, &phb_id, &local_err); > >> + if (local_err) { > >> + error_propagate(errp, local_err); > >> + return; > >> + } > >> + > >> + /* > >> + * Limit to a maximum of 6 PHBs per chip > >> + */ > >> + if (phb_id >= PNV8_CHIP_PHB3_MAX) { > >> + error_setg(errp, "invalid PHB index: '%d'", phb_id); > >> + return; > >> + } > >> + > >> + phb->phb_id = phb_id; > >> +} > >> + > >> +static const PropertyInfo pnv_phb3_phb_id_propinfo = { > >> + .name = "irq", > >> + .get = pnv_phb3_get_phb_id, > >> + .set = pnv_phb3_set_phb_id, > >> +}; > > Can't you use a static DeviceProps style property for this, which is a > > bit simpler? > > yes but we will need these ops for user creatable devices. This is where > we will check the chip id.
Why? Can't we check that during realize()? That's a common pattern for static properties. -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
signature.asc
Description: PGP signature