* [Qemu-devel] [PATCH 0/3] conversion to realize for pxb/pxb-pcie
@ 2016-03-14 10:35 Wei Jiangang
2016-03-14 10:35 ` [Qemu-devel] [PATCH 1/3] hw/pci-bridge: modify pxb_dev_init_common Wei Jiangang
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Wei Jiangang @ 2016-03-14 10:35 UTC (permalink / raw)
To: qemu-devel; +Cc: marcel, caoj.fnst, Wei Jiangang, ehabkost, mst
The previous patch named '[PATCH v3] PXB: convert to realize()'
was raised by Cao jin <caoj.fnst@cn.fujitsu.com>,
and reviewed by Marcel Apfelbaum <marcel@redhat.com>.
It conflicts with 02b0743 that had been merged,
so resend a newer version.
Wei Jiangang (3):
hw/pci-bridge: modify pxb_dev_init_common
pxb: convert to realize()
pxb-pcie: convert to realize()
hw/pci-bridge/pci_expander_bridge.c | 56 +++++++++++++++++++------------------
1 file changed, 29 insertions(+), 27 deletions(-)
--
1.9.3
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH 1/3] hw/pci-bridge: modify pxb_dev_init_common
2016-03-14 10:35 [Qemu-devel] [PATCH 0/3] conversion to realize for pxb/pxb-pcie Wei Jiangang
@ 2016-03-14 10:35 ` Wei Jiangang
2016-03-22 14:38 ` Markus Armbruster
2016-03-14 10:35 ` [Qemu-devel] [PATCH 2/3] pxb: convert to realize() Wei Jiangang
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Wei Jiangang @ 2016-03-14 10:35 UTC (permalink / raw)
To: qemu-devel; +Cc: marcel, caoj.fnst, Wei Jiangang, ehabkost, mst
1) add Error **errp parameter for it,
2) rename pxb_dev_init_common to pxb_dev_realize_common,
and prepare for pxb/pxb-pcie convert to realize.
3) modify the callers,
including pxb_dev_initfn and pxb_pcie_dev_initfn.
Signed-off-by: Wei Jiangang <weijg.fnst@cn.fujitsu.com>
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
---
hw/pci-bridge/pci_expander_bridge.c | 56 ++++++++++++++++++++++++-------------
1 file changed, 37 insertions(+), 19 deletions(-)
diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c
index d23b8da..ce5baf8 100644
--- a/hw/pci-bridge/pci_expander_bridge.c
+++ b/hw/pci-bridge/pci_expander_bridge.c
@@ -160,30 +160,25 @@ static const TypeInfo pxb_host_info = {
};
/*
- * Registers the PXB bus as a child of the i440fx root bus.
- *
- * Returns 0 on successs, -1 if i440fx host was not
- * found or the bus number is already in use.
+ * Registers the PXB bus as a child of pci host root bus.
*/
-static int pxb_register_bus(PCIDevice *dev, PCIBus *pxb_bus)
+static void pxb_register_bus(PCIDevice *dev, PCIBus *pxb_bus, Error **errp)
{
PCIBus *bus = dev->bus;
int pxb_bus_num = pci_bus_num(pxb_bus);
if (bus->parent_dev) {
- error_report("PXB devices can be attached only to root bus.");
- return -1;
+ error_setg(errp, "PXB devices can be attached only to root bus.");
+ return;
}
QLIST_FOREACH(bus, &bus->child, sibling) {
if (pci_bus_num(bus) == pxb_bus_num) {
- error_report("Bus %d is already in use.", pxb_bus_num);
- return -1;
+ error_setg(errp, "Bus %d is already in use.", pxb_bus_num);
+ return;
}
}
QLIST_INSERT_HEAD(&dev->bus->child, pxb_bus, sibling);
-
- return 0;
}
static int pxb_map_irq_fn(PCIDevice *pci_dev, int pin)
@@ -213,7 +208,7 @@ static gint pxb_compare(gconstpointer a, gconstpointer b)
0;
}
-static int pxb_dev_init_common(PCIDevice *dev, bool pcie)
+static void pxb_dev_realize_common(PCIDevice *dev, bool pcie, Error **errp)
{
PXBDev *pxb = convert_to_pxb(dev);
DeviceState *ds, *bds = NULL;
@@ -222,8 +217,8 @@ static int pxb_dev_init_common(PCIDevice *dev, bool pcie)
if (pxb->numa_node != NUMA_NODE_UNASSIGNED &&
pxb->numa_node >= nb_numa_nodes) {
- error_report("Illegal numa node %d.", pxb->numa_node);
- return -EINVAL;
+ error_setg(errp, "Illegal numa node %d.", pxb->numa_node);
+ return;
}
if (dev->qdev.id && *dev->qdev.id) {
@@ -248,8 +243,9 @@ static int pxb_dev_init_common(PCIDevice *dev, bool pcie)
PCI_HOST_BRIDGE(ds)->bus = bus;
- if (pxb_register_bus(dev, bus)) {
- return -EINVAL;
+ pxb_register_bus(dev, bus, errp);
+ if (*errp) {
+ goto err_register_bus;
}
qdev_init_nofail(ds);
@@ -262,17 +258,31 @@ static int pxb_dev_init_common(PCIDevice *dev, bool pcie)
pci_config_set_class(dev->config, PCI_CLASS_BRIDGE_HOST);
pxb_dev_list = g_list_insert_sorted(pxb_dev_list, pxb, pxb_compare);
- return 0;
+
+ return;
+
+err_register_bus:
+ object_unref(OBJECT(bds));
+ object_unparent(OBJECT(bus));
+ object_unref(OBJECT(ds));
}
static int pxb_dev_initfn(PCIDevice *dev)
{
+ Error *err = NULL;
+
if (pci_bus_is_express(dev->bus)) {
error_report("pxb devices cannot reside on a PCIe bus!");
return -EINVAL;
}
- return pxb_dev_init_common(dev, false);
+ pxb_dev_realize_common(dev, false, &err);
+ if (err) {
+ error_report_err(err);
+ return -EINVAL;
+ }
+
+ return 0;
}
static void pxb_dev_exitfn(PCIDevice *pci_dev)
@@ -314,12 +324,20 @@ static const TypeInfo pxb_dev_info = {
static int pxb_pcie_dev_initfn(PCIDevice *dev)
{
+ Error *err = NULL;
+
if (!pci_bus_is_express(dev->bus)) {
error_report("pxb-pcie devices cannot reside on a PCI bus!");
return -EINVAL;
}
- return pxb_dev_init_common(dev, true);
+ pxb_dev_realize_common(dev, true, &err);
+ if (err) {
+ error_report_err(err);
+ return -EINVAL;
+ }
+
+ return 0;
}
static void pxb_pcie_dev_class_init(ObjectClass *klass, void *data)
--
1.9.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH 2/3] pxb: convert to realize()
2016-03-14 10:35 [Qemu-devel] [PATCH 0/3] conversion to realize for pxb/pxb-pcie Wei Jiangang
2016-03-14 10:35 ` [Qemu-devel] [PATCH 1/3] hw/pci-bridge: modify pxb_dev_init_common Wei Jiangang
@ 2016-03-14 10:35 ` Wei Jiangang
2016-03-22 14:40 ` Markus Armbruster
2016-03-14 10:35 ` [Qemu-devel] [PATCH 3/3] pxb-pcie: " Wei Jiangang
2016-03-15 14:14 ` [Qemu-devel] [PATCH 0/3] conversion to realize for pxb/pxb-pcie Marcel Apfelbaum
3 siblings, 1 reply; 8+ messages in thread
From: Wei Jiangang @ 2016-03-14 10:35 UTC (permalink / raw)
To: qemu-devel; +Cc: marcel, caoj.fnst, Wei Jiangang, ehabkost, mst
Signed-off-by: Wei Jiangang <weijg.fnst@cn.fujitsu.com>
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
---
hw/pci-bridge/pci_expander_bridge.c | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c
index ce5baf8..cc5074d 100644
--- a/hw/pci-bridge/pci_expander_bridge.c
+++ b/hw/pci-bridge/pci_expander_bridge.c
@@ -267,22 +267,14 @@ err_register_bus:
object_unref(OBJECT(ds));
}
-static int pxb_dev_initfn(PCIDevice *dev)
+static void pxb_dev_realize(PCIDevice *dev, Error **errp)
{
- Error *err = NULL;
-
if (pci_bus_is_express(dev->bus)) {
- error_report("pxb devices cannot reside on a PCIe bus!");
- return -EINVAL;
- }
-
- pxb_dev_realize_common(dev, false, &err);
- if (err) {
- error_report_err(err);
- return -EINVAL;
+ error_setg(errp, "pxb devices cannot reside on a PCIe bus!");
+ return;
}
- return 0;
+ pxb_dev_realize_common(dev, false, errp);
}
static void pxb_dev_exitfn(PCIDevice *pci_dev)
@@ -304,7 +296,7 @@ static void pxb_dev_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
- k->init = pxb_dev_initfn;
+ k->realize = pxb_dev_realize;
k->exit = pxb_dev_exitfn;
k->vendor_id = PCI_VENDOR_ID_REDHAT;
k->device_id = PCI_DEVICE_ID_REDHAT_PXB;
--
1.9.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH 3/3] pxb-pcie: convert to realize()
2016-03-14 10:35 [Qemu-devel] [PATCH 0/3] conversion to realize for pxb/pxb-pcie Wei Jiangang
2016-03-14 10:35 ` [Qemu-devel] [PATCH 1/3] hw/pci-bridge: modify pxb_dev_init_common Wei Jiangang
2016-03-14 10:35 ` [Qemu-devel] [PATCH 2/3] pxb: convert to realize() Wei Jiangang
@ 2016-03-14 10:35 ` Wei Jiangang
2016-03-22 14:42 ` Markus Armbruster
2016-03-15 14:14 ` [Qemu-devel] [PATCH 0/3] conversion to realize for pxb/pxb-pcie Marcel Apfelbaum
3 siblings, 1 reply; 8+ messages in thread
From: Wei Jiangang @ 2016-03-14 10:35 UTC (permalink / raw)
To: qemu-devel; +Cc: marcel, caoj.fnst, Wei Jiangang, ehabkost, mst
Signed-off-by: Wei Jiangang <weijg.fnst@cn.fujitsu.com>
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
---
hw/pci-bridge/pci_expander_bridge.c | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c
index cc5074d..64267d8 100644
--- a/hw/pci-bridge/pci_expander_bridge.c
+++ b/hw/pci-bridge/pci_expander_bridge.c
@@ -314,22 +314,14 @@ static const TypeInfo pxb_dev_info = {
.class_init = pxb_dev_class_init,
};
-static int pxb_pcie_dev_initfn(PCIDevice *dev)
+static void pxb_pcie_dev_realize(PCIDevice *dev, Error **errp)
{
- Error *err = NULL;
-
if (!pci_bus_is_express(dev->bus)) {
- error_report("pxb-pcie devices cannot reside on a PCI bus!");
- return -EINVAL;
- }
-
- pxb_dev_realize_common(dev, true, &err);
- if (err) {
- error_report_err(err);
- return -EINVAL;
+ error_setg(errp, "pxb-pcie devices cannot reside on a PCI bus!");
+ return;
}
- return 0;
+ pxb_dev_realize_common(dev, true, errp);
}
static void pxb_pcie_dev_class_init(ObjectClass *klass, void *data)
@@ -337,7 +329,7 @@ static void pxb_pcie_dev_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
- k->init = pxb_pcie_dev_initfn;
+ k->realize = pxb_pcie_dev_realize;
k->exit = pxb_dev_exitfn;
k->vendor_id = PCI_VENDOR_ID_REDHAT;
k->device_id = PCI_DEVICE_ID_REDHAT_PXB_PCIE;
--
1.9.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH 0/3] conversion to realize for pxb/pxb-pcie
2016-03-14 10:35 [Qemu-devel] [PATCH 0/3] conversion to realize for pxb/pxb-pcie Wei Jiangang
` (2 preceding siblings ...)
2016-03-14 10:35 ` [Qemu-devel] [PATCH 3/3] pxb-pcie: " Wei Jiangang
@ 2016-03-15 14:14 ` Marcel Apfelbaum
3 siblings, 0 replies; 8+ messages in thread
From: Marcel Apfelbaum @ 2016-03-15 14:14 UTC (permalink / raw)
To: Wei Jiangang, qemu-devel, Markus Armbruster; +Cc: caoj.fnst, ehabkost, mst
On 03/14/2016 12:35 PM, Wei Jiangang wrote:
> The previous patch named '[PATCH v3] PXB: convert to realize()'
> was raised by Cao jin <caoj.fnst@cn.fujitsu.com>,
> and reviewed by Marcel Apfelbaum <marcel@redhat.com>.
>
> It conflicts with 02b0743 that had been merged,
> so resend a newer version.
>
> Wei Jiangang (3):
> hw/pci-bridge: modify pxb_dev_init_common
> pxb: convert to realize()
> pxb-pcie: convert to realize()
>
> hw/pci-bridge/pci_expander_bridge.c | 56 +++++++++++++++++++------------------
> 1 file changed, 29 insertions(+), 27 deletions(-)
>
Hi Markus,
Do you have maybe some time to go over the error handling proposed by the series?
Thanks,
Marcel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] hw/pci-bridge: modify pxb_dev_init_common
2016-03-14 10:35 ` [Qemu-devel] [PATCH 1/3] hw/pci-bridge: modify pxb_dev_init_common Wei Jiangang
@ 2016-03-22 14:38 ` Markus Armbruster
0 siblings, 0 replies; 8+ messages in thread
From: Markus Armbruster @ 2016-03-22 14:38 UTC (permalink / raw)
To: Wei Jiangang; +Cc: marcel, caoj.fnst, mst, qemu-devel, ehabkost
Wei Jiangang <weijg.fnst@cn.fujitsu.com> writes:
> 1) add Error **errp parameter for it,
> 2) rename pxb_dev_init_common to pxb_dev_realize_common,
> and prepare for pxb/pxb-pcie convert to realize.
> 3) modify the callers,
> including pxb_dev_initfn and pxb_pcie_dev_initfn.
>
> Signed-off-by: Wei Jiangang <weijg.fnst@cn.fujitsu.com>
> Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
The first line of your commit message is inexpressive. Suggest
hw/pci-bridge: Convert to pxb_dev_init_common() to Error
The next commits will convert its users to realize(), so rename it
to pxb_dev_realize_common() now.
The patch actually converts pxb_register_bus() as well, but that's
detail.
> ---
> hw/pci-bridge/pci_expander_bridge.c | 56 ++++++++++++++++++++++++-------------
> 1 file changed, 37 insertions(+), 19 deletions(-)
>
> diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c
> index d23b8da..ce5baf8 100644
> --- a/hw/pci-bridge/pci_expander_bridge.c
> +++ b/hw/pci-bridge/pci_expander_bridge.c
> @@ -160,30 +160,25 @@ static const TypeInfo pxb_host_info = {
> };
>
> /*
> - * Registers the PXB bus as a child of the i440fx root bus.
> - *
> - * Returns 0 on successs, -1 if i440fx host was not
> - * found or the bus number is already in use.
> + * Registers the PXB bus as a child of pci host root bus.
> */
> -static int pxb_register_bus(PCIDevice *dev, PCIBus *pxb_bus)
> +static void pxb_register_bus(PCIDevice *dev, PCIBus *pxb_bus, Error **errp)
> {
> PCIBus *bus = dev->bus;
> int pxb_bus_num = pci_bus_num(pxb_bus);
>
> if (bus->parent_dev) {
> - error_report("PXB devices can be attached only to root bus.");
> - return -1;
> + error_setg(errp, "PXB devices can be attached only to root bus.");
While there, drop the period (error messages generally don't end in
punctuation). More of the same below.
> + return;
> }
>
> QLIST_FOREACH(bus, &bus->child, sibling) {
> if (pci_bus_num(bus) == pxb_bus_num) {
> - error_report("Bus %d is already in use.", pxb_bus_num);
> - return -1;
> + error_setg(errp, "Bus %d is already in use.", pxb_bus_num);
> + return;
> }
> }
> QLIST_INSERT_HEAD(&dev->bus->child, pxb_bus, sibling);
> -
> - return 0;
> }
>
> static int pxb_map_irq_fn(PCIDevice *pci_dev, int pin)
> @@ -213,7 +208,7 @@ static gint pxb_compare(gconstpointer a, gconstpointer b)
> 0;
> }
>
> -static int pxb_dev_init_common(PCIDevice *dev, bool pcie)
> +static void pxb_dev_realize_common(PCIDevice *dev, bool pcie, Error **errp)
> {
> PXBDev *pxb = convert_to_pxb(dev);
> DeviceState *ds, *bds = NULL;
> @@ -222,8 +217,8 @@ static int pxb_dev_init_common(PCIDevice *dev, bool pcie)
>
> if (pxb->numa_node != NUMA_NODE_UNASSIGNED &&
> pxb->numa_node >= nb_numa_nodes) {
> - error_report("Illegal numa node %d.", pxb->numa_node);
> - return -EINVAL;
> + error_setg(errp, "Illegal numa node %d.", pxb->numa_node);
> + return;
> }
>
> if (dev->qdev.id && *dev->qdev.id) {
> @@ -248,8 +243,9 @@ static int pxb_dev_init_common(PCIDevice *dev, bool pcie)
>
> PCI_HOST_BRIDGE(ds)->bus = bus;
>
> - if (pxb_register_bus(dev, bus)) {
> - return -EINVAL;
> + pxb_register_bus(dev, bus, errp);
> + if (*errp) {
Breaks when a caller passes a null errp. You have to do
pxb_register_bus(dev, bus, &err);
if (err) {
error_propagate(errp, err);
with err previously initialized to null.
See also the big comment in error.h.
> + goto err_register_bus;
> }
>
> qdev_init_nofail(ds);
> @@ -262,17 +258,31 @@ static int pxb_dev_init_common(PCIDevice *dev, bool pcie)
> pci_config_set_class(dev->config, PCI_CLASS_BRIDGE_HOST);
>
> pxb_dev_list = g_list_insert_sorted(pxb_dev_list, pxb, pxb_compare);
> - return 0;
> +
> + return;
> +
> +err_register_bus:
> + object_unref(OBJECT(bds));
> + object_unparent(OBJECT(bus));
> + object_unref(OBJECT(ds));
Cleanup new in this patch. Is this a bug fix? If yes, the commit
message should mention it. I'd make it a separate patch, before this one.
> }
>
> static int pxb_dev_initfn(PCIDevice *dev)
> {
> + Error *err = NULL;
> +
> if (pci_bus_is_express(dev->bus)) {
> error_report("pxb devices cannot reside on a PCIe bus!");
> return -EINVAL;
> }
>
> - return pxb_dev_init_common(dev, false);
> + pxb_dev_realize_common(dev, false, &err);
> + if (err) {
> + error_report_err(err);
> + return -EINVAL;
> + }
> +
> + return 0;
> }
>
> static void pxb_dev_exitfn(PCIDevice *pci_dev)
> @@ -314,12 +324,20 @@ static const TypeInfo pxb_dev_info = {
>
> static int pxb_pcie_dev_initfn(PCIDevice *dev)
> {
> + Error *err = NULL;
> +
> if (!pci_bus_is_express(dev->bus)) {
> error_report("pxb-pcie devices cannot reside on a PCI bus!");
> return -EINVAL;
> }
>
> - return pxb_dev_init_common(dev, true);
> + pxb_dev_realize_common(dev, true, &err);
> + if (err) {
> + error_report_err(err);
> + return -EINVAL;
> + }
> +
> + return 0;
> }
>
> static void pxb_pcie_dev_class_init(ObjectClass *klass, void *data)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH 2/3] pxb: convert to realize()
2016-03-14 10:35 ` [Qemu-devel] [PATCH 2/3] pxb: convert to realize() Wei Jiangang
@ 2016-03-22 14:40 ` Markus Armbruster
0 siblings, 0 replies; 8+ messages in thread
From: Markus Armbruster @ 2016-03-22 14:40 UTC (permalink / raw)
To: Wei Jiangang; +Cc: marcel, caoj.fnst, mst, qemu-devel, ehabkost
Wei Jiangang <weijg.fnst@cn.fujitsu.com> writes:
> Signed-off-by: Wei Jiangang <weijg.fnst@cn.fujitsu.com>
> Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
> ---
> hw/pci-bridge/pci_expander_bridge.c | 18 +++++-------------
> 1 file changed, 5 insertions(+), 13 deletions(-)
>
> diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c
> index ce5baf8..cc5074d 100644
> --- a/hw/pci-bridge/pci_expander_bridge.c
> +++ b/hw/pci-bridge/pci_expander_bridge.c
> @@ -267,22 +267,14 @@ err_register_bus:
> object_unref(OBJECT(ds));
> }
>
> -static int pxb_dev_initfn(PCIDevice *dev)
> +static void pxb_dev_realize(PCIDevice *dev, Error **errp)
> {
> - Error *err = NULL;
> -
> if (pci_bus_is_express(dev->bus)) {
> - error_report("pxb devices cannot reside on a PCIe bus!");
> - return -EINVAL;
> - }
> -
> - pxb_dev_realize_common(dev, false, &err);
> - if (err) {
> - error_report_err(err);
> - return -EINVAL;
> + error_setg(errp, "pxb devices cannot reside on a PCIe bus!");
Suggest to use the occasion to drop the exclamation mark.
> + return;
> }
>
> - return 0;
> + pxb_dev_realize_common(dev, false, errp);
> }
>
> static void pxb_dev_exitfn(PCIDevice *pci_dev)
> @@ -304,7 +296,7 @@ static void pxb_dev_class_init(ObjectClass *klass, void *data)
> DeviceClass *dc = DEVICE_CLASS(klass);
> PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
>
> - k->init = pxb_dev_initfn;
> + k->realize = pxb_dev_realize;
> k->exit = pxb_dev_exitfn;
> k->vendor_id = PCI_VENDOR_ID_REDHAT;
> k->device_id = PCI_DEVICE_ID_REDHAT_PXB;
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] pxb-pcie: convert to realize()
2016-03-14 10:35 ` [Qemu-devel] [PATCH 3/3] pxb-pcie: " Wei Jiangang
@ 2016-03-22 14:42 ` Markus Armbruster
0 siblings, 0 replies; 8+ messages in thread
From: Markus Armbruster @ 2016-03-22 14:42 UTC (permalink / raw)
To: Wei Jiangang; +Cc: marcel, caoj.fnst, mst, qemu-devel, ehabkost
Wei Jiangang <weijg.fnst@cn.fujitsu.com> writes:
> Signed-off-by: Wei Jiangang <weijg.fnst@cn.fujitsu.com>
> Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
> ---
> hw/pci-bridge/pci_expander_bridge.c | 18 +++++-------------
> 1 file changed, 5 insertions(+), 13 deletions(-)
>
> diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c
> index cc5074d..64267d8 100644
> --- a/hw/pci-bridge/pci_expander_bridge.c
> +++ b/hw/pci-bridge/pci_expander_bridge.c
> @@ -314,22 +314,14 @@ static const TypeInfo pxb_dev_info = {
> .class_init = pxb_dev_class_init,
> };
>
> -static int pxb_pcie_dev_initfn(PCIDevice *dev)
> +static void pxb_pcie_dev_realize(PCIDevice *dev, Error **errp)
> {
> - Error *err = NULL;
> -
> if (!pci_bus_is_express(dev->bus)) {
> - error_report("pxb-pcie devices cannot reside on a PCI bus!");
> - return -EINVAL;
> - }
> -
> - pxb_dev_realize_common(dev, true, &err);
> - if (err) {
> - error_report_err(err);
> - return -EINVAL;
> + error_setg(errp, "pxb-pcie devices cannot reside on a PCI bus!");
Suggest to use the occasion to drop the exclamation mark.
> + return;
> }
>
> - return 0;
> + pxb_dev_realize_common(dev, true, errp);
> }
>
> static void pxb_pcie_dev_class_init(ObjectClass *klass, void *data)
> @@ -337,7 +329,7 @@ static void pxb_pcie_dev_class_init(ObjectClass *klass, void *data)
> DeviceClass *dc = DEVICE_CLASS(klass);
> PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
>
> - k->init = pxb_pcie_dev_initfn;
> + k->realize = pxb_pcie_dev_realize;
> k->exit = pxb_dev_exitfn;
> k->vendor_id = PCI_VENDOR_ID_REDHAT;
> k->device_id = PCI_DEVICE_ID_REDHAT_PXB_PCIE;
I'd be tempted to squash PATCH 1-3 together, with only the bug fix from
PATCH 1 (assuming it is a bug fix) separate. Clearly a matter of taste.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-03-22 14:42 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-14 10:35 [Qemu-devel] [PATCH 0/3] conversion to realize for pxb/pxb-pcie Wei Jiangang
2016-03-14 10:35 ` [Qemu-devel] [PATCH 1/3] hw/pci-bridge: modify pxb_dev_init_common Wei Jiangang
2016-03-22 14:38 ` Markus Armbruster
2016-03-14 10:35 ` [Qemu-devel] [PATCH 2/3] pxb: convert to realize() Wei Jiangang
2016-03-22 14:40 ` Markus Armbruster
2016-03-14 10:35 ` [Qemu-devel] [PATCH 3/3] pxb-pcie: " Wei Jiangang
2016-03-22 14:42 ` Markus Armbruster
2016-03-15 14:14 ` [Qemu-devel] [PATCH 0/3] conversion to realize for pxb/pxb-pcie Marcel Apfelbaum
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.