Commit 3508bf44 authored by Miguel Jimenez Lopez's avatar Miguel Jimenez Lopez

Update NIC driver for the new IRQ scheme.

parent e09e5b30
......@@ -23,33 +23,10 @@
#include <linux/spinlock.h>
#include <linux/delay.h>
#include <linux/io.h>
#include <linux/irqdomain.h>
#include "wr-nic.h"
#include "nic-mem.h"
/**
* IRQ domain to be used. This is static here but in general it should be
* a module parameter or somehow configurable. For the time being we keep
* it hard-coded here.
*/
#define HTVIC_IRQDOMAIN_NAME "htvic-irq"
static struct irq_domain * irq_find_irqdomain(const char *name)
{
struct irq_fwspec fwspec;
struct irq_domain *d = NULL;
memset(&fwspec,0,sizeof(fwspec));
fwspec.fwnode = (struct fwnode_handle *) name;
fwspec.param_count = 1;
d = irq_find_matching_fwspec(&fwspec,DOMAIN_BUS_ANY);
return d;
}
static inline struct wrn_dev *wrn_from_pdev(struct platform_device *pdev)
{
#if WR_IS_SWITCH
......@@ -64,25 +41,6 @@ static int wrn_remove(struct platform_device *pdev)
{
struct wrn_dev *wrn = wrn_from_pdev(pdev);
int i, irq;
struct irq_domain *irqdomain;
char *irqdomain_name;
struct resource *r;
r = platform_get_resource(pdev, IORESOURCE_BUS, 0);
irqdomain_name = kasprintf(GFP_KERNEL, "%s-%d:%d",
HTVIC_IRQDOMAIN_NAME,
(unsigned char) ((!r) ? 0 : r->start),
(unsigned int) ((!r) ? 0 : r->end));
irqdomain = irq_find_irqdomain(irqdomain_name);
if (!irqdomain) {
dev_err(&pdev->dev, "The IRQ domain %s does not exist\n",
irqdomain_name);
return -EINVAL;
}
kfree(irqdomain_name);
if (WR_IS_SWITCH) {
spin_lock(&wrn->lock);
......@@ -113,8 +71,7 @@ static int wrn_remove(struct platform_device *pdev)
for (i = 0; wrn->irq_registered; i++) {
static int irqs[] = WRN_IRQ_NUMBERS;
if (wrn->irq_registered & (1 << i)) {
irq = irq_find_mapping(irqdomain, irqs[i]);
free_irq(irq, wrn);
free_irq(irqs[i], wrn);
}
wrn->irq_registered &= ~(1 << i);
}
......@@ -124,7 +81,7 @@ static int wrn_remove(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_IRQ, i);
if (!res)
continue;
irq = irq_find_mapping(irqdomain, res->start);
irq = res->start;
free_irq(irq, wrn);
wrn->irq_registered &= ~(1 << i);
}
......@@ -165,7 +122,7 @@ static int __wrn_map_resources(struct platform_device *pdev)
}
/* This helper is used by probe below */
static int __wrn_map_irq(struct platform_device *pdev, struct irq_domain *irqdomain)
static int __wrn_map_irq(struct platform_device *pdev)
{
int i;
struct resource *res;
......@@ -180,7 +137,7 @@ static int __wrn_map_irq(struct platform_device *pdev, struct irq_domain *irqdom
if (WR_IS_SWITCH) {
/* Register the interrupt handlers (not shared) */
for (i = 0; i < ARRAY_SIZE(irq_names); i++) {
irq = irq_find_mapping(irqdomain, irqs[i]);
irq = irqs[i];
err = request_any_context_irq(irq, irq_handlers[i],
IRQF_TRIGGER_LOW, irq_names[i], wrn);
if (err < 0)
......@@ -193,7 +150,7 @@ static int __wrn_map_irq(struct platform_device *pdev, struct irq_domain *irqdom
res = platform_get_resource(pdev, IORESOURCE_IRQ, i);
if (!res)
continue;
irq = irq_find_mapping(irqdomain, res->start);
irq = res->start;
err = request_any_context_irq(irq, irq_handlers[i],
IRQF_TRIGGER_HIGH, res->name, wrn);
......@@ -214,25 +171,6 @@ static int wrn_probe(struct platform_device *pdev)
struct wrn_ep *ep;
struct wrn_dev *wrn = wrn_from_pdev(pdev);
int i, err = 0;
struct irq_domain *irqdomain;
char *irqdomain_name;
struct resource *r;
r = platform_get_resource(pdev, IORESOURCE_BUS, 0);
irqdomain_name = kasprintf(GFP_KERNEL, "%s-%d:%d",
HTVIC_IRQDOMAIN_NAME,
(unsigned char) ((!r) ? 0 : r->start),
(unsigned int) ((!r) ? 0 : r->end));
irqdomain = irq_find_irqdomain(irqdomain_name);
if (!irqdomain) {
dev_err(&pdev->dev, "The IRQ domain %s does not exist\n",
irqdomain_name);
return -EINVAL;
}
kfree(irqdomain_name);
/* No need to lock_irq: we only protect count and continue unlocked */
if (WR_IS_SWITCH) {
......@@ -258,7 +196,7 @@ static int wrn_probe(struct platform_device *pdev)
tasklet_init(&wrn->rx_tlet, wrn_rx_interrupt, (unsigned long)wrn);
;
/* Map our interrupts */
if( (err = __wrn_map_irq(pdev,irqdomain)) )
if( (err = __wrn_map_irq(pdev)) )
goto out;
/* Finally, register one interface per endpoint */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment