include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / sound / pcmcia / vx / vxpocket.c
index d7df59e..cfd1438 100644 (file)
@@ -19,9 +19,9 @@
  */
 
 
-#include <sound/driver.h>
 #include <linux/init.h>
 #include <linux/moduleparam.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include "vxpocket.h"
 #include <pcmcia/ciscode.h>
@@ -91,7 +91,7 @@ static int snd_vxpocket_dev_free(struct snd_device *device)
  * Only output levels can be modified
  */
 
-static DECLARE_TLV_DB_SCALE(db_scale_old_vol, -11350, 50, 0);
+static const DECLARE_TLV_DB_SCALE(db_scale_old_vol, -11350, 50, 0);
 
 static struct snd_vx_hardware vxpocket_hw = {
        .name = "VXPocket",
@@ -131,23 +131,26 @@ static struct snd_vx_hardware vxp440_hw = {
 /*
  * create vxpocket instance
  */
-static struct snd_vxpocket *snd_vxpocket_new(struct snd_card *card, int ibl,
-                                            struct pcmcia_device *link)
+static int snd_vxpocket_new(struct snd_card *card, int ibl,
+                           struct pcmcia_device *link,
+                           struct snd_vxpocket **chip_ret)
 {
        struct vx_core *chip;
        struct snd_vxpocket *vxp;
        static struct snd_device_ops ops = {
                .dev_free =     snd_vxpocket_dev_free,
        };
+       int err;
 
        chip = snd_vx_create(card, &vxpocket_hw, &snd_vxpocket_ops,
                             sizeof(struct snd_vxpocket) - sizeof(struct vx_core));
-       if (! chip)
-               return NULL;
+       if (!chip)
+               return -ENOMEM;
 
-       if (snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops) < 0) {
+       err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
+       if (err < 0) {
                kfree(chip);
-               return NULL;
+               return err;
        }
        chip->ibl.size = ibl;
 
@@ -159,18 +162,17 @@ static struct snd_vxpocket *snd_vxpocket_new(struct snd_card *card, int ibl,
        link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
        link->io.NumPorts1 = 16;
 
-       link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
+       link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
 
-       link->irq.IRQInfo1 = IRQ_LEVEL_ID;
        link->irq.Handler = &snd_vx_irq_handler;
-       link->irq.Instance = chip;
 
        link->conf.Attributes = CONF_ENABLE_IRQ;
        link->conf.IntType = INT_MEMORY_AND_IO;
        link->conf.ConfigIndex = 1;
        link->conf.Present = PRESENT_OPTION;
 
-       return vxp;
+       *chip_ret = vxp;
+       return 0;
 }
 
 
@@ -210,14 +212,11 @@ static int snd_vxpocket_assign_resources(struct vx_core *chip, int port, int irq
  * configuration callback
  */
 
-#define CS_CHECK(fn, ret) \
-do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
-
 static int vxpocket_config(struct pcmcia_device *link)
 {
        struct vx_core *chip = link->priv;
        struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip;
-       int last_fn, last_ret;
+       int ret;
 
        snd_printdd(KERN_DEBUG "vxpocket_config called\n");
 
@@ -232,11 +231,19 @@ static int vxpocket_config(struct pcmcia_device *link)
                strcpy(chip->card->driver, vxp440_hw.name);
        }
 
-       CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io));
-       CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
-       CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
+       ret = pcmcia_request_io(link, &link->io);
+       if (ret)
+               goto failed;
 
-       chip->dev = &handle_to_dev(link);
+       ret = pcmcia_request_irq(link, &link->irq);
+       if (ret)
+               goto failed;
+
+       ret = pcmcia_request_configuration(link, &link->conf);
+       if (ret)
+               goto failed;
+
+       chip->dev = &link->dev;
        snd_card_set_dev(chip->card, chip->dev);
 
        if (snd_vxpocket_assign_resources(chip, link->io.BasePort1, link->irq.AssignedIRQ) < 0)
@@ -245,8 +252,6 @@ static int vxpocket_config(struct pcmcia_device *link)
        link->dev_node = &vxp->node;
        return 0;
 
-cs_failed:
-       cs_error(link, last_fn, last_ret);
 failed:
        pcmcia_disable_device(link);
        return -ENODEV;
@@ -293,11 +298,11 @@ static int vxpocket_probe(struct pcmcia_device *p_dev)
 {
        struct snd_card *card;
        struct snd_vxpocket *vxp;
-       int i;
+       int i, err;
 
        /* find an empty slot from the card list */
        for (i = 0; i < SNDRV_CARDS; i++) {
-               if (! card_alloc & (1 << i))
+               if (!(card_alloc & (1 << i)))
                        break;
        }
        if (i >= SNDRV_CARDS) {
@@ -308,16 +313,16 @@ static int vxpocket_probe(struct pcmcia_device *p_dev)
                return -ENODEV; /* disabled explicitly */
 
        /* ok, create a card instance */
-       card = snd_card_new(index[i], id[i], THIS_MODULE, 0);
-       if (card == NULL) {
+       err = snd_card_create(index[i], id[i], THIS_MODULE, 0, &card);
+       if (err < 0) {
                snd_printk(KERN_ERR "vxpocket: cannot create a card instance\n");
-               return -ENOMEM;
+               return err;
        }
 
-       vxp = snd_vxpocket_new(card, ibl[i], p_dev);
-       if (! vxp) {
+       err = snd_vxpocket_new(card, ibl[i], p_dev, &vxp);
+       if (err < 0) {
                snd_card_free(card);
-               return -ENODEV;
+               return err;
        }
        card->private_data = vxp;