+ int err;
+ struct snd_card *card = chip->card;
+ struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip;
+
+ snd_printdd(KERN_DEBUG "vxpocket assign resources: port = 0x%x, irq = %d\n", port, irq);
+ vxp->port = port;
+
+ sprintf(card->shortname, "Digigram %s", card->driver);
+ sprintf(card->longname, "%s at 0x%x, irq %i",
+ card->shortname, port, irq);
+
+ chip->irq = irq;
+
+ if ((err = snd_vx_setup_firmware(chip)) < 0)
+ return err;
+
+ return 0;
+}
+
+
+/*
+ * 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;
+
+ snd_printdd(KERN_DEBUG "vxpocket_config called\n");
+
+ /* redefine hardware record according to the VERSION1 string */
+ if (!strcmp(link->prod_id[1], "VX-POCKET")) {
+ snd_printdd("VX-pocket is detected\n");
+ } else {
+ snd_printdd("VX-pocket 440 is detected\n");
+ /* overwrite the hardware information */
+ chip->hw = &vxp440_hw;
+ chip->type = vxp440_hw.type;
+ 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));
+
+ chip->dev = &handle_to_dev(link);
+ snd_card_set_dev(chip->card, chip->dev);
+
+ if (snd_vxpocket_assign_resources(chip, link->io.BasePort1, link->irq.AssignedIRQ) < 0)
+ goto failed;
+
+ link->dev_node = &vxp->node;
+ return 0;
+
+cs_failed:
+ cs_error(link, last_fn, last_ret);
+failed:
+ pcmcia_disable_device(link);
+ return -ENODEV;
+}
+
+#ifdef CONFIG_PM
+
+static int vxp_suspend(struct pcmcia_device *link)
+{
+ struct vx_core *chip = link->priv;
+
+ snd_printdd(KERN_DEBUG "SUSPEND\n");
+ if (chip) {
+ snd_printdd(KERN_DEBUG "snd_vx_suspend calling\n");
+ snd_vx_suspend(chip, PMSG_SUSPEND);
+ }
+
+ return 0;
+}
+
+static int vxp_resume(struct pcmcia_device *link)
+{
+ struct vx_core *chip = link->priv;
+
+ snd_printdd(KERN_DEBUG "RESUME\n");
+ if (pcmcia_dev_present(link)) {
+ //struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip;
+ if (chip) {
+ snd_printdd(KERN_DEBUG "calling snd_vx_resume\n");
+ snd_vx_resume(chip);
+ }
+ }
+ snd_printdd(KERN_DEBUG "resume done!\n");
+
+ return 0;
+}
+
+#endif
+
+
+/*
+ */
+static int vxpocket_probe(struct pcmcia_device *p_dev)
+{
+ struct snd_card *card;
+ struct snd_vxpocket *vxp;
+ int i;
+
+ /* find an empty slot from the card list */
+ for (i = 0; i < SNDRV_CARDS; i++) {
+ if (! card_alloc & (1 << i))
+ break;
+ }
+ if (i >= SNDRV_CARDS) {
+ snd_printk(KERN_ERR "vxpocket: too many cards found\n");
+ return -EINVAL;
+ }
+ if (! enable[i])
+ return -ENODEV; /* disabled explicitly */
+
+ /* ok, create a card instance */
+ card = snd_card_new(index[i], id[i], THIS_MODULE, 0);
+ if (card == NULL) {
+ snd_printk(KERN_ERR "vxpocket: cannot create a card instance\n");
+ return -ENOMEM;
+ }
+
+ vxp = snd_vxpocket_new(card, ibl[i], p_dev);
+ if (! vxp) {
+ snd_card_free(card);
+ return -ENODEV;
+ }
+ card->private_data = vxp;
+
+ vxp->index = i;
+ card_alloc |= 1 << i;
+
+ vxp->p_dev = p_dev;
+
+ return vxpocket_config(p_dev);
+}
+
+static void vxpocket_detach(struct pcmcia_device *link)
+{
+ struct snd_vxpocket *vxp;
+ struct vx_core *chip;
+
+ if (! link)
+ return;
+
+ vxp = link->priv;
+ chip = (struct vx_core *)vxp;
+ card_alloc &= ~(1 << vxp->index);
+
+ chip->chip_status |= VX_STAT_IS_STALE; /* to be sure */
+ snd_card_disconnect(chip->card);
+ vxpocket_release(link);
+ snd_card_free_when_closed(chip->card);