[PATCH] defxx: Use irqreturn_t for the interrupt handler

This is a fix for the interrupt handler in the defxx driver to use
irqreturn_t. Beside the obvious fix of returning a proper status at all,
it actually checks board registers as appropriate for determining if an
interrupt has been recorded in the bus-specific interface logic.

The patch also includes an obvious one-line fix for SET_NETDEV_DEV needed
for the EISA variation, for which I've decided there is no point in sending
separately.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
Cc: Jeff Garzik <jgarzik@pobox.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>

authored by Maciej W. Rozycki and committed by Jeff Garzik feea1db2 16b110c3

+51 -37
+51 -37
drivers/net/defxx.c
··· 191 191 * Feb 2001 davej PCI enable cleanups. 192 192 * 04 Aug 2003 macro Converted to the DMA API. 193 193 * 14 Aug 2004 macro Fix device names reported. 194 + * 14 Jun 2005 macro Use irqreturn_t. 194 195 */ 195 196 196 197 /* Include files */ ··· 218 217 219 218 /* Version information string should be updated prior to each new release! */ 220 219 #define DRV_NAME "defxx" 221 - #define DRV_VERSION "v1.07" 222 - #define DRV_RELDATE "2004/08/14" 220 + #define DRV_VERSION "v1.08" 221 + #define DRV_RELDATE "2005/06/14" 223 222 224 223 static char version[] __devinitdata = 225 224 DRV_NAME ": " DRV_VERSION " " DRV_RELDATE ··· 248 247 static void dfx_int_pr_halt_id(DFX_board_t *bp); 249 248 static void dfx_int_type_0_process(DFX_board_t *bp); 250 249 static void dfx_int_common(struct net_device *dev); 251 - static void dfx_interrupt(int irq, void *dev_id, struct pt_regs *regs); 250 + static irqreturn_t dfx_interrupt(int irq, void *dev_id, 251 + struct pt_regs *regs); 252 252 253 253 static struct net_device_stats *dfx_ctl_get_stats(struct net_device *dev); 254 254 static void dfx_ctl_set_multicast_list(struct net_device *dev); ··· 439 437 } 440 438 441 439 SET_MODULE_OWNER(dev); 442 - SET_NETDEV_DEV(dev, &pdev->dev); 440 + if (pdev != NULL) 441 + SET_NETDEV_DEV(dev, &pdev->dev); 443 442 444 443 bp = dev->priv; 445 444 ··· 1228 1225 1229 1226 /* Register IRQ - support shared interrupts by passing device ptr */ 1230 1227 1231 - ret = request_irq(dev->irq, (void *)dfx_interrupt, SA_SHIRQ, dev->name, dev); 1228 + ret = request_irq(dev->irq, dfx_interrupt, SA_SHIRQ, dev->name, dev); 1232 1229 if (ret) { 1233 1230 printk(KERN_ERR "%s: Requested IRQ %d is busy\n", dev->name, dev->irq); 1234 1231 return ret; ··· 1683 1680 * ================= 1684 1681 * = dfx_interrupt = 1685 1682 * ================= 1686 - * 1683 + * 1687 1684 * Overview: 1688 1685 * Interrupt processing routine 1689 - * 1686 + * 1690 1687 * Returns: 1691 - * None 1692 - * 1688 + * Whether a valid interrupt was seen. 1689 + * 1693 1690 * Arguments: 1694 1691 * irq - interrupt vector 1695 1692 * dev_id - pointer to device information ··· 1702 1699 * structure context. 1703 1700 * 1704 1701 * Return Codes: 1705 - * None 1702 + * IRQ_HANDLED - an IRQ was handled. 1703 + * IRQ_NONE - no IRQ was handled. 1706 1704 * 1707 1705 * Assumptions: 1708 1706 * The interrupt acknowledgement at the hardware level (eg. ACKing the PIC ··· 1716 1712 * Interrupts are disabled, then reenabled at the adapter. 1717 1713 */ 1718 1714 1719 - static void dfx_interrupt(int irq, void *dev_id, struct pt_regs *regs) 1720 - { 1715 + static irqreturn_t dfx_interrupt(int irq, void *dev_id, struct pt_regs *regs) 1716 + { 1721 1717 struct net_device *dev = dev_id; 1722 1718 DFX_board_t *bp; /* private board structure pointer */ 1723 - u8 tmp; /* used for disabling/enabling ints */ 1724 1719 1725 1720 /* Get board pointer only if device structure is valid */ 1726 1721 1727 1722 bp = dev->priv; 1728 1723 1729 - spin_lock(&bp->lock); 1730 - 1731 1724 /* See if we're already servicing an interrupt */ 1732 1725 1733 1726 /* Service adapter interrupts */ 1734 1727 1735 - if (bp->bus_type == DFX_BUS_TYPE_PCI) 1736 - { 1737 - /* Disable PDQ-PFI interrupts at PFI */ 1728 + if (bp->bus_type == DFX_BUS_TYPE_PCI) { 1729 + u32 status; 1738 1730 1739 - dfx_port_write_long(bp, PFI_K_REG_MODE_CTRL, PFI_MODE_M_DMA_ENB); 1731 + dfx_port_read_long(bp, PFI_K_REG_STATUS, &status); 1732 + if (!(status & PFI_STATUS_M_PDQ_INT)) 1733 + return IRQ_NONE; 1734 + 1735 + spin_lock(&bp->lock); 1736 + 1737 + /* Disable PDQ-PFI interrupts at PFI */ 1738 + dfx_port_write_long(bp, PFI_K_REG_MODE_CTRL, 1739 + PFI_MODE_M_DMA_ENB); 1740 1740 1741 1741 /* Call interrupt service routine for this adapter */ 1742 - 1743 1742 dfx_int_common(dev); 1744 1743 1745 1744 /* Clear PDQ interrupt status bit and reenable interrupts */ 1746 - 1747 - dfx_port_write_long(bp, PFI_K_REG_STATUS, PFI_STATUS_M_PDQ_INT); 1745 + dfx_port_write_long(bp, PFI_K_REG_STATUS, 1746 + PFI_STATUS_M_PDQ_INT); 1748 1747 dfx_port_write_long(bp, PFI_K_REG_MODE_CTRL, 1749 - (PFI_MODE_M_PDQ_INT_ENB + PFI_MODE_M_DMA_ENB)); 1750 - } 1751 - else 1752 - { 1753 - /* Disable interrupts at the ESIC */ 1748 + (PFI_MODE_M_PDQ_INT_ENB | 1749 + PFI_MODE_M_DMA_ENB)); 1754 1750 1755 - dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &tmp); 1756 - tmp &= ~PI_CONFIG_STAT_0_M_INT_ENB; 1757 - dfx_port_write_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, tmp); 1751 + spin_unlock(&bp->lock); 1752 + } else { 1753 + u8 status; 1754 + 1755 + dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &status); 1756 + if (!(status & PI_CONFIG_STAT_0_M_PEND)) 1757 + return IRQ_NONE; 1758 + 1759 + spin_lock(&bp->lock); 1760 + 1761 + /* Disable interrupts at the ESIC */ 1762 + status &= ~PI_CONFIG_STAT_0_M_INT_ENB; 1763 + dfx_port_write_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, status); 1758 1764 1759 1765 /* Call interrupt service routine for this adapter */ 1760 - 1761 1766 dfx_int_common(dev); 1762 1767 1763 1768 /* Reenable interrupts at the ESIC */ 1769 + dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &status); 1770 + status |= PI_CONFIG_STAT_0_M_INT_ENB; 1771 + dfx_port_write_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, status); 1764 1772 1765 - dfx_port_read_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, &tmp); 1766 - tmp |= PI_CONFIG_STAT_0_M_INT_ENB; 1767 - dfx_port_write_byte(bp, PI_ESIC_K_IO_CONFIG_STAT_0, tmp); 1768 - } 1769 - 1770 - spin_unlock(&bp->lock); 1773 + spin_unlock(&bp->lock); 1771 1774 } 1775 + 1776 + return IRQ_HANDLED; 1777 + } 1772 1778 1773 1779 1774 1780 /*