arm: tegra: fb: Apply new mode even if its current
[linux-2.6.git] / drivers / bluetooth / btuart_cs.c
index 39cca28..526b618 100644 (file)
@@ -41,8 +41,6 @@
 #include <asm/system.h>
 #include <asm/io.h>
 
-#include <pcmcia/cs_types.h>
-#include <pcmcia/cs.h>
 #include <pcmcia/cistpl.h>
 #include <pcmcia/ciscode.h>
 #include <pcmcia/ds.h>
@@ -67,7 +65,6 @@ MODULE_LICENSE("GPL");
 
 typedef struct btuart_info_t {
        struct pcmcia_device *p_dev;
-       dev_node_t node;
 
        struct hci_dev *hdev;
 
@@ -144,7 +141,7 @@ static void btuart_write_wakeup(btuart_info_t *info)
        }
 
        do {
-               register unsigned int iobase = info->p_dev->io.BasePort1;
+               register unsigned int iobase = info->p_dev->resource[0]->start;
                register struct sk_buff *skb;
                register int len;
 
@@ -185,7 +182,7 @@ static void btuart_receive(btuart_info_t *info)
                return;
        }
 
-       iobase = info->p_dev->io.BasePort1;
+       iobase = info->p_dev->resource[0]->start;
 
        do {
                info->hdev->stat.byte_rx++;
@@ -293,15 +290,19 @@ static irqreturn_t btuart_interrupt(int irq, void *dev_inst)
        unsigned int iobase;
        int boguscount = 0;
        int iir, lsr;
+       irqreturn_t r = IRQ_NONE;
 
-       BUG_ON(!info->hdev);
+       if (!info || !info->hdev)
+               /* our irq handler is shared */
+               return IRQ_NONE;
 
-       iobase = info->p_dev->io.BasePort1;
+       iobase = info->p_dev->resource[0]->start;
 
        spin_lock(&(info->lock));
 
        iir = inb(iobase + UART_IIR) & UART_IIR_ID;
        while (iir) {
+               r = IRQ_HANDLED;
 
                /* Clear interrupt */
                lsr = inb(iobase + UART_LSR);
@@ -335,7 +336,7 @@ static irqreturn_t btuart_interrupt(int irq, void *dev_inst)
 
        spin_unlock(&(info->lock));
 
-       return IRQ_HANDLED;
+       return r;
 }
 
 
@@ -352,7 +353,7 @@ static void btuart_change_speed(btuart_info_t *info, unsigned int speed)
                return;
        }
 
-       iobase = info->p_dev->io.BasePort1;
+       iobase = info->p_dev->resource[0]->start;
 
        spin_lock_irqsave(&(info->lock), flags);
 
@@ -476,7 +477,7 @@ static int btuart_hci_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned lon
 static int btuart_open(btuart_info_t *info)
 {
        unsigned long flags;
-       unsigned int iobase = info->p_dev->io.BasePort1;
+       unsigned int iobase = info->p_dev->resource[0]->start;
        struct hci_dev *hdev;
 
        spin_lock_init(&(info->lock));
@@ -496,7 +497,7 @@ static int btuart_open(btuart_info_t *info)
 
        info->hdev = hdev;
 
-       hdev->type = HCI_PCCARD;
+       hdev->bus = HCI_PCCARD;
        hdev->driver_data = info;
        SET_HCIDEV_DEV(hdev, &info->p_dev->dev);
 
@@ -546,7 +547,7 @@ static int btuart_open(btuart_info_t *info)
 static int btuart_close(btuart_info_t *info)
 {
        unsigned long flags;
-       unsigned int iobase = info->p_dev->io.BasePort1;
+       unsigned int iobase = info->p_dev->resource[0]->start;
        struct hci_dev *hdev = info->hdev;
 
        if (!hdev)
@@ -584,16 +585,8 @@ static int btuart_probe(struct pcmcia_device *link)
        info->p_dev = link;
        link->priv = info;
 
-       link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
-       link->io.NumPorts1 = 8;
-       link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
-       link->irq.IRQInfo1 = IRQ_LEVEL_ID;
-
-       link->irq.Handler = btuart_interrupt;
-       link->irq.Instance = info;
-
-       link->conf.Attributes = CONF_ENABLE_IRQ;
-       link->conf.IntType = INT_MEMORY_AND_IO;
+       link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_VPP |
+               CONF_AUTO_SET_IO;
 
        return btuart_config(link);
 }
@@ -607,41 +600,41 @@ static void btuart_detach(struct pcmcia_device *link)
        kfree(info);
 }
 
-static int btuart_check_config(struct pcmcia_device *p_dev,
-                              cistpl_cftable_entry_t *cf,
-                              void *priv_data)
+static int btuart_check_config(struct pcmcia_device *p_dev, void *priv_data)
 {
-       unsigned long try = (unsigned long) priv_data;
-
-       if (cf->vpp1.present & (1 << CISTPL_POWER_VNOM))
-               p_dev->conf.Vpp = cf->vpp1.param[CISTPL_POWER_VNOM] / 10000;
-       if ((cf->io.nwin > 0) && (cf->io.win[0].len == 8) &&
-           (cf->io.win[0].base != 0)) {
-               p_dev->conf.ConfigIndex = cf->index;
-               p_dev->io.BasePort1 = cf->io.win[0].base;
-               p_dev->io.IOAddrLines = (try == 0) ? 16 :
-                       cf->io.flags & CISTPL_IO_LINES_MASK;
-               if (!pcmcia_request_io(p_dev, &p_dev->io))
-                       return 0;
-       }
-       return -ENODEV;
+       int *try = priv_data;
+
+       if (try == 0)
+               p_dev->io_lines = 16;
+
+       if ((p_dev->resource[0]->end != 8) || (p_dev->resource[0]->start == 0))
+               return -EINVAL;
+
+       p_dev->resource[0]->end = 8;
+       p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
+       p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
+
+       return pcmcia_request_io(p_dev);
 }
 
 static int btuart_check_config_notpicky(struct pcmcia_device *p_dev,
-                                       cistpl_cftable_entry_t *cf,
                                        void *priv_data)
 {
        static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };
        int j;
 
-       if ((cf->io.nwin > 0) && ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) {
-               p_dev->conf.ConfigIndex = cf->index;
-               for (j = 0; j < 5; j++) {
-                       p_dev->io.BasePort1 = base[j];
-                       p_dev->io.IOAddrLines = base[j] ? 16 : 3;
-                       if (!pcmcia_request_io(p_dev, &p_dev->io))
-                               return 0;
-               }
+       if (p_dev->io_lines > 3)
+               return -ENODEV;
+
+       p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
+       p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
+       p_dev->resource[0]->end = 8;
+
+       for (j = 0; j < 5; j++) {
+               p_dev->resource[0]->start = base[j];
+               p_dev->io_lines = base[j] ? 16 : 3;
+               if (!pcmcia_request_io(p_dev))
+                       return 0;
        }
        return -ENODEV;
 }
@@ -650,13 +643,12 @@ static int btuart_config(struct pcmcia_device *link)
 {
        btuart_info_t *info = link->priv;
        int i;
-       unsigned long try;
+       int try;
 
        /* First pass: look for a config entry that looks normal.
           Two tries: without IO aliases, then with aliases */
        for (try = 0; try < 2; try++)
-               if (!pcmcia_loop_config(link, btuart_check_config,
-                                       (void *) try))
+               if (!pcmcia_loop_config(link, btuart_check_config, &try))
                        goto found_port;
 
        /* Second pass: try to find an entry that isn't picky about
@@ -666,28 +658,20 @@ static int btuart_config(struct pcmcia_device *link)
                goto found_port;
 
        BT_ERR("No usable port range found");
-       cs_error(link, RequestIO, -ENODEV);
        goto failed;
 
 found_port:
-       i = pcmcia_request_irq(link, &link->irq);
-       if (i != CS_SUCCESS) {
-               cs_error(link, RequestIRQ, i);
-               link->irq.AssignedIRQ = 0;
-       }
+       i = pcmcia_request_irq(link, btuart_interrupt);
+       if (i != 0)
+               goto failed;
 
-       i = pcmcia_request_configuration(link, &link->conf);
-       if (i != CS_SUCCESS) {
-               cs_error(link, RequestConfiguration, i);
+       i = pcmcia_enable_device(link);
+       if (i != 0)
                goto failed;
-       }
 
        if (btuart_open(info) != 0)
                goto failed;
 
-       strcpy(info->node.dev_name, info->hdev->name);
-       link->dev_node = &info->node;
-
        return 0;
 
 failed:
@@ -705,7 +689,7 @@ static void btuart_release(struct pcmcia_device *link)
        pcmcia_disable_device(link);
 }
 
-static struct pcmcia_device_id btuart_ids[] = {
+static const struct pcmcia_device_id btuart_ids[] = {
        /* don't use this driver. Use serial_cs + hci_uart instead */
        PCMCIA_DEVICE_NULL
 };
@@ -713,9 +697,7 @@ MODULE_DEVICE_TABLE(pcmcia, btuart_ids);
 
 static struct pcmcia_driver btuart_driver = {
        .owner          = THIS_MODULE,
-       .drv            = {
-               .name   = "btuart_cs",
-       },
+       .name           = "btuart_cs",
        .probe          = btuart_probe,
        .remove         = btuart_detach,
        .id_table       = btuart_ids,