]> err.no Git - linux-2.6/blobdiff - drivers/isdn/hisax/avma1_cs.c
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/sparc-2.6
[linux-2.6] / drivers / isdn / hisax / avma1_cs.c
index ff6b0e185bc4478deb2b65e402230c961767278e..fc6cc2c065b807ac72c44992bb885a1d92e6ec0d 100644 (file)
@@ -14,7 +14,6 @@
 
 #include <linux/kernel.h>
 #include <linux/init.h>
-#include <linux/sched.h>
 #include <linux/ptrace.h>
 #include <linux/slab.h>
 #include <linux/string.h>
@@ -67,7 +66,7 @@ module_param(isdnprot, int, 0);
    handler.
 */
 
-static void avma1cs_config(struct pcmcia_device *link);
+static int avma1cs_config(struct pcmcia_device *link);
 static void avma1cs_release(struct pcmcia_device *link);
 
 /*
@@ -116,18 +115,17 @@ typedef struct local_info_t {
     
 ======================================================================*/
 
-static int avma1cs_attach(struct pcmcia_device *p_dev)
+static int avma1cs_probe(struct pcmcia_device *p_dev)
 {
     local_info_t *local;
 
     DEBUG(0, "avma1cs_attach()\n");
 
     /* Allocate space for private device-specific data */
-    local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
+    local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
     if (!local)
        return -ENOMEM;
 
-    memset(local, 0, sizeof(local_info_t));
     p_dev->priv = local;
 
     /* The io structure describes IO port mapping */
@@ -149,10 +147,7 @@ static int avma1cs_attach(struct pcmcia_device *p_dev)
     p_dev->conf.ConfigIndex = 1;
     p_dev->conf.Present = PRESENT_OPTION;
 
-    p_dev->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
-    avma1cs_config(p_dev);
-
-    return 0;
+    return avma1cs_config(p_dev);
 } /* avma1cs_attach */
 
 /*======================================================================
@@ -166,12 +161,9 @@ static int avma1cs_attach(struct pcmcia_device *p_dev)
 
 static void avma1cs_detach(struct pcmcia_device *link)
 {
-    DEBUG(0, "avma1cs_detach(0x%p)\n", link);
-
-    if (link->state & DEV_CONFIG)
-           avma1cs_release(link);
-
-    kfree(link->priv);
+       DEBUG(0, "avma1cs_detach(0x%p)\n", link);
+       avma1cs_release(link);
+       kfree(link->priv);
 } /* avma1cs_detach */
 
 /*======================================================================
@@ -206,7 +198,7 @@ static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple,
     return get_tuple(handle, tuple, parse);
 }
 
-static void avma1cs_config(struct pcmcia_device *link)
+static int avma1cs_config(struct pcmcia_device *link)
 {
     tuple_t tuple;
     cisparse_t parse;
@@ -222,45 +214,11 @@ static void avma1cs_config(struct pcmcia_device *link)
 
     DEBUG(0, "avma1cs_config(0x%p)\n", link);
 
-    /*
-       This reads the card's CONFIG tuple to find its configuration
-       registers.
-    */
-    do {
-       tuple.DesiredTuple = CISTPL_CONFIG;
-       i = pcmcia_get_first_tuple(link, &tuple);
-       if (i != CS_SUCCESS) break;
-       tuple.TupleData = buf;
-       tuple.TupleDataMax = 64;
-       tuple.TupleOffset = 0;
-       i = pcmcia_get_tuple_data(link, &tuple);
-       if (i != CS_SUCCESS) break;
-       i = pcmcia_parse_tuple(link, &tuple, &parse);
-       if (i != CS_SUCCESS) break;
-       link->conf.ConfigBase = parse.config.base;
-    } while (0);
-    if (i != CS_SUCCESS) {
-       cs_error(link, ParseTuple, i);
-       link->state &= ~DEV_CONFIG_PENDING;
-       return;
-    }
-    
-    /* Configure card */
-    link->state |= DEV_CONFIG;
-
     do {
-
-       tuple.Attributes = 0;
-       tuple.TupleData = buf;
-       tuple.TupleDataMax = 254;
-       tuple.TupleOffset = 0;
-       tuple.DesiredTuple = CISTPL_VERS_1;
-
        devname[0] = 0;
-       if( !first_tuple(link, &tuple, &parse) && parse.version_1.ns > 1 ) {
-           strlcpy(devname,parse.version_1.str + parse.version_1.ofs[1], 
-                       sizeof(devname));
-       }
+       if (link->prod_id[1])
+               strlcpy(devname, link->prod_id[1], sizeof(devname));
+
        /*
          * find IO port
          */
@@ -320,12 +278,11 @@ found_port:
     dev->node.major = 45;
     dev->node.minor = 0;
     link->dev_node = &dev->node;
-    
-    link->state &= ~DEV_CONFIG_PENDING;
+
     /* If any step failed, release any partially configured state */
     if (i != 0) {
        avma1cs_release(link);
-       return;
+       return -ENODEV;
     }
 
     printk(KERN_NOTICE "avma1_cs: checking at i/o %#x, irq %d\n",
@@ -340,10 +297,11 @@ found_port:
     if (i < 0) {
        printk(KERN_ERR "avma1_cs: failed to initialize AVM A1 PCMCIA %d at i/o %#x\n", i, link->io.BasePort1);
        avma1cs_release(link);
-       return;
+       return -ENODEV;
     }
     dev->node.minor = i;
 
+    return 0;
 } /* avma1cs_config */
 
 /*======================================================================
@@ -379,7 +337,7 @@ static struct pcmcia_driver avma1cs_driver = {
        .drv            = {
                .name   = "avma1_cs",
        },
-       .probe          = avma1cs_attach,
+       .probe          = avma1cs_probe,
        .remove         = avma1cs_detach,
        .id_table       = avma1cs_ids,
 };