fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / arch / arm / kernel / ecard.c
index 3dc15b1..71257e3 100644 (file)
@@ -27,7 +27,6 @@
  */
 #define ECARD_C
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
@@ -40,6 +39,7 @@
 #include <linux/proc_fs.h>
 #include <linux/device.h>
 #include <linux/init.h>
+#include <linux/mutex.h>
 
 #include <asm/dma.h>
 #include <asm/ecard.h>
@@ -206,7 +206,7 @@ static void ecard_task_readbytes(struct ecard_request *req)
 
 static DECLARE_WAIT_QUEUE_HEAD(ecard_wait);
 static struct ecard_request *ecard_req;
-static DECLARE_MUTEX(ecard_sem);
+static DEFINE_MUTEX(ecard_mutex);
 
 /*
  * Set up the expansion card daemon's page tables.
@@ -295,11 +295,11 @@ ecard_task(void * unused)
  */
 static void ecard_call(struct ecard_request *req)
 {
-       DECLARE_COMPLETION(completion);
+       DECLARE_COMPLETION_ONSTACK(completion);
 
        req->complete = &completion;
 
-       down(&ecard_sem);
+       mutex_lock(&ecard_mutex);
        ecard_req = req;
        wake_up(&ecard_wait);
 
@@ -307,7 +307,7 @@ static void ecard_call(struct ecard_request *req)
         * Now wait for kecardd to run.
         */
        wait_for_completion(&completion);
-       up(&ecard_sem);
+       mutex_unlock(&ecard_mutex);
 }
 
 /* ======================= Mid-level card control ===================== */
@@ -353,7 +353,7 @@ int ecard_readchunk(struct in_chunk_dir *cd, ecard_t *ec, int id, int num)
                }
                if (c_id(&excd) == 0x80) { /* loader */
                        if (!ec->loader) {
-                               ec->loader = (loader_t)kmalloc(c_len(&excd),
+                               ec->loader = kmalloc(c_len(&excd),
                                                               GFP_KERNEL);
                                if (ec->loader)
                                        ecard_readbytes(ec->loader, ec,
@@ -470,7 +470,8 @@ static void ecard_irq_mask(unsigned int irqnr)
        }
 }
 
-static struct irqchip ecard_chip = {
+static struct irq_chip ecard_chip = {
+       .name   = "ECARD",
        .ack    = ecard_irq_mask,
        .mask   = ecard_irq_mask,
        .unmask = ecard_irq_unmask,
@@ -528,7 +529,7 @@ static void ecard_dump_irq_state(void)
        }
 }
 
-static void ecard_check_lockup(struct irqdesc *desc)
+static void ecard_check_lockup(struct irq_desc *desc)
 {
        static unsigned long last;
        static int lockup;
@@ -566,7 +567,7 @@ static void ecard_check_lockup(struct irqdesc *desc)
 }
 
 static void
-ecard_irq_handler(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs)
+ecard_irq_handler(unsigned int irq, struct irq_desc *desc)
 {
        ecard_t *ec;
        int called = 0;
@@ -584,8 +585,8 @@ ecard_irq_handler(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs)
                        pending = ecard_default_ops.irqpending(ec);
 
                if (pending) {
-                       struct irqdesc *d = irq_desc + ec->irq;
-                       d->handle(ec->irq, d, regs);
+                       struct irq_desc *d = irq_desc + ec->irq;
+                       desc_handle_irq(ec->irq, d);
                        called ++;
                }
        }
@@ -608,7 +609,7 @@ static unsigned char first_set[] =
 };
 
 static void
-ecard_irqexp_handler(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs)
+ecard_irqexp_handler(unsigned int irq, struct irq_desc *desc)
 {
        const unsigned int statusmask = 15;
        unsigned int status;
@@ -619,7 +620,7 @@ ecard_irqexp_handler(unsigned int irq, struct irqdesc *desc, struct pt_regs *reg
                ecard_t *ec = slot_to_ecard(slot);
 
                if (ec->claimed) {
-                       struct irqdesc *d = irqdesc + ec->irq;
+                       struct irq_desc *d = irq_desc + ec->irq;
                        /*
                         * this ugly code is so that we can operate a
                         * prioritorising system:
@@ -632,7 +633,7 @@ ecard_irqexp_handler(unsigned int irq, struct irqdesc *desc, struct pt_regs *reg
                         * Serial cards should go in 0/1, ethernet/scsi in 2/3
                         * otherwise you will lose serial data at high speeds!
                         */
-                       d->handle(ec->irq, d, regs);
+                       desc_handle_irq(ec->irq, d);
                } else {
                        printk(KERN_WARNING "card%d: interrupt from unclaimed "
                               "card???\n", slot);
@@ -806,14 +807,12 @@ static struct expansion_card *__init ecard_alloc_card(int type, int slot)
        unsigned long base;
        int i;
 
-       ec = kmalloc(sizeof(ecard_t), GFP_KERNEL);
+       ec = kzalloc(sizeof(ecard_t), GFP_KERNEL);
        if (!ec) {
                ec = ERR_PTR(-ENOMEM);
                goto nomem;
        }
 
-       memset(ec, 0, sizeof(ecard_t));
-
        ec->slot_no = slot;
        ec->type = type;
        ec->irq = NO_IRQ;
@@ -866,26 +865,26 @@ static struct expansion_card *__init ecard_alloc_card(int type, int slot)
        return ec;
 }
 
-static ssize_t ecard_show_irq(struct device *dev, char *buf)
+static ssize_t ecard_show_irq(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct expansion_card *ec = ECARD_DEV(dev);
        return sprintf(buf, "%u\n", ec->irq);
 }
 
-static ssize_t ecard_show_dma(struct device *dev, char *buf)
+static ssize_t ecard_show_dma(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct expansion_card *ec = ECARD_DEV(dev);
        return sprintf(buf, "%u\n", ec->dma);
 }
 
-static ssize_t ecard_show_resources(struct device *dev, char *buf)
+static ssize_t ecard_show_resources(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct expansion_card *ec = ECARD_DEV(dev);
        char *str = buf;
        int i;
 
        for (i = 0; i < ECARD_NUM_RESOURCES; i++)
-               str += sprintf(str, "%08lx %08lx %08lx\n",
+               str += sprintf(str, "%08x %08x %08lx\n",
                                ec->resource[i].start,
                                ec->resource[i].end,
                                ec->resource[i].flags);
@@ -893,19 +892,19 @@ static ssize_t ecard_show_resources(struct device *dev, char *buf)
        return str - buf;
 }
 
-static ssize_t ecard_show_vendor(struct device *dev, char *buf)
+static ssize_t ecard_show_vendor(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct expansion_card *ec = ECARD_DEV(dev);
        return sprintf(buf, "%u\n", ec->cid.manufacturer);
 }
 
-static ssize_t ecard_show_device(struct device *dev, char *buf)
+static ssize_t ecard_show_device(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct expansion_card *ec = ECARD_DEV(dev);
        return sprintf(buf, "%u\n", ec->cid.product);
 }
 
-static ssize_t ecard_show_type(struct device *dev, char *buf)
+static ssize_t ecard_show_type(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct expansion_card *ec = ECARD_DEV(dev);
        return sprintf(buf, "%s\n", ec->type == ECARD_EASI ? "EASI" : "IOC");
@@ -1023,7 +1022,7 @@ ecard_probe(int slot, card_type_t type)
        if (slot < 8) {
                ec->irq = 32 + slot;
                set_irq_chip(ec->irq, &ecard_chip);
-               set_irq_handler(ec->irq, do_level_IRQ);
+               set_irq_handler(ec->irq, handle_level_irq);
                set_irq_flags(ec->irq, IRQF_VALID);
        }
 
@@ -1146,9 +1145,11 @@ static void ecard_drv_shutdown(struct device *dev)
        struct ecard_driver *drv = ECARD_DRV(dev->driver);
        struct ecard_request req;
 
-       if (drv->shutdown)
-               drv->shutdown(ec);
-       ecard_release(ec);
+       if (dev->driver) {
+               if (drv->shutdown)
+                       drv->shutdown(ec);
+               ecard_release(ec);
+       }
 
        /*
         * If this card has a loader, call the reset handler.
@@ -1163,9 +1164,6 @@ static void ecard_drv_shutdown(struct device *dev)
 int ecard_register_driver(struct ecard_driver *drv)
 {
        drv->drv.bus = &ecard_bus_type;
-       drv->drv.probe = ecard_drv_probe;
-       drv->drv.remove = ecard_drv_remove;
-       drv->drv.shutdown = ecard_drv_shutdown;
 
        return driver_register(&drv->drv);
 }
@@ -1194,6 +1192,9 @@ struct bus_type ecard_bus_type = {
        .name           = "ecard",
        .dev_attrs      = ecard_dev_attrs,
        .match          = ecard_match,
+       .probe          = ecard_drv_probe,
+       .remove         = ecard_drv_remove,
+       .shutdown       = ecard_drv_shutdown,
 };
 
 static int ecard_bus_init(void)