staging: comedi: quatech_daqp_cs: cleanup daqp_cs_attach()
authorH Hartley Sweeten <hartleys@visionengravers.com>
Fri, 25 Jan 2013 21:59:56 +0000 (14:59 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 30 Jan 2013 04:06:40 +0000 (23:06 -0500)
Absorb the code from daqp_cs_config() into this function and
properly return the error if the configuration fails.

Remove the dev_dbg() function trace messages.

Fix the kzalloc(). The preferred form for passing a size of a struct
is:

p = kzalloc(sizeof(*p), ...);

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/quatech_daqp_cs.c

index b2b755f031b1d2c311c91b8a2542d4209c44ae17..8eea8a9ca843cb96f9e20f5dece0615b5e66e679 100644 (file)
@@ -944,41 +944,12 @@ static int daqp_pcmcia_config_loop(struct pcmcia_device *p_dev, void *priv_data)
        return pcmcia_request_io(p_dev);
 }
 
-static void daqp_cs_config(struct pcmcia_device *link)
-{
-       int ret;
-
-       dev_dbg(&link->dev, "daqp_cs_config\n");
-
-       link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
-
-       ret = pcmcia_loop_config(link, daqp_pcmcia_config_loop, NULL);
-       if (ret) {
-               dev_warn(&link->dev, "no configuration found\n");
-               goto failed;
-       }
-
-       ret = pcmcia_request_irq(link, daqp_interrupt);
-       if (ret)
-               goto failed;
-
-       ret = pcmcia_enable_device(link);
-       if (ret)
-               goto failed;
-
-       return;
-
-failed:
-       pcmcia_disable_device(link);
-}
-
 static int daqp_cs_attach(struct pcmcia_device *link)
 {
        struct local_info_t *local;
+       int ret;
        int i;
 
-       dev_dbg(&link->dev, "daqp_cs_attach()\n");
-
        for (i = 0; i < MAX_DEV; i++)
                if (dev_table[i] == NULL)
                        break;
@@ -988,7 +959,7 @@ static int daqp_cs_attach(struct pcmcia_device *link)
        }
 
        /* Allocate space for private device-specific data */
-       local = kzalloc(sizeof(struct local_info_t), GFP_KERNEL);
+       local = kzalloc(sizeof(*local), GFP_KERNEL);
        if (!local)
                return -ENOMEM;
 
@@ -997,9 +968,27 @@ static int daqp_cs_attach(struct pcmcia_device *link)
        local->link = link;
        link->priv = local;
 
-       daqp_cs_config(link);
+       link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
+
+       ret = pcmcia_loop_config(link, daqp_pcmcia_config_loop, NULL);
+       if (ret) {
+               dev_warn(&link->dev, "no configuration found\n");
+               goto failed;
+       }
+
+       ret = pcmcia_request_irq(link, daqp_interrupt);
+       if (ret)
+               goto failed;
+
+       ret = pcmcia_enable_device(link);
+       if (ret)
+               goto failed;
 
        return 0;
+
+failed:
+       pcmcia_disable_device(link);
+       return ret;
 }
 
 static void daqp_cs_detach(struct pcmcia_device *link)