Quoting David Gibson (2017-06-02 02:29:51) > This function was used in generating the device tree. However, now that > we have different QOM types for different DRC types we can easily store > the information we need in the class structure and avoid this specialized > lookup function. > > Signed-off-by: David Gibson <da...@gibson.dropbear.id.au>
Reviewed-by: Michael Roth <mdr...@linux.vnet.ibm.com> > --- > hw/ppc/spapr_drc.c | 31 ++++--------------------------- > include/hw/ppc/spapr_drc.h | 1 + > 2 files changed, 5 insertions(+), 27 deletions(-) > > diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c > index 27d4bd3..d43c9cd 100644 > --- a/hw/ppc/spapr_drc.c > +++ b/hw/ppc/spapr_drc.c > @@ -716,6 +716,7 @@ static void spapr_drc_cpu_class_init(ObjectClass *k, void > *data) > sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_CLASS(k); > > drck->typeshift = SPAPR_DR_CONNECTOR_TYPE_SHIFT_CPU; > + drck->typename = "CPU"; > } > > static void spapr_drc_pci_class_init(ObjectClass *k, void *data) > @@ -723,6 +724,7 @@ static void spapr_drc_pci_class_init(ObjectClass *k, void > *data) > sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_CLASS(k); > > drck->typeshift = SPAPR_DR_CONNECTOR_TYPE_SHIFT_PCI; > + drck->typename = "28"; > } > > static void spapr_drc_lmb_class_init(ObjectClass *k, void *data) > @@ -730,6 +732,7 @@ static void spapr_drc_lmb_class_init(ObjectClass *k, void > *data) > sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_CLASS(k); > > drck->typeshift = SPAPR_DR_CONNECTOR_TYPE_SHIFT_LMB; > + drck->typename = "MEM"; > } > > static const TypeInfo spapr_dr_connector_info = { > @@ -796,31 +799,6 @@ sPAPRDRConnector *spapr_drc_by_id(const char *type, > uint32_t id) > | (id & DRC_INDEX_ID_MASK)); > } > > -/* generate a string the describes the DRC to encode into the > - * device tree. > - * > - * as documented by PAPR+ v2.7, 13.5.2.6 and C.6.1 > - */ > -static const char *spapr_drc_get_type_str(sPAPRDRConnectorType type) > -{ > - switch (type) { > - case SPAPR_DR_CONNECTOR_TYPE_CPU: > - return "CPU"; > - case SPAPR_DR_CONNECTOR_TYPE_PHB: > - return "PHB"; > - case SPAPR_DR_CONNECTOR_TYPE_VIO: > - return "SLOT"; > - case SPAPR_DR_CONNECTOR_TYPE_PCI: > - return "28"; > - case SPAPR_DR_CONNECTOR_TYPE_LMB: > - return "MEM"; > - default: > - g_assert(false); > - } > - > - return NULL; > -} > - > /** > * spapr_drc_populate_dt > * > @@ -902,8 +880,7 @@ int spapr_drc_populate_dt(void *fdt, int fdt_offset, > Object *owner, > drc_names = g_string_insert_len(drc_names, -1, "\0", 1); > > /* ibm,drc-types */ > - drc_types = g_string_append(drc_types, > - > spapr_drc_get_type_str(spapr_drc_type(drc))); > + drc_types = g_string_append(drc_types, drck->typename); > drc_types = g_string_insert_len(drc_types, -1, "\0", 1); > } > > diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h > index 53b0f8b..8a4889a 100644 > --- a/include/hw/ppc/spapr_drc.h > +++ b/include/hw/ppc/spapr_drc.h > @@ -212,6 +212,7 @@ typedef struct sPAPRDRConnectorClass { > > /*< public >*/ > sPAPRDRConnectorTypeShift typeshift; > + const char *typename; /* used in device tree, PAPR 13.5.2.6 & C.6.1 */ > > /* accessors for guest-visible (generally via RTAS) DR state */ > uint32_t (*set_isolation_state)(sPAPRDRConnector *drc, > -- > 2.9.4 >