]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - drivers/isdn/hardware/avm/avm_cs.c
[PATCH] pcmcia: embed dev_link_t into struct pcmcia_device
[mirror_ubuntu-artful-kernel.git] / drivers / isdn / hardware / avm / avm_cs.c
index 2a2b03ff096b6a3a5b56beddb997ac515117f932..3b7461ece50568b7072220d4031756a5a5489c38 100644 (file)
@@ -101,50 +101,37 @@ typedef struct local_info_t {
 
 static int avmcs_attach(struct pcmcia_device *p_dev)
 {
-    dev_link_t *link;
     local_info_t *local;
 
-    /* Initialize the dev_link_t structure */
-    link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL);
-    if (!link)
-        goto err;
-    memset(link, 0, sizeof(struct dev_link_t));
-
     /* The io structure describes IO port mapping */
-    link->io.NumPorts1 = 16;
-    link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
-    link->io.NumPorts2 = 0;
+    p_dev->io.NumPorts1 = 16;
+    p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
+    p_dev->io.NumPorts2 = 0;
 
     /* Interrupt setup */
-    link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
-    link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED;
+    p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
+    p_dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED;
+
+    p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID;
 
-    link->irq.IRQInfo1 = IRQ_LEVEL_ID;
-    
     /* General socket configuration */
-    link->conf.Attributes = CONF_ENABLE_IRQ;
-    link->conf.Vcc = 50;
-    link->conf.IntType = INT_MEMORY_AND_IO;
-    link->conf.ConfigIndex = 1;
-    link->conf.Present = PRESENT_OPTION;
+    p_dev->conf.Attributes = CONF_ENABLE_IRQ;
+    p_dev->conf.IntType = INT_MEMORY_AND_IO;
+    p_dev->conf.ConfigIndex = 1;
+    p_dev->conf.Present = PRESENT_OPTION;
 
     /* Allocate space for private device-specific data */
     local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
     if (!local)
-        goto err_kfree;
+        goto err;
     memset(local, 0, sizeof(local_info_t));
-    link->priv = local;
-
-    link->handle = p_dev;
-    p_dev->instance = link;
+    p_dev->priv = local;
 
-    link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
-    avmcs_config(link);
+    p_dev->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
+    avmcs_config(p_dev);
 
     return 0;
 
- err_kfree:
-    kfree(link);
  err:
     return -EINVAL;
 } /* avmcs_attach */
@@ -166,7 +153,6 @@ static void avmcs_detach(struct pcmcia_device *p_dev)
        avmcs_release(link);
 
     kfree(link->priv);
-    kfree(link);
 } /* avmcs_detach */
 
 /*======================================================================
@@ -284,25 +270,25 @@ found_port:
            cs_error(link->handle, RequestIO, i);
            break;
        }
-       
+
        /*
         * allocate an interrupt line
         */
        i = pcmcia_request_irq(link->handle, &link->irq);
        if (i != CS_SUCCESS) {
            cs_error(link->handle, RequestIRQ, i);
-           pcmcia_release_io(link->handle, &link->io);
+           /* undo */
+           pcmcia_disable_device(link->handle);
            break;
        }
-       
+
        /*
          * configure the PCMCIA socket
          */
        i = pcmcia_request_configuration(link->handle, &link->conf);
        if (i != CS_SUCCESS) {
            cs_error(link->handle, RequestConfiguration, i);
-           pcmcia_release_io(link->handle, &link->io);
-           pcmcia_release_irq(link->handle, &link->irq);
+           pcmcia_disable_device(link->handle);
            break;
        }
 
@@ -331,7 +317,7 @@ found_port:
 
     dev->node.major = 64;
     dev->node.minor = 0;
-    link->dev = &dev->node;
+    link->dev_node = &dev->node;
     
     link->state &= ~DEV_CONFIG_PENDING;
     /* If any step failed, release any partially configured state */
@@ -367,54 +353,10 @@ found_port:
 
 static void avmcs_release(dev_link_t *link)
 {
-    b1pcmcia_delcard(link->io.BasePort1, link->irq.AssignedIRQ);
-
-    /* Unlink the device chain */
-    link->dev = NULL;
-    
-    /* Don't bother checking to see if these succeed or not */
-    pcmcia_release_configuration(link->handle);
-    pcmcia_release_io(link->handle, &link->io);
-    pcmcia_release_irq(link->handle, &link->irq);
-    link->state &= ~DEV_CONFIG;
+       b1pcmcia_delcard(link->io.BasePort1, link->irq.AssignedIRQ);
+       pcmcia_disable_device(link->handle);
 } /* avmcs_release */
 
-static int avmcs_suspend(struct pcmcia_device *dev)
-{
-       dev_link_t *link = dev_to_instance(dev);
-
-       link->state |= DEV_SUSPEND;
-       if (link->state & DEV_CONFIG)
-               pcmcia_release_configuration(link->handle);
-
-       return 0;
-}
-
-static int avmcs_resume(struct pcmcia_device *dev)
-{
-       dev_link_t *link = dev_to_instance(dev);
-
-       link->state &= ~DEV_SUSPEND;
-       if (link->state & DEV_CONFIG)
-               pcmcia_request_configuration(link->handle, &link->conf);
-
-       return 0;
-}
-
-/*======================================================================
-
-    The card status event handler.  Mostly, this schedules other
-    stuff to run after an event is received.  A CARD_REMOVAL event
-    also sets some flags to discourage the net drivers from trying
-    to talk to the card any more.
-
-    When a CARD_REMOVAL event is received, we immediately set a flag
-    to block future accesses to this device.  All the functions that
-    actually access the device should check this flag to make sure
-    the card is still present.
-    
-======================================================================*/
-
 
 static struct pcmcia_device_id avmcs_ids[] = {
        PCMCIA_DEVICE_PROD_ID12("AVM", "ISDN-Controller B1", 0x95d42008, 0x845dc335),
@@ -432,8 +374,6 @@ static struct pcmcia_driver avmcs_driver = {
        .probe = avmcs_attach,
        .remove = avmcs_detach,
        .id_table = avmcs_ids,
-       .suspend= avmcs_suspend,
-       .resume = avmcs_resume,
 };
 
 static int __init avmcs_init(void)