pirqs = kzalloc(*count * sizeof(int), GFP_KERNEL);
if (!pirqs)
return -ENOMEM;
dev->desc = irq_create_affinity_masks(*count, affd);
if (!dev->desc) {
kfree(irqs);
pirqs I assume and this also leaks the affinity masks and the pointer in
dev.
return -ENOMEM;
}
for (i = 0; i < *count; i++) {
pirqs[i] = platform_get_irq(dev, i);
if (irqs[i] < 0) {
kfree(dev->desc);
kfree(irqs);
return -ENOMEM;
That's obviously broken as well :)
}
}
*irqs = pirqs;
return 0;
}
EXPORT_SYMBOL_GPL(platform_get_irqs_affinity);
I wouldn't mind to expose a function which allows you to switch the
allocated interrupts to managed. The reason why we do it in one go in
the PCI code is that we get automatically the irq descriptors allocated
on the correct node. So if the node aware allocation is not a
showstopper
...
for (i = 0; i < count; i++) {
pirqs[i] = platform_get_irq(dev, i);
irq_update_affinity_desc(pirqs[i], affdescs + i);
}
int irq_update_affinity_desc(unsigned int irq, irq_affinity_desc *affinity)
{
unsigned long flags;
struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0);
if (!desc)
return -EINVAL;
if (affinity->is_managed) {
irqd_set(&desc->irq_data, IRQD_IRQ_DISABLED);
irqd_set(&desc->irq_data, IRQD_IRQ_MASKED);
}
cpumask_copy(desc->irq_common_data.affinity, affinity);
return 0;
}