Re: [-mm patch] aic7xxx: check irq validity (was Re: 2.6.18-mm2)

Matthew Wilcox
2006-10-01T19:36:17Z

On Sun, Oct 01, 2006 at 09:05:23PM +0200, Arjan van de Ven wrote:
> > int pci_request_irq(struct pci_dev *pdev, irq_handler_t handler,
> > unsigned long flags, const char *name, void *data)
> > {
> > if (!valid_irq(pdev->irq)) {
> > dev_printk(KERN_ERR, &pdev->dev, "invalid irq\n");
> > return -EINVAL;
> > }
> >
> > return request_irq(pdev->irq, handler, flags | IRQF_SHARED, name, data);
> > }
>
> well... why not go one step further and eliminate the flags argument
> entirely? And use pci_name() for the name (so eliminate the argument ;)
> and always pass pdev as data, so that that argument can go away too....
>
> that'll cover 99% of the request_irq() users for pci devices.. and makes
> it really nicely simple and consistent.

hmm. $ echo `cut -c34- /proc/interrupts`
timer i8042 cascade acpi yenta, ehci_hcd:usb1, Intel 82801DB-ICH4 yenta,
uhci_hcd:usb2 uhci_hcd:usb4, eth0 ide0 uhci_hcd:usb3, eth1

Network drivers use their eth%d name. USB drivers use [eu]hci_hcd:usb%d.
Others tend to use the driver name. Changing them all to be 0000:00:1d.2
isn't really an improvement in the readability of /proc/interrupts, IMO.

Passing pdev as the data is a good idea for practically no device driver.
It's rare to actually want the pci_device down in the interrupt handler;
normally you want the device private data. Using pci_get_drvdata(pdev)
as the data would make sense for both sym2 and tg3. I don't feel like
auditing other drivers to see if it'd make sense for them too.

So, current proposal:

int pci_request_irq(struct pci_dev *pdev, irq_handler_t handler,
const char *name)
{
if (!valid_irq(pdev->irq)) {
dev_printk(KERN_ERR, &pdev->dev, "invalid irq\n");
return -EINVAL;
}

return request_irq(pdev->irq, handler, IRQF_SHARED, name,
pci_get_drvdata(pdev));
}

But what about IRQF_SAMPLE_RANDOM?