Skip to contentSkip to conversation

ARM: mach-iop32x: iq31244: Replace if-then-else with a switch statement

PATCH In review Valentin Ilie 2 participants 3 messages Sep 2, 2013 – Oct 2, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: mach-iop32x: iq31244: Replace if-then-else with a switch statement

Convert a compound if-else blob to a switch statement.

---
 arch/arm/mach-iop32x/iq31244.c | 29 +++++++++++------------------
 1 file changed, 11 insertions(+), 18 deletions(-)
arch/arm/mach-iop32x/iq31244.c +11 -18
index f2cd296..3415f11 100644
@@ -101,28 +101,21 @@ void __init iq31244_map_io(void)
 static int __init
 ep80219_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
 {
-	int irq;
-
-	if (slot == 0) {
-		/* CFlash */
-		irq = IRQ_IOP32X_XINT1;
-	} else if (slot == 1) {
-		/* 82551 Pro 100 */
-		irq = IRQ_IOP32X_XINT0;
-	} else if (slot == 2) {
-		/* PCI-X Slot */
-		irq = IRQ_IOP32X_XINT3;
-	} else if (slot == 3) {
-		/* SATA */
-		irq = IRQ_IOP32X_XINT2;
-	} else {
+	switch (slot) {
+	case 0: /* CFlash */
+		return IRQ_IOP32X_XINT1;
+	case 1: /* 82551 Pro 100 */
+		return IRQ_IOP32X_XINT0;
+	case 2: /* PCI-X Slot */
+		return IRQ_IOP32X_XINT3;
+	case 3: /* SATA */
+		return IRQ_IOP32X_XINT2;
+	default:
 		printk(KERN_ERR "ep80219_pci_map_irq() called for unknown "
 			"device PCI:%d:%d:%d\n", dev->bus->number,
 			PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
-		irq = -1;
+		return -1;
 	}
-
-	return irq;
 }
 
 static struct hw_pci ep80219_pci __initdata = {
Signature · 1 line
1.8.1.2
#1 lore raw
Quoted 52 lines · Valentin Ilie

Convert a compound if-else blob to a switch statement.

---
 arch/arm/mach-iop32x/iq31244.c | 29 +++++++++++------------------
 1 file changed, 11 insertions(+), 18 deletions(-)
arch/arm/mach-iop32x/iq31244.c +11 -19
index f2cd296..3415f11 100644
@@ -101,28 +101,21 @@ void __init iq31244_map_io(void)
 static int __init
 ep80219_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
 {
-       int irq;
-
-       if (slot == 0) {
-               /* CFlash */
-               irq = IRQ_IOP32X_XINT1;
-       } else if (slot == 1) {
-               /* 82551 Pro 100 */
-               irq = IRQ_IOP32X_XINT0;
-       } else if (slot == 2) {
-               /* PCI-X Slot */
-               irq = IRQ_IOP32X_XINT3;
-       } else if (slot == 3) {
-               /* SATA */
-               irq = IRQ_IOP32X_XINT2;
-       } else {
+       switch (slot) {
+       case 0: /* CFlash */
+               return IRQ_IOP32X_XINT1;
+       case 1: /* 82551 Pro 100 */
+               return IRQ_IOP32X_XINT0;
+       case 2: /* PCI-X Slot */
+               return IRQ_IOP32X_XINT3;
+       case 3: /* SATA */
+               return IRQ_IOP32X_XINT2;
+       default:
                printk(KERN_ERR "ep80219_pci_map_irq() called for unknown "
                        "device PCI:%d:%d:%d\n", dev->bus->number,
                        PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
-               irq = -1;
+               return -1;
        }
-
-       return irq;
 }
 
 static struct hw_pci ep80219_pci __initdata = {
--
Quoted 2 lines

1.8.1.2

Can someone look into this?

Signature · 1 line
Valentin Ilie
#2 lore raw
Quoted 51 lines · Valentin Ilie
Quoted 50 lines · Valentin Ilie

Convert a compound if-else blob to a switch statement.

---
 arch/arm/mach-iop32x/iq31244.c | 29 +++++++++++------------------
 1 file changed, 11 insertions(+), 18 deletions(-)
arch/arm/mach-iop32x/iq31244.c +11 -18
index f2cd296..3415f11 100644
@@ -101,28 +101,21 @@ void __init iq31244_map_io(void)
 static int __init
 ep80219_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
 {
-       int irq;
-
-       if (slot == 0) {
-               /* CFlash */
-               irq = IRQ_IOP32X_XINT1;
-       } else if (slot == 1) {
-               /* 82551 Pro 100 */
-               irq = IRQ_IOP32X_XINT0;
-       } else if (slot == 2) {
-               /* PCI-X Slot */
-               irq = IRQ_IOP32X_XINT3;
-       } else if (slot == 3) {
-               /* SATA */
-               irq = IRQ_IOP32X_XINT2;
-       } else {
+       switch (slot) {
+       case 0: /* CFlash */
+               return IRQ_IOP32X_XINT1;
+       case 1: /* 82551 Pro 100 */
+               return IRQ_IOP32X_XINT0;
+       case 2: /* PCI-X Slot */
+               return IRQ_IOP32X_XINT3;
+       case 3: /* SATA */
+               return IRQ_IOP32X_XINT2;
+       default:
                printk(KERN_ERR "ep80219_pci_map_irq() called for unknown "
                        "device PCI:%d:%d:%d\n", dev->bus->number,
                        PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
-               irq = -1;
+               return -1;
        }
-
-       return irq;
 }
 
Quoted 6 lines
Quoted 4 lines
arch/arm/mach-iop32x/iq31244.c +0 -1
 static struct hw_pci ep80219_pci __initdata = {
--

1.8.1.2

Can someone look into this?

The fact that no one has responded suggests that there is no current maintainer for this. It's far better to leave the code as-is because we know that _that_ used to work fine. Changing it even for cleanups means that the replacement code has not been exercised on real hardware and risks regressions.