parisc: update parisc for new irq_desc
[safe/jmp/linux-2.6] / drivers / mfd / asic3.c
index 80dc333..9e48545 100644 (file)
@@ -16,7 +16,6 @@
  *
  */
 
-#include <linux/version.h>
 #include <linux/kernel.h>
 #include <linux/irq.h>
 #include <linux/gpio.h>
@@ -124,7 +123,7 @@ static void asic3_irq_demux(unsigned int irq, struct irq_desc *desc)
                                        irqnr = asic->irq_base +
                                                (ASIC3_GPIOS_PER_BANK * bank)
                                                + i;
-                                       desc = irq_desc + irqnr;
+                                       desc = irq_to_desc(irqnr);
                                        desc->handle_irq(irqnr, desc);
                                        if (asic->irq_bothedge[bank] & bit)
                                                asic3_irq_flip_edge(asic, base,
@@ -137,7 +136,7 @@ static void asic3_irq_demux(unsigned int irq, struct irq_desc *desc)
                for (i = ASIC3_NUM_GPIOS; i < ASIC3_NR_IRQS; i++) {
                        /* They start at bit 4 and go up */
                        if (status & (1 << (i - ASIC3_NUM_GPIOS + 4))) {
-                               desc = irq_desc +  + i;
+                               desc = irq_to_desc(asic->irq_base + i);
                                desc->handle_irq(asic->irq_base + i,
                                                 desc);
                        }
@@ -256,28 +255,28 @@ static int asic3_gpio_irq_type(unsigned int irq, unsigned int type)
                                      bank + ASIC3_GPIO_TRIGGER_TYPE);
        asic->irq_bothedge[(irq - asic->irq_base) >> 4] &= ~bit;
 
-       if (type == IRQT_RISING) {
+       if (type == IRQ_TYPE_EDGE_RISING) {
                trigger |= bit;
                edge |= bit;
-       } else if (type == IRQT_FALLING) {
+       } else if (type == IRQ_TYPE_EDGE_FALLING) {
                trigger |= bit;
                edge &= ~bit;
-       } else if (type == IRQT_BOTHEDGE) {
+       } else if (type == IRQ_TYPE_EDGE_BOTH) {
                trigger |= bit;
                if (asic3_gpio_get(&asic->gpio, irq - asic->irq_base))
                        edge &= ~bit;
                else
                        edge |= bit;
                asic->irq_bothedge[(irq - asic->irq_base) >> 4] |= bit;
-       } else if (type == IRQT_LOW) {
+       } else if (type == IRQ_TYPE_LEVEL_LOW) {
                trigger &= ~bit;
                level &= ~bit;
-       } else if (type == IRQT_HIGH) {
+       } else if (type == IRQ_TYPE_LEVEL_HIGH) {
                trigger &= ~bit;
                level |= bit;
        } else {
                /*
-                * if type == IRQT_NOEDGE, we should mask interrupts, but
+                * if type == IRQ_TYPE_NONE, we should mask interrupts, but
                 * be careful to not unmask them if mask was also called.
                 * Probably need internal state for mask.
                 */
@@ -313,10 +312,12 @@ static int __init asic3_irq_probe(struct platform_device *pdev)
        struct asic3 *asic = platform_get_drvdata(pdev);
        unsigned long clksel = 0;
        unsigned int irq, irq_base;
+       int ret;
 
-       asic->irq_nr = platform_get_irq(pdev, 0);
-       if (asic->irq_nr < 0)
-               return asic->irq_nr;
+       ret = platform_get_irq(pdev, 0);
+       if (ret < 0)
+               return ret;
+       asic->irq_nr = ret;
 
        /* turn on clock to IRQ controller */
        clksel |= CLOCK_SEL_CX;
@@ -340,7 +341,7 @@ static int __init asic3_irq_probe(struct platform_device *pdev)
                             ASIC3_INTMASK_GINTMASK);
 
        set_irq_chained_handler(asic->irq_nr, asic3_irq_demux);
-       set_irq_type(asic->irq_nr, IRQT_RISING);
+       set_irq_type(asic->irq_nr, IRQ_TYPE_EDGE_RISING);
        set_irq_data(asic->irq_nr, asic);
 
        return 0;
@@ -473,9 +474,9 @@ static __init int asic3_gpio_probe(struct platform_device *pdev,
        u16 dir_reg[ASIC3_NUM_GPIO_BANKS];
        int i;
 
-       memset(alt_reg, 0, ASIC3_NUM_GPIO_BANKS);
-       memset(out_reg, 0, ASIC3_NUM_GPIO_BANKS);
-       memset(dir_reg, 0, ASIC3_NUM_GPIO_BANKS);
+       memset(alt_reg, 0, ASIC3_NUM_GPIO_BANKS * sizeof(u16));
+       memset(out_reg, 0, ASIC3_NUM_GPIO_BANKS * sizeof(u16));
+       memset(dir_reg, 0, ASIC3_NUM_GPIO_BANKS * sizeof(u16));
 
        /* Enable all GPIOs */
        asic3_write_register(asic, ASIC3_GPIO_OFFSET(A, MASK), 0xffff);
@@ -532,6 +533,7 @@ static int __init asic3_probe(struct platform_device *pdev)
        struct asic3 *asic;
        struct resource *mem;
        unsigned long clksel;
+       int map_size;
        int ret = 0;
 
        asic = kzalloc(sizeof(struct asic3), GFP_KERNEL);
@@ -551,8 +553,8 @@ static int __init asic3_probe(struct platform_device *pdev)
                goto out_free;
        }
 
-
-       asic->mapping = ioremap(mem->start, PAGE_SIZE);
+       map_size = mem->end - mem->start + 1;
+       asic->mapping = ioremap(mem->start, map_size);
        if (!asic->mapping) {
                ret = -ENOMEM;
                dev_err(asic->dev, "Couldn't ioremap\n");
@@ -561,10 +563,8 @@ static int __init asic3_probe(struct platform_device *pdev)
 
        asic->irq_base = pdata->irq_base;
 
-       if (pdata && pdata->bus_shift)
-               asic->bus_shift = 2 - pdata->bus_shift;
-       else
-               asic->bus_shift = 0;
+       /* calculate bus shift from mem resource */
+       asic->bus_shift = 2 - (map_size >> 12);
 
        clksel = 0;
        asic3_write_register(asic, ASIC3_OFFSET(CLOCK, SEL), clksel);