drivers/net: Trim trailing whitespace
[linux-2.6.git] / drivers / bluetooth / btuart_cs.c
index cfe1d74..746ccca 100644 (file)
@@ -20,7 +20,6 @@
  *
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 
 #include <linux/kernel.h>
@@ -84,8 +83,8 @@ typedef struct btuart_info_t {
 } btuart_info_t;
 
 
-static void btuart_config(dev_link_t *link);
-static void btuart_release(dev_link_t *link);
+static int btuart_config(struct pcmcia_device *link);
+static void btuart_release(struct pcmcia_device *link);
 
 static void btuart_detach(struct pcmcia_device *p_dev);
 
@@ -152,7 +151,7 @@ static void btuart_write_wakeup(btuart_info_t *info)
 
                clear_bit(XMIT_WAKEUP, &(info->tx_state));
 
-               if (!(info->p_dev->state & DEV_PRESENT))
+               if (!pcmcia_dev_present(info->p_dev))
                        return;
 
                if (!(skb = skb_dequeue(&(info->txq))))
@@ -503,6 +502,7 @@ static int btuart_open(btuart_info_t *info)
 
        hdev->type = HCI_PCCARD;
        hdev->driver_data = info;
+       SET_HCIDEV_DEV(hdev, &info->p_dev->dev);
 
        hdev->open     = btuart_hci_open;
        hdev->close    = btuart_hci_close;
@@ -576,17 +576,16 @@ static int btuart_close(btuart_info_t *info)
        return 0;
 }
 
-static int btuart_attach(struct pcmcia_device *p_dev)
+static int btuart_probe(struct pcmcia_device *link)
 {
        btuart_info_t *info;
-       dev_link_t *link = dev_to_instance(p_dev);
 
        /* Create new info device */
        info = kzalloc(sizeof(*info), GFP_KERNEL);
        if (!info)
                return -ENOMEM;
 
-       info->p_dev = p_dev;
+       info->p_dev = link;
        link->priv = info;
 
        link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
@@ -600,25 +599,19 @@ static int btuart_attach(struct pcmcia_device *p_dev)
        link->conf.Attributes = CONF_ENABLE_IRQ;
        link->conf.IntType = INT_MEMORY_AND_IO;
 
-       link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
-       btuart_config(link);
-
-       return 0;
+       return btuart_config(link);
 }
 
 
-static void btuart_detach(struct pcmcia_device *p_dev)
+static void btuart_detach(struct pcmcia_device *link)
 {
-       dev_link_t *link = dev_to_instance(p_dev);
        btuart_info_t *info = link->priv;
 
-       if (link->state & DEV_CONFIG)
-               btuart_release(link);
-
+       btuart_release(link);
        kfree(info);
 }
 
-static int get_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
+static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse)
 {
        int i;
 
@@ -629,24 +622,23 @@ static int get_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
        return pcmcia_parse_tuple(handle, tuple, parse);
 }
 
-static int first_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
+static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse)
 {
        if (pcmcia_get_first_tuple(handle, tuple) != CS_SUCCESS)
                return CS_NO_MORE_ITEMS;
        return get_tuple(handle, tuple, parse);
 }
 
-static int next_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
+static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse)
 {
        if (pcmcia_get_next_tuple(handle, tuple) != CS_SUCCESS)
                return CS_NO_MORE_ITEMS;
        return get_tuple(handle, tuple, parse);
 }
 
-static void btuart_config(dev_link_t *link)
+static int btuart_config(struct pcmcia_device *link)
 {
        static kio_addr_t base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };
-       client_handle_t handle = link->handle;
        btuart_info_t *info = link->priv;
        tuple_t tuple;
        u_short buf[256];
@@ -661,7 +653,7 @@ static void btuart_config(dev_link_t *link)
 
        /* Get configuration register information */
        tuple.DesiredTuple = CISTPL_CONFIG;
-       last_ret = first_tuple(handle, &tuple, &parse);
+       last_ret = first_tuple(link, &tuple, &parse);
        if (last_ret != CS_SUCCESS) {
                last_fn = ParseTuple;
                goto cs_failed;
@@ -669,9 +661,6 @@ static void btuart_config(dev_link_t *link)
        link->conf.ConfigBase = parse.config.base;
        link->conf.Present = parse.config.rmask[0];
 
-       /* Configure card */
-       link->state |= DEV_CONFIG;
-
        /* First pass: look for a config entry that looks normal. */
        tuple.TupleData = (cisdata_t *) buf;
        tuple.TupleOffset = 0;
@@ -680,7 +669,7 @@ static void btuart_config(dev_link_t *link)
        tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
        /* Two tries: without IO aliases, then with aliases */
        for (try = 0; try < 2; try++) {
-               i = first_tuple(handle, &tuple, &parse);
+               i = first_tuple(link, &tuple, &parse);
                while (i != CS_NO_MORE_ITEMS) {
                        if (i != CS_SUCCESS)
                                goto next_entry;
@@ -690,19 +679,19 @@ static void btuart_config(dev_link_t *link)
                                link->conf.ConfigIndex = cf->index;
                                link->io.BasePort1 = cf->io.win[0].base;
                                link->io.IOAddrLines = (try == 0) ? 16 : cf->io.flags & CISTPL_IO_LINES_MASK;
-                               i = pcmcia_request_io(link->handle, &link->io);
+                               i = pcmcia_request_io(link, &link->io);
                                if (i == CS_SUCCESS)
                                        goto found_port;
                        }
 next_entry:
-                       i = next_tuple(handle, &tuple, &parse);
+                       i = next_tuple(link, &tuple, &parse);
                }
        }
 
        /* Second pass: try to find an entry that isn't picky about
           its base address, then try to grab any standard serial port
           address, and finally try to get any free port. */
-       i = first_tuple(handle, &tuple, &parse);
+       i = first_tuple(link, &tuple, &parse);
        while (i != CS_NO_MORE_ITEMS) {
                if ((i == CS_SUCCESS) && (cf->io.nwin > 0)
                    && ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) {
@@ -710,30 +699,30 @@ next_entry:
                        for (j = 0; j < 5; j++) {
                                link->io.BasePort1 = base[j];
                                link->io.IOAddrLines = base[j] ? 16 : 3;
-                               i = pcmcia_request_io(link->handle, &link->io);
+                               i = pcmcia_request_io(link, &link->io);
                                if (i == CS_SUCCESS)
                                        goto found_port;
                        }
                }
-               i = next_tuple(handle, &tuple, &parse);
+               i = next_tuple(link, &tuple, &parse);
        }
 
 found_port:
        if (i != CS_SUCCESS) {
                BT_ERR("No usable port range found");
-               cs_error(link->handle, RequestIO, i);
+               cs_error(link, RequestIO, i);
                goto failed;
        }
 
-       i = pcmcia_request_irq(link->handle, &link->irq);
+       i = pcmcia_request_irq(link, &link->irq);
        if (i != CS_SUCCESS) {
-               cs_error(link->handle, RequestIRQ, i);
+               cs_error(link, RequestIRQ, i);
                link->irq.AssignedIRQ = 0;
        }
 
-       i = pcmcia_request_configuration(link->handle, &link->conf);
+       i = pcmcia_request_configuration(link, &link->conf);
        if (i != CS_SUCCESS) {
-               cs_error(link->handle, RequestConfiguration, i);
+               cs_error(link, RequestConfiguration, i);
                goto failed;
        }
 
@@ -742,26 +731,25 @@ found_port:
 
        strcpy(info->node.dev_name, info->hdev->name);
        link->dev_node = &info->node;
-       link->state &= ~DEV_CONFIG_PENDING;
 
-       return;
+       return 0;
 
 cs_failed:
-       cs_error(link->handle, last_fn, last_ret);
+       cs_error(link, last_fn, last_ret);
 
 failed:
        btuart_release(link);
+       return -ENODEV;
 }
 
 
-static void btuart_release(dev_link_t *link)
+static void btuart_release(struct pcmcia_device *link)
 {
        btuart_info_t *info = link->priv;
 
-       if (link->state & DEV_PRESENT)
-               btuart_close(info);
+       btuart_close(info);
 
-       pcmcia_disable_device(link->handle);
+       pcmcia_disable_device(link);
 }
 
 static struct pcmcia_device_id btuart_ids[] = {
@@ -775,7 +763,7 @@ static struct pcmcia_driver btuart_driver = {
        .drv            = {
                .name   = "btuart_cs",
        },
-       .probe          = btuart_attach,
+       .probe          = btuart_probe,
        .remove         = btuart_detach,
        .id_table       = btuart_ids,
 };