[PATCH 1/2] drivers: net: xgene: fix: Derive prefetch number from irq

Mark Rutland mark.rutland at arm.com
Mon Mar 7 11:07:06 PST 2016


On Tue, Mar 08, 2016 at 09:49:36PM -0800, Iyappan Subramanian wrote:
> Prefetch buffer numbers are mapped to hardware irqs. Currently
> they are statically assigned to match with firmware irqs.
> 
> If the irq on firmware changes, prefetch buffer number on the driver
> also needs to be updated to match with the firmware.
> 
> This patch removes this static association between firmware and the
> driver by deriving the prefetch buffer number from the Linux irq.

This driver should neither care about the Linux IRQ number nor the interrupt
controller's physical IRQ number. Neither of the two are properties of the
device.

What you actually care about is the index of the interrupt pin _out_ of the
device, not _into_ the interrupt controller. As with other drivers, that should
described explicitly in the device binding. Either the interrupts should be
listed in a fixed order, or they should be given names.

> +static u8 xgene_start_cpu_bufnum(struct xgene_enet_pdata *pdata)
> +{
> +	struct irq_desc *desc;
> +	int hwirq;
> +
> +	desc = irq_to_desc(pdata->irqs[0]);
> +	hwirq = desc->irq_data.hwirq;
> +
> +	return hwirq - XGENE2_RM0_START_IRQ;
> +}

No device driver should be doing this.

Mark.



More information about the linux-arm-kernel mailing list