[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL 16/17] spapr: Eliminate spapr_drc_get_type_str()
From: |
David Gibson |
Subject: |
[Qemu-ppc] [PULL 16/17] spapr: Eliminate spapr_drc_get_type_str() |
Date: |
Tue, 6 Jun 2017 12:51:34 +1000 |
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 <address@hidden>
Reviewed-by: Michael Roth <address@hidden>
Acked-by: Michael Roth <address@hidden>
---
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 783c621..06df5d0 100644
--- a/hw/ppc/spapr_drc.c
+++ b/hw/ppc/spapr_drc.c
@@ -712,6 +712,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)
@@ -719,6 +720,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)
@@ -726,6 +728,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 = {
@@ -795,31 +798,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
*
@@ -901,8 +879,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 7dbb478..c88e1be 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
- [Qemu-ppc] [PULL 07/17] target-ppc: Fix openpic timer read register offset, (continued)
- [Qemu-ppc] [PULL 07/17] target-ppc: Fix openpic timer read register offset, David Gibson, 2017/06/05
- [Qemu-ppc] [PULL 12/17] spapr/drc: don't migrate DRC of cold-plugged CPUs and LMBs, David Gibson, 2017/06/05
- [Qemu-ppc] [PULL 02/17] migration: Mark CPU states dirty before incoming migration/loadvm, David Gibson, 2017/06/05
- [Qemu-ppc] [PULL 10/17] ppc/pnv: check the return value of fdt_setprop(), David Gibson, 2017/06/05
- [Qemu-ppc] [PULL 09/17] spapr_nvram: Check return value from blk_getlength(), David Gibson, 2017/06/05
- [Qemu-ppc] [PULL 04/17] spapr: Abolish DRC get_fdt method, David Gibson, 2017/06/05
- [Qemu-ppc] [PULL 17/17] spapr: Remove some non-useful properties on DRC objects, David Gibson, 2017/06/05
- [Qemu-ppc] [PULL 05/17] spapr: Abolish DRC set_configured method, David Gibson, 2017/06/05
- [Qemu-ppc] [PULL 03/17] spapr: Move DRC RTAS calls into spapr_drc.c, David Gibson, 2017/06/05
- [Qemu-ppc] [PULL 08/17] target/ppc: Fixup set_spr error in h_register_process_table, David Gibson, 2017/06/05
- [Qemu-ppc] [PULL 16/17] spapr: Eliminate spapr_drc_get_type_str(),
David Gibson <=
- [Qemu-ppc] [PULL 06/17] spapr: Make DRC get_index and get_type methods into plain functions, David Gibson, 2017/06/05
- [Qemu-ppc] [PULL 14/17] spapr: Clean up spapr_dr_connector_by_*(), David Gibson, 2017/06/05
- [Qemu-ppc] [PULL 13/17] spapr: Introduce DRC subclasses, David Gibson, 2017/06/05
- [Qemu-ppc] [PULL 11/17] spapr: Allow boot from vhost-*-scsi backends, David Gibson, 2017/06/05
- [Qemu-ppc] [PULL 15/17] spapr: Move configure-connector state into DRC, David Gibson, 2017/06/05
- Re: [Qemu-ppc] [PULL 00/17] ppc-for-2.10 queue 20170606, Peter Maydell, 2017/06/06