Skip to content

Commit

Permalink
powerpc: Remove all usages of NO_IRQ
Browse files Browse the repository at this point in the history
NO_IRQ has been == 0 on powerpc for just over ten years (since commit
0ebfff1 ("[POWERPC] Add new interrupt mapping core and change
platforms to use it")). It's also 0 on most other arches.

Although it's fairly harmless, every now and then it causes confusion
when a driver is built on powerpc and another arch which doesn't define
NO_IRQ. There's at least 6 definitions of NO_IRQ in drivers/, at least
some of which are to work around that problem.

So we'd like to remove it. This is fairly trivial in the arch code, we
just convert:

    if (irq == NO_IRQ)	to	if (!irq)
    if (irq != NO_IRQ)	to	if (irq)
    irq = NO_IRQ;	to	irq = 0;
    return NO_IRQ;	to	return 0;

And a few other odd cases as well.

At least for now we keep the #define NO_IRQ, because there is driver
code that uses NO_IRQ and the fixes to remove those will go via other
trees.

Note we also change some occurrences in PPC sound drivers, drivers/ps3,
and drivers/macintosh.

Signed-off-by: Michael Ellerman <[email protected]>
  • Loading branch information
mpe committed Sep 20, 2016
1 parent 9d82fd2 commit ef24ba7
Show file tree
Hide file tree
Showing 80 changed files with 204 additions and 200 deletions.
2 changes: 1 addition & 1 deletion arch/powerpc/include/asm/machdep.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct machdep_calls {

void (*init_IRQ)(void);

/* Return an irq, or NO_IRQ to indicate there are none pending. */
/* Return an irq, or 0 to indicate there are none pending. */
unsigned int (*get_irq)(void);

/* PCI stuff */
Expand Down
6 changes: 3 additions & 3 deletions arch/powerpc/include/asm/mpic_msgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ static inline void mpic_msgr_set_destination(struct mpic_msgr *msgr,
* @msgr: the message register whose IRQ is to be returned
*
* Returns the IRQ number associated with the given message register.
* NO_IRQ is returned if this message register is not capable of
* receiving interrupts. What message register can and cannot receive
* interrupts is specified in the device tree for the system.
* 0 is returned if this message register is not capable of receiving
* interrupts. What message register can and cannot receive interrupts is
* specified in the device tree for the system.
*/
static inline int mpic_msgr_get_irq(struct mpic_msgr *msgr)
{
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/include/asm/parport.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static int parport_pc_find_nonpci_ports (int autoirq, int autodma)
io1 = prop[1]; io2 = prop[2];

virq = irq_of_parse_and_map(np, 0);
if (virq == NO_IRQ)
if (!virq)
continue;

if (parport_pc_probe_port(io1, io2, virq, autodma, NULL, 0)
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/kernel/ibmebus.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ int ibmebus_request_irq(u32 ist, irq_handler_t handler,
{
unsigned int irq = irq_create_mapping(NULL, ist);

if (irq == NO_IRQ)
if (!irq)
return -EINVAL;

return request_irq(irq, handler, irq_flags, devname, dev_id);
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/kernel/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ void __do_irq(struct pt_regs *regs)
may_hard_irq_enable();

/* And finally process it */
if (unlikely(irq == NO_IRQ))
if (unlikely(!irq))
__this_cpu_inc(irq_stat.spurious_irqs);
else
generic_handle_irq(irq);
Expand Down
14 changes: 7 additions & 7 deletions arch/powerpc/kernel/legacy_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ static int __init add_legacy_soc_port(struct device_node *np,
*/
if (tsi && !strcmp(tsi->type, "tsi-bridge"))
return add_legacy_port(np, -1, UPIO_TSI, addr, addr,
NO_IRQ, legacy_port_flags, 0);
0, legacy_port_flags, 0);
else
return add_legacy_port(np, -1, UPIO_MEM, addr, addr,
NO_IRQ, legacy_port_flags, 0);
0, legacy_port_flags, 0);
}

static int __init add_legacy_isa_port(struct device_node *np,
Expand Down Expand Up @@ -242,7 +242,7 @@ static int __init add_legacy_isa_port(struct device_node *np,

/* Add port, irq will be dealt with later */
return add_legacy_port(np, index, UPIO_PORT, be32_to_cpu(reg[1]),
taddr, NO_IRQ, legacy_port_flags, 0);
taddr, 0, legacy_port_flags, 0);

}

Expand Down Expand Up @@ -314,7 +314,7 @@ static int __init add_legacy_pci_port(struct device_node *np,
/* Add port, irq will be dealt with later. We passed a translated
* IO port value. It will be fixed up later along with the irq
*/
return add_legacy_port(np, index, iotype, base, addr, NO_IRQ,
return add_legacy_port(np, index, iotype, base, addr, 0,
legacy_port_flags, np != pci_dev);
}
#endif
Expand Down Expand Up @@ -462,14 +462,14 @@ static void __init fixup_port_irq(int index,
DBG("fixup_port_irq(%d)\n", index);

virq = irq_of_parse_and_map(np, 0);
if (virq == NO_IRQ && legacy_serial_infos[index].irq_check_parent) {
if (!virq && legacy_serial_infos[index].irq_check_parent) {
np = of_get_parent(np);
if (np == NULL)
return;
virq = irq_of_parse_and_map(np, 0);
of_node_put(np);
}
if (virq == NO_IRQ)
if (!virq)
return;

port->irq = virq;
Expand Down Expand Up @@ -543,7 +543,7 @@ static int __init serial_dev_init(void)
struct plat_serial8250_port *port = &legacy_serial_ports[i];
struct device_node *np = legacy_serial_infos[i].np;

if (port->irq == NO_IRQ)
if (!port->irq)
fixup_port_irq(i, np, port);
if (port->iotype == UPIO_PORT)
fixup_port_pio(i, np, port);
Expand Down
5 changes: 3 additions & 2 deletions arch/powerpc/kernel/pci-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ static int pci_read_irq_line(struct pci_dev *pci_dev)
line, pin);

virq = irq_create_mapping(NULL, line);
if (virq != NO_IRQ)
if (virq)
irq_set_irq_type(virq, IRQ_TYPE_LEVEL_LOW);
} else {
pr_debug(" Got one, spec %d cells (0x%08x 0x%08x...) on %s\n",
Expand All @@ -369,7 +369,8 @@ static int pci_read_irq_line(struct pci_dev *pci_dev)

virq = irq_create_of_mapping(&oirq);
}
if(virq == NO_IRQ) {

if (!virq) {
pr_debug(" Failed to map !\n");
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/kernel/pci_of_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ struct pci_dev *of_create_pci_dev(struct device_node *node,
dev->hdr_type = PCI_HEADER_TYPE_NORMAL;
dev->rom_base_reg = PCI_ROM_ADDRESS;
/* Maybe do a default OF mapping here */
dev->irq = NO_IRQ;
dev->irq = 0;
}

of_pci_parse_addrs(node, dev);
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/44x/warp.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ static void pika_setup_critical_temp(struct device_node *np,
i2c_smbus_write_byte_data(client, 3, 0); /* Tlow */

irq = irq_of_parse_and_map(np, 0);
if (irq == NO_IRQ) {
if (!irq) {
printk(KERN_ERR __FILE__ ": Unable to get ad7414 irq\n");
return;
}
Expand Down
8 changes: 4 additions & 4 deletions arch/powerpc/platforms/512x/mpc5121_ads_cpld.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ cpld_pic_get_irq(int offset, u8 ignore, u8 __iomem *statusp,
status |= (ignore | mask);

if (status == 0xff)
return NO_IRQ;
return 0;

cpld_irq = ffz(status) + offset;

Expand All @@ -110,14 +110,14 @@ static void cpld_pic_cascade(struct irq_desc *desc)

irq = cpld_pic_get_irq(0, PCI_IGNORE, &cpld_regs->pci_status,
&cpld_regs->pci_mask);
if (irq != NO_IRQ) {
if (irq) {
generic_handle_irq(irq);
return;
}

irq = cpld_pic_get_irq(8, MISC_IGNORE, &cpld_regs->misc_status,
&cpld_regs->misc_mask);
if (irq != NO_IRQ) {
if (irq) {
generic_handle_irq(irq);
return;
}
Expand Down Expand Up @@ -177,7 +177,7 @@ mpc5121_ads_cpld_pic_init(void)
goto end;

cascade_irq = irq_of_parse_and_map(np, 0);
if (cascade_irq == NO_IRQ)
if (!cascade_irq)
goto end;

/*
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/512x/mpc512x_lpbfifo.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ static int mpc512x_lpbfifo_probe(struct platform_device *pdev)
}

lpbfifo.irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
if (lpbfifo.irq == NO_IRQ) {
if (!lpbfifo.irq) {
dev_err(&pdev->dev, "mapping irq failed\n");
ret = -ENODEV;
goto err0;
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/52xx/mpc52xx_pic.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ unsigned int mpc52xx_get_irq(void)
irq |= (MPC52xx_IRQ_L1_PERP << MPC52xx_IRQ_L1_OFFSET);
}
} else {
return NO_IRQ;
return 0;
}

return irq_linear_revmap(mpc52xx_irqhost, irq);
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/82xx/pq2ads-pci-pic.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ int __init pq2ads_pci_init_irq(void)
}

irq = irq_of_parse_and_map(np, 0);
if (irq == NO_IRQ) {
if (!irq) {
printk(KERN_ERR "No interrupt in pci pic node.\n");
of_node_put(np);
goto out;
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/83xx/mpc832x_rdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static int __init of_fsl_spi_probe(char *type, char *compatible, u32 sysclk,
goto err;

ret = of_irq_to_resource(np, 0, &res[1]);
if (ret == NO_IRQ)
if (!ret)
goto err;

pdev = platform_device_alloc("mpc83xx_spi", i);
Expand Down
4 changes: 2 additions & 2 deletions arch/powerpc/platforms/83xx/suspend.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ static int pmc_probe(struct platform_device *ofdev)
return -ENODEV;

pmc_irq = irq_of_parse_and_map(np, 0);
if (pmc_irq != NO_IRQ) {
if (pmc_irq) {
ret = request_irq(pmc_irq, pmc_irq_handler, IRQF_SHARED,
"pmc", ofdev);

Expand Down Expand Up @@ -400,7 +400,7 @@ static int pmc_probe(struct platform_device *ofdev)
out_pmc:
iounmap(pmc_regs);
out:
if (pmc_irq != NO_IRQ)
if (pmc_irq)
free_irq(pmc_irq, ofdev);

return ret;
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/85xx/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void __init mpc85xx_cpm2_pic_init(void)
return;
}
irq = irq_of_parse_and_map(np, 0);
if (irq == NO_IRQ) {
if (!irq) {
of_node_put(np);
printk(KERN_ERR "PIC init: got no IRQ for cpm cascade\n");
return;
Expand Down
4 changes: 2 additions & 2 deletions arch/powerpc/platforms/85xx/mpc85xx_cds.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ static void mpc85xx_8259_cascade_handler(struct irq_desc *desc)
{
unsigned int cascade_irq = i8259_irq();

if (cascade_irq != NO_IRQ)
if (cascade_irq)
/* handle an interrupt from the 8259 */
generic_handle_irq(cascade_irq);

Expand Down Expand Up @@ -247,7 +247,7 @@ static int mpc85xx_cds_8259_attach(void)
}

cascade_irq = irq_of_parse_and_map(cascade_node, 0);
if (cascade_irq == NO_IRQ) {
if (!cascade_irq) {
printk(KERN_ERR "Failed to map cascade interrupt\n");
return -ENXIO;
}
Expand Down
4 changes: 2 additions & 2 deletions arch/powerpc/platforms/85xx/mpc85xx_ds.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static void mpc85xx_8259_cascade(struct irq_desc *desc)
struct irq_chip *chip = irq_desc_get_chip(desc);
unsigned int cascade_irq = i8259_irq();

if (cascade_irq != NO_IRQ) {
if (cascade_irq) {
generic_handle_irq(cascade_irq);
}
chip->irq_eoi(&desc->irq_data);
Expand Down Expand Up @@ -96,7 +96,7 @@ void __init mpc85xx_ds_pic_init(void)
}

cascade_irq = irq_of_parse_and_map(cascade_node, 0);
if (cascade_irq == NO_IRQ) {
if (!cascade_irq) {
printk(KERN_ERR "Failed to map cascade interrupt\n");
return;
}
Expand Down
6 changes: 3 additions & 3 deletions arch/powerpc/platforms/85xx/socrates_fpga_pic.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static inline unsigned int socrates_fpga_pic_get_irq(unsigned int irq)
break;
}
if (i == 3)
return NO_IRQ;
return 0;

raw_spin_lock_irqsave(&socrates_fpga_pic_lock, flags);
cause = socrates_fpga_pic_read(FPGA_PIC_IRQMASK(i));
Expand All @@ -103,7 +103,7 @@ static void socrates_fpga_pic_cascade(struct irq_desc *desc)
*/
cascade_irq = socrates_fpga_pic_get_irq(irq);

if (cascade_irq != NO_IRQ)
if (cascade_irq)
generic_handle_irq(cascade_irq);
chip->irq_eoi(&desc->irq_data);
}
Expand Down Expand Up @@ -292,7 +292,7 @@ void socrates_fpga_pic_init(struct device_node *pic)

for (i = 0; i < 3; i++) {
socrates_fpga_irqs[i] = irq_of_parse_and_map(pic, i);
if (socrates_fpga_irqs[i] == NO_IRQ) {
if (!socrates_fpga_irqs[i]) {
pr_warning("FPGA PIC: can't get irq%d.\n", i);
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions arch/powerpc/platforms/86xx/pic.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static void mpc86xx_8259_cascade(struct irq_desc *desc)
struct irq_chip *chip = irq_desc_get_chip(desc);
unsigned int cascade_irq = i8259_irq();

if (cascade_irq != NO_IRQ)
if (cascade_irq)
generic_handle_irq(cascade_irq);

chip->irq_eoi(&desc->irq_data);
Expand Down Expand Up @@ -58,7 +58,7 @@ void __init mpc86xx_init_irq(void)
}

cascade_irq = irq_of_parse_and_map(cascade_node, 0);
if (cascade_irq == NO_IRQ) {
if (!cascade_irq) {
printk(KERN_ERR "Failed to map cascade interrupt\n");
return;
}
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/8xx/m8xx_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,6 @@ void __init mpc8xx_pics_init(void)
}

irq = cpm_pic_init();
if (irq != NO_IRQ)
if (irq)
irq_set_chained_handler(irq, cpm_cascade);
}
6 changes: 3 additions & 3 deletions arch/powerpc/platforms/cell/axon_msi.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ static int axon_msi_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)

for_each_pci_msi_entry(entry, dev) {
virq = irq_create_direct_mapping(msic->irq_domain);
if (virq == NO_IRQ) {
if (!virq) {
dev_warn(&dev->dev,
"axon_msi: virq allocation failed!\n");
return -1;
Expand All @@ -293,7 +293,7 @@ static void axon_msi_teardown_msi_irqs(struct pci_dev *dev)
dev_dbg(&dev->dev, "axon_msi: tearing down msi irqs\n");

for_each_pci_msi_entry(entry, dev) {
if (entry->irq == NO_IRQ)
if (!entry->irq)
continue;

irq_set_msi_desc(entry->irq, NULL);
Expand Down Expand Up @@ -375,7 +375,7 @@ static int axon_msi_probe(struct platform_device *device)
}

virq = irq_of_parse_and_map(dn, 0);
if (virq == NO_IRQ) {
if (!virq) {
printk(KERN_ERR "axon_msi: irq parse and map failed for %s\n",
dn->full_name);
goto out_free_fifo;
Expand Down
12 changes: 6 additions & 6 deletions arch/powerpc/platforms/cell/interrupt.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ static void iic_ioexc_cascade(struct irq_desc *desc)
unsigned int cirq =
irq_linear_revmap(iic_host,
base | cascade);
if (cirq != NO_IRQ)
if (cirq)
generic_handle_irq(cirq);
}
/* post-ack level interrupts */
Expand Down Expand Up @@ -153,10 +153,10 @@ static unsigned int iic_get_irq(void)
*(unsigned long *) &pending =
in_be64((u64 __iomem *) &iic->regs->pending_destr);
if (!(pending.flags & CBE_IIC_IRQ_VALID))
return NO_IRQ;
return 0;
virq = irq_linear_revmap(iic_host, iic_pending_to_hwnum(pending));
if (virq == NO_IRQ)
return NO_IRQ;
if (!virq)
return 0;
iic->eoi_stack[++iic->eoi_ptr] = pending.prio;
BUG_ON(iic->eoi_ptr > 15);
return virq;
Expand Down Expand Up @@ -192,7 +192,7 @@ static void iic_request_ipi(int msg)
int virq;

virq = irq_create_mapping(iic_host, iic_msg_to_irq(msg));
if (virq == NO_IRQ) {
if (!virq) {
printk(KERN_ERR
"iic: failed to map IPI %s\n", smp_ipi_name[msg]);
return;
Expand Down Expand Up @@ -347,7 +347,7 @@ static int __init setup_iic(void)
cascade |= 1 << IIC_IRQ_CLASS_SHIFT;
cascade |= IIC_UNIT_IIC;
cascade = irq_create_mapping(iic_host, cascade);
if (cascade == NO_IRQ)
if (!cascade)
continue;
/*
* irq_data is a generic pointer that gets passed back
Expand Down
Loading

0 comments on commit ef24ba7

Please sign in to comment.