]> err.no Git - linux-2.6/blobdiff - arch/arm/kernel/ecard.c
Merge branch 'for-2.6.26' of master.kernel.org:/pub/scm/linux/kernel/git/jwboyer...
[linux-2.6] / arch / arm / kernel / ecard.c
index f1c0fb974177803c0ec2510d79d4e9c72669164b..a53c0aba5c142b53295ca2563785bde904dc72b1 100644 (file)
 #include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/proc_fs.h>
+#include <linux/seq_file.h>
 #include <linux/device.h>
 #include <linux/init.h>
 #include <linux/mutex.h>
+#include <linux/kthread.h>
+#include <linux/io.h>
 
 #include <asm/dma.h>
 #include <asm/ecard.h>
 #include <asm/hardware.h>
-#include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/mmu_context.h>
 #include <asm/mach/irq.h>
 #include <asm/tlbflush.h>
 
+#include "ecard.h"
+
 #ifndef CONFIG_ARCH_RPC
 #define HAVE_EXPMASK
 #endif
@@ -123,7 +127,7 @@ static void ecard_task_reset(struct ecard_request *req)
 
        res = ec->slot_no == 8
                ? &ec->resource[ECARD_RES_MEMC]
-               : ec->type == ECARD_EASI
+               : ec->easi
                  ? &ec->resource[ECARD_RES_EASI]
                  : &ec->resource[ECARD_RES_IOCSYNC];
 
@@ -178,7 +182,7 @@ static void ecard_task_readbytes(struct ecard_request *req)
                        index += 1;
                }
        } else {
-               unsigned long base = (ec->type == ECARD_EASI
+               unsigned long base = (ec->easi
                         ? &ec->resource[ECARD_RES_EASI]
                         : &ec->resource[ECARD_RES_IOCSYNC])->start;
                void __iomem *pbase = (void __iomem *)base;
@@ -263,8 +267,6 @@ static int ecard_init_mm(void)
 static int
 ecard_task(void * unused)
 {
-       daemonize("kecardd");
-
        /*
         * Allocate a mm.  We're not a lazy-TLB kernel task since we need
         * to set page table entries where the user space would be.  Note
@@ -722,17 +724,14 @@ unsigned int __ecard_address(ecard_t *ec, card_type_t type, card_speed_t speed)
        return address;
 }
 
-static int ecard_prints(char *buffer, ecard_t *ec)
+static int ecard_prints(struct seq_file *m, ecard_t *ec)
 {
-       char *start = buffer;
-
-       buffer += sprintf(buffer, "  %d: %s ", ec->slot_no,
-                         ec->type == ECARD_EASI ? "EASI" : "    ");
+       seq_printf(m, "  %d: %s ", ec->slot_no, ec->easi ? "EASI" : "    ");
 
        if (ec->cid.id == 0) {
                struct in_chunk_dir incd;
 
-               buffer += sprintf(buffer, "[%04X:%04X] ",
+               seq_printf(m, "[%04X:%04X] ",
                        ec->cid.manufacturer, ec->cid.product);
 
                if (!ec->card_desc && ec->cid.cd &&
@@ -743,43 +742,43 @@ static int ecard_prints(char *buffer, ecard_t *ec)
                                strcpy((char *)ec->card_desc, incd.d.string);
                }
 
-               buffer += sprintf(buffer, "%s\n", ec->card_desc ? ec->card_desc : "*unknown*");
+               seq_printf(m, "%s\n", ec->card_desc ? ec->card_desc : "*unknown*");
        } else
-               buffer += sprintf(buffer, "Simple card %d\n", ec->cid.id);
+               seq_printf(m, "Simple card %d\n", ec->cid.id);
 
-       return buffer - start;
+       return 0;
 }
 
-static int get_ecard_dev_info(char *buf, char **start, off_t pos, int count)
+static int ecard_devices_proc_show(struct seq_file *m, void *v)
 {
        ecard_t *ec = cards;
-       off_t at = 0;
-       int len, cnt;
-
-       cnt = 0;
-       while (ec && count > cnt) {
-               len = ecard_prints(buf, ec);
-               at += len;
-               if (at >= pos) {
-                       if (!*start) {
-                               *start = buf + (pos - (at - len));
-                               cnt = at - pos;
-                       } else
-                               cnt += len;
-                       buf += len;
-               }
+
+       while (ec) {
+               ecard_prints(m, ec);
                ec = ec->next;
        }
-       return (count > cnt) ? cnt : count;
+       return 0;
 }
 
+static int ecard_devices_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, ecard_devices_proc_show, NULL);
+}
+
+static const struct file_operations bus_ecard_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = ecard_devices_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
 static struct proc_dir_entry *proc_bus_ecard_dir = NULL;
 
 static void ecard_proc_init(void)
 {
-       proc_bus_ecard_dir = proc_mkdir("ecard", proc_bus);
-       create_proc_info_entry("devices", 0, proc_bus_ecard_dir,
-               get_ecard_dev_info);
+       proc_bus_ecard_dir = proc_mkdir("bus/ecard", NULL);
+       proc_create("devices", 0, proc_bus_ecard_dir, &bus_ecard_proc_fops);
 }
 
 #define ec_set_resource(ec,nr,st,sz)                           \
@@ -814,7 +813,7 @@ static struct expansion_card *__init ecard_alloc_card(int type, int slot)
        }
 
        ec->slot_no = slot;
-       ec->type = type;
+       ec->easi = type == ECARD_EASI;
        ec->irq = NO_IRQ;
        ec->fiq = NO_IRQ;
        ec->dma = NO_DMA;
@@ -825,6 +824,7 @@ static struct expansion_card *__init ecard_alloc_card(int type, int slot)
        ec->dev.bus = &ecard_bus_type;
        ec->dev.dma_mask = &ec->dma_mask;
        ec->dma_mask = (u64)0xffffffff;
+       ec->dev.coherent_dma_mask = ec->dma_mask;
 
        if (slot < 4) {
                ec_set_resource(ec, ECARD_RES_MEMC,
@@ -907,7 +907,7 @@ static ssize_t ecard_show_device(struct device *dev, struct device_attribute *at
 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");
+       return sprintf(buf, "%s\n", ec->easi ? "EASI" : "IOC");
 }
 
 static struct device_attribute ecard_dev_attrs[] = {
@@ -956,6 +956,31 @@ void ecard_release_resources(struct expansion_card *ec)
 }
 EXPORT_SYMBOL(ecard_release_resources);
 
+void ecard_setirq(struct expansion_card *ec, const struct expansion_card_ops *ops, void *irq_data)
+{
+       ec->irq_data = irq_data;
+       barrier();
+       ec->ops = ops;
+}
+EXPORT_SYMBOL(ecard_setirq);
+
+void __iomem *ecardm_iomap(struct expansion_card *ec, unsigned int res,
+                          unsigned long offset, unsigned long maxsize)
+{
+       unsigned long start = ecard_resource_start(ec, res);
+       unsigned long end = ecard_resource_end(ec, res);
+
+       if (offset > (end - start))
+               return NULL;
+
+       start += offset;
+       if (maxsize && end - start > maxsize)
+               end = start + maxsize;
+       
+       return devm_ioremap(&ec->dev, start, end - start);
+}
+EXPORT_SYMBOL(ecardm_iomap);
+
 /*
  * Probe for an expansion card.
  *
@@ -1058,13 +1083,14 @@ ecard_probe(int slot, card_type_t type)
  */
 static int __init ecard_init(void)
 {
-       int slot, irqhw, ret;
-
-       ret = kernel_thread(ecard_task, NULL, CLONE_KERNEL);
-       if (ret < 0) {
-               printk(KERN_ERR "Ecard: unable to create kernel thread: %d\n",
-                      ret);
-               return ret;
+       struct task_struct *task;
+       int slot, irqhw;
+
+       task = kthread_run(ecard_task, NULL, "kecardd");
+       if (IS_ERR(task)) {
+               printk(KERN_ERR "Ecard: unable to create kernel thread: %ld\n",
+                      PTR_ERR(task));
+               return PTR_ERR(task);
        }
 
        printk("Probing expansion cards\n");
@@ -1130,6 +1156,14 @@ static int ecard_drv_remove(struct device *dev)
        drv->remove(ec);
        ecard_release(ec);
 
+       /*
+        * Restore the default operations.  We ensure that the
+        * ops are set before we change the data.
+        */
+       ec->ops = &ecard_default_ops;
+       barrier();
+       ec->irq_data = NULL;
+
        return 0;
 }