diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2017-06-04 20:26:03 +1000 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2017-06-06 09:24:08 +1000 |
commit | fbf553971898aee18b5933d335e2fa3e74bb9be7 (patch) | |
tree | 2741d2ab19afb7099586f3777a5f63b5c24c793c /hw/ppc/spapr_drc.c | |
parent | 2d33581899edcaba9b7e48def11c4ddfcd2423ec (diff) |
spapr: Clean up spapr_dr_connector_by_*()
* Change names to something less ludicrously verbose
* Now that we have QOM subclasses for the different DRC types, use a QOM
typename instead of a PAPR type value parameter
The latter allows removal of the get_type_shift() helper.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Acked-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Diffstat (limited to 'hw/ppc/spapr_drc.c')
-rw-r--r-- | hw/ppc/spapr_drc.c | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index 969d727b72..7ed2de1c25 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -55,21 +55,6 @@ static void spapr_ccs_remove(sPAPRMachineState *spapr, g_free(ccs); } -static sPAPRDRConnectorTypeShift get_type_shift(sPAPRDRConnectorType type) -{ - uint32_t shift = 0; - - /* make sure this isn't SPAPR_DR_CONNECTOR_TYPE_ANY, or some - * other wonky value. - */ - g_assert(is_power_of_2(type)); - - while (type != (1 << shift)) { - shift++; - } - return shift; -} - sPAPRDRConnectorType spapr_drc_type(sPAPRDRConnector *drc) { sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); @@ -804,7 +789,7 @@ static const TypeInfo spapr_drc_lmb_info = { /* helper functions for external users */ -sPAPRDRConnector *spapr_dr_connector_by_index(uint32_t index) +sPAPRDRConnector *spapr_drc_by_index(uint32_t index) { Object *obj; char name[256]; @@ -815,12 +800,13 @@ sPAPRDRConnector *spapr_dr_connector_by_index(uint32_t index) return !obj ? NULL : SPAPR_DR_CONNECTOR(obj); } -sPAPRDRConnector *spapr_dr_connector_by_id(sPAPRDRConnectorType type, - uint32_t id) +sPAPRDRConnector *spapr_drc_by_id(const char *type, uint32_t id) { - return spapr_dr_connector_by_index( - (get_type_shift(type) << DRC_INDEX_TYPE_SHIFT) | - (id & DRC_INDEX_ID_MASK)); + sPAPRDRConnectorClass *drck + = SPAPR_DR_CONNECTOR_CLASS(object_class_by_name(type)); + + return spapr_drc_by_index(drck->typeshift << DRC_INDEX_TYPE_SHIFT + | (id & DRC_INDEX_ID_MASK)); } /* generate a string the describes the DRC to encode into the @@ -1023,7 +1009,7 @@ static void rtas_set_indicator(PowerPCCPU *cpu, sPAPRMachineState *spapr, } /* if this is a DR sensor we can assume sensor_index == drc_index */ - drc = spapr_dr_connector_by_index(sensor_index); + drc = spapr_drc_by_index(sensor_index); if (!drc) { trace_spapr_rtas_set_indicator_invalid(sensor_index); ret = RTAS_OUT_PARAM_ERROR; @@ -1096,7 +1082,7 @@ static void rtas_get_sensor_state(PowerPCCPU *cpu, sPAPRMachineState *spapr, goto out; } - drc = spapr_dr_connector_by_index(sensor_index); + drc = spapr_drc_by_index(sensor_index); if (!drc) { trace_spapr_rtas_get_sensor_state_invalid(sensor_index); ret = RTAS_OUT_PARAM_ERROR; @@ -1161,7 +1147,7 @@ static void rtas_ibm_configure_connector(PowerPCCPU *cpu, wa_addr = ((uint64_t)rtas_ld(args, 1) << 32) | rtas_ld(args, 0); drc_index = rtas_ld(wa_addr, 0); - drc = spapr_dr_connector_by_index(drc_index); + drc = spapr_drc_by_index(drc_index); if (!drc) { trace_spapr_rtas_ibm_configure_connector_invalid(drc_index); rc = RTAS_OUT_PARAM_ERROR; |