mirror of https://gitee.com/openkylin/qemu.git
spapr: Add DRC release method
At the moment, spapr_drc_release() has an ugly switch on the DRC type to call the right, device-specific release function. This cleans it up by doing that via a proper QOM method. It's still arguably an abstraction violation for the DRC code to call into the specific device code, but one mess at a time. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Laurent Vivier <lvivier@redhat.com> Reviewed-by: Greg Kurz <groug@kaod.org>
This commit is contained in:
parent
6caf3ac613
commit
6b762f29a8
|
@ -370,22 +370,9 @@ void spapr_drc_attach(sPAPRDRConnector *drc, DeviceState *d, void *fdt,
|
||||||
|
|
||||||
static void spapr_drc_release(sPAPRDRConnector *drc)
|
static void spapr_drc_release(sPAPRDRConnector *drc)
|
||||||
{
|
{
|
||||||
/* Calling release callbacks based on spapr_drc_type(drc). */
|
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
|
||||||
switch (spapr_drc_type(drc)) {
|
|
||||||
case SPAPR_DR_CONNECTOR_TYPE_CPU:
|
drck->release(drc->dev);
|
||||||
spapr_core_release(drc->dev);
|
|
||||||
break;
|
|
||||||
case SPAPR_DR_CONNECTOR_TYPE_PCI:
|
|
||||||
spapr_phb_remove_pci_device_cb(drc->dev);
|
|
||||||
break;
|
|
||||||
case SPAPR_DR_CONNECTOR_TYPE_LMB:
|
|
||||||
spapr_lmb_release(drc->dev);
|
|
||||||
break;
|
|
||||||
case SPAPR_DR_CONNECTOR_TYPE_PHB:
|
|
||||||
case SPAPR_DR_CONNECTOR_TYPE_VIO:
|
|
||||||
default:
|
|
||||||
g_assert(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
drc->awaiting_release = false;
|
drc->awaiting_release = false;
|
||||||
g_free(drc->fdt);
|
g_free(drc->fdt);
|
||||||
|
@ -631,6 +618,7 @@ static void spapr_drc_cpu_class_init(ObjectClass *k, void *data)
|
||||||
drck->typeshift = SPAPR_DR_CONNECTOR_TYPE_SHIFT_CPU;
|
drck->typeshift = SPAPR_DR_CONNECTOR_TYPE_SHIFT_CPU;
|
||||||
drck->typename = "CPU";
|
drck->typename = "CPU";
|
||||||
drck->drc_name_prefix = "CPU ";
|
drck->drc_name_prefix = "CPU ";
|
||||||
|
drck->release = spapr_core_release;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void spapr_drc_pci_class_init(ObjectClass *k, void *data)
|
static void spapr_drc_pci_class_init(ObjectClass *k, void *data)
|
||||||
|
@ -640,6 +628,7 @@ static void spapr_drc_pci_class_init(ObjectClass *k, void *data)
|
||||||
drck->typeshift = SPAPR_DR_CONNECTOR_TYPE_SHIFT_PCI;
|
drck->typeshift = SPAPR_DR_CONNECTOR_TYPE_SHIFT_PCI;
|
||||||
drck->typename = "28";
|
drck->typename = "28";
|
||||||
drck->drc_name_prefix = "C";
|
drck->drc_name_prefix = "C";
|
||||||
|
drck->release = spapr_phb_remove_pci_device_cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void spapr_drc_lmb_class_init(ObjectClass *k, void *data)
|
static void spapr_drc_lmb_class_init(ObjectClass *k, void *data)
|
||||||
|
@ -649,6 +638,7 @@ static void spapr_drc_lmb_class_init(ObjectClass *k, void *data)
|
||||||
drck->typeshift = SPAPR_DR_CONNECTOR_TYPE_SHIFT_LMB;
|
drck->typeshift = SPAPR_DR_CONNECTOR_TYPE_SHIFT_LMB;
|
||||||
drck->typename = "MEM";
|
drck->typename = "MEM";
|
||||||
drck->drc_name_prefix = "LMB ";
|
drck->drc_name_prefix = "LMB ";
|
||||||
|
drck->release = spapr_lmb_release;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo spapr_dr_connector_info = {
|
static const TypeInfo spapr_dr_connector_info = {
|
||||||
|
|
|
@ -217,6 +217,7 @@ typedef struct sPAPRDRConnectorClass {
|
||||||
sPAPRDREntitySense (*dr_entity_sense)(sPAPRDRConnector *drc);
|
sPAPRDREntitySense (*dr_entity_sense)(sPAPRDRConnector *drc);
|
||||||
uint32_t (*isolate)(sPAPRDRConnector *drc);
|
uint32_t (*isolate)(sPAPRDRConnector *drc);
|
||||||
uint32_t (*unisolate)(sPAPRDRConnector *drc);
|
uint32_t (*unisolate)(sPAPRDRConnector *drc);
|
||||||
|
void (*release)(DeviceState *dev);
|
||||||
|
|
||||||
/* QEMU interfaces for managing hotplug operations */
|
/* QEMU interfaces for managing hotplug operations */
|
||||||
bool (*release_pending)(sPAPRDRConnector *drc);
|
bool (*release_pending)(sPAPRDRConnector *drc);
|
||||||
|
|
Loading…
Reference in New Issue