Merge branch 'linus' of master.kernel.org:/pub/scm/linux/kernel/git/perex/alsa
[sfrench/cifs-2.6.git] / drivers / pcmcia / omap_cf.c
index 2c23d758439982be6eb765667e586596a44dea08..76f7cbc62a8b95311ccc52ad610b45fecb39ff79 100644 (file)
@@ -11,7 +11,6 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
 #include <linux/platform_device.h>
 #include <linux/errno.h>
 #include <linux/init.h>
@@ -67,6 +66,7 @@ struct omap_cf_socket {
        struct platform_device  *pdev;
        unsigned long           phys_cf;
        u_int                   irq;
+       struct resource         iomem;
 };
 
 #define        POLL_INTERVAL           (2 * HZ)
@@ -101,7 +101,7 @@ static void omap_cf_timer(unsigned long _cf)
  * claim the card's IRQ.  It may also detect some card insertions, but
  * not removals; it can't always eliminate timer irqs.
  */
-static irqreturn_t omap_cf_irq(int irq, void *_cf, struct pt_regs *r)
+static irqreturn_t omap_cf_irq(int irq, void *_cf)
 {
        omap_cf_timer((unsigned long)_cf);
        return IRQ_HANDLED;
@@ -112,16 +112,14 @@ static int omap_cf_get_status(struct pcmcia_socket *s, u_int *sp)
        if (!sp)
                return -EINVAL;
 
-       /* FIXME power management should probably be board-specific:
-        *  - 3VCARD vs XVCARD (OSK only handles 3VCARD)
-        *  - POWERON (switched on/off by set_socket)
-        */
+       /* NOTE CF is always 3VCARD */
        if (omap_cf_present()) {
                struct omap_cf_socket   *cf;
 
                *sp = SS_READY | SS_DETECT | SS_POWERON | SS_3VCARD;
                cf = container_of(s, struct omap_cf_socket, socket);
-               s->irq.AssignedIRQ = cf->irq;
+               s->irq.AssignedIRQ = 0;
+               s->pci_irq = cf->irq;
        } else
                *sp = 0;
        return 0;
@@ -132,7 +130,7 @@ omap_cf_set_socket(struct pcmcia_socket *sock, struct socket_state_t *s)
 {
        u16             control;
 
-       /* FIXME some non-OSK boards will support power switching */
+       /* REVISIT some non-OSK boards may support power switching */
        switch (s->Vcc) {
        case 0:
        case 33:
@@ -204,7 +202,7 @@ static struct pccard_operations omap_cf_ops = {
  * "what chipselect is used".  Boards could want more.
  */
 
-static int __init omap_cf_probe(struct device *dev)
+static int __devinit omap_cf_probe(struct device *dev)
 {
        unsigned                seg;
        struct omap_cf_socket   *cf;
@@ -221,7 +219,7 @@ static int __init omap_cf_probe(struct device *dev)
        if (irq < 0)
                return -EINVAL;
 
-       cf = kcalloc(1, sizeof *cf, GFP_KERNEL);
+       cf = kzalloc(sizeof *cf, GFP_KERNEL);
        if (!cf)
                return -ENOMEM;
        init_timer(&cf->timer);
@@ -232,7 +230,7 @@ static int __init omap_cf_probe(struct device *dev)
        dev_set_drvdata(dev, cf);
 
        /* this primarily just shuts up irq handling noise */
-       status = request_irq(irq, omap_cf_irq, SA_SHIRQ,
+       status = request_irq(irq, omap_cf_irq, IRQF_SHARED,
                        driver_name, cf);
        if (status < 0)
                goto fail0;
@@ -253,6 +251,9 @@ static int __init omap_cf_probe(struct device *dev)
        default:
                goto  fail1;
        }
+       cf->iomem.start = cf->phys_cf;
+       cf->iomem.end = cf->iomem.end + SZ_8K - 1;
+       cf->iomem.flags = IORESOURCE_MEM;
 
        /* pcmcia layer only remaps "real" memory */
        cf->socket.io_offset = (unsigned long)
@@ -296,6 +297,7 @@ static int __init omap_cf_probe(struct device *dev)
        cf->socket.features = SS_CAP_PCCARD | SS_CAP_STATIC_MAP
                                | SS_CAP_MEM_ALIGN;
        cf->socket.map_size = SZ_2K;
+       cf->socket.io[0].res = &cf->iomem;
 
        status = pcmcia_register_socket(&cf->socket);
        if (status < 0)
@@ -306,9 +308,10 @@ static int __init omap_cf_probe(struct device *dev)
        return 0;
 
 fail2:
-       iounmap((void __iomem *) cf->socket.io_offset);
        release_mem_region(cf->phys_cf, SZ_8K);
 fail1:
+       if (cf->socket.io_offset)
+               iounmap((void __iomem *) cf->socket.io_offset);
        free_irq(irq, cf);
 fail0:
        kfree(cf);
@@ -334,15 +337,15 @@ static struct device_driver omap_cf_driver = {
        .bus            = &platform_bus_type,
        .probe          = omap_cf_probe,
        .remove         = __devexit_p(omap_cf_remove),
-       .suspend        = pcmcia_socket_dev_suspend,
-       .resume         = pcmcia_socket_dev_resume,
+       .suspend        = pcmcia_socket_dev_suspend,
+       .resume         = pcmcia_socket_dev_resume,
 };
 
 static int __init omap_cf_init(void)
 {
        if (cpu_is_omap16xx())
-               driver_register(&omap_cf_driver);
-       return 0;
+               return driver_register(&omap_cf_driver);
+       return -ENODEV;
 }
 
 static void __exit omap_cf_exit(void)