diff mbox

[01/13] pci: Refactor pci_change_irq_level

Message ID f1627a12ac21980e14c9d2041013877d959d22cf.1338799935.git.jan.kiszka@siemens.com
State New
Headers show

Commit Message

Jan Kiszka June 4, 2012, 8:52 a.m. UTC
Align the bus traversal in pci_change_irq_level to other functions. They
use PCIBus:parent_dev to detect the root.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 hw/pci.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

Comments

Michael S. Tsirkin June 10, 2012, 11:28 a.m. UTC | #1
On Mon, Jun 04, 2012 at 10:52:09AM +0200, Jan Kiszka wrote:
> Align the bus traversal in pci_change_irq_level to other functions. They
> use PCIBus:parent_dev to detect the root.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>

Applied.

> ---
>  hw/pci.c |    8 ++++----
>  1 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/pci.c b/hw/pci.c
> index c1ebdde..893f89c 100644
> --- a/hw/pci.c
> +++ b/hw/pci.c
> @@ -115,13 +115,13 @@ static inline void pci_set_irq_state(PCIDevice *d, int irq_num, int level)
>  static void pci_change_irq_level(PCIDevice *pci_dev, int irq_num, int change)
>  {
>      PCIBus *bus;
> -    for (;;) {
> +
> +    do {
>          bus = pci_dev->bus;
>          irq_num = bus->map_irq(pci_dev, irq_num);
> -        if (bus->set_irq)
> -            break;
>          pci_dev = bus->parent_dev;
> -    }
> +    } while (pci_dev);
> +
>      bus->irq_count[irq_num] += change;
>      bus->set_irq(bus->irq_opaque, irq_num, bus->irq_count[irq_num] != 0);
>  }
> -- 
> 1.7.3.4
diff mbox

Patch

diff --git a/hw/pci.c b/hw/pci.c
index c1ebdde..893f89c 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -115,13 +115,13 @@  static inline void pci_set_irq_state(PCIDevice *d, int irq_num, int level)
 static void pci_change_irq_level(PCIDevice *pci_dev, int irq_num, int change)
 {
     PCIBus *bus;
-    for (;;) {
+
+    do {
         bus = pci_dev->bus;
         irq_num = bus->map_irq(pci_dev, irq_num);
-        if (bus->set_irq)
-            break;
         pci_dev = bus->parent_dev;
-    }
+    } while (pci_dev);
+
     bus->irq_count[irq_num] += change;
     bus->set_irq(bus->irq_opaque, irq_num, bus->irq_count[irq_num] != 0);
 }