From af26367f69a474ed809e4a59abb5855b47daaff4 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 14:46:59 +0100 Subject: [ALSA] Remove xxx_t typedefs: VXdriver Remove xxx_t typedefs from the VXdriver codes (vx_core support, vx222 and vxpocket). Signed-off-by: Takashi Iwai --- sound/pcmcia/vx/vxpocket.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'sound/pcmcia/vx/vxpocket.c') diff --git a/sound/pcmcia/vx/vxpocket.c b/sound/pcmcia/vx/vxpocket.c index 1e8f16b4c073..009629714140 100644 --- a/sound/pcmcia/vx/vxpocket.c +++ b/sound/pcmcia/vx/vxpocket.c @@ -83,9 +83,9 @@ static void vxpocket_release(dev_link_t *link) /* * destructor, called from snd_card_free_in_thread() */ -static int snd_vxpocket_dev_free(snd_device_t *device) +static int snd_vxpocket_dev_free(struct snd_device *device) { - vx_core_t *chip = device->device_data; + struct vx_core *chip = device->device_data; snd_vx_free_firmware(chip); kfree(chip); @@ -142,19 +142,19 @@ static struct snd_vx_hardware vxp440_hw = { /* * create vxpocket instance */ -static struct snd_vxpocket *snd_vxpocket_new(snd_card_t *card, int ibl) +static struct snd_vxpocket *snd_vxpocket_new(struct snd_card *card, int ibl) { client_reg_t client_reg; /* Register with cardmgr */ dev_link_t *link; /* Info for cardmgr */ - vx_core_t *chip; + struct vx_core *chip; struct snd_vxpocket *vxp; int ret; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_vxpocket_dev_free, }; chip = snd_vx_create(card, &vxpocket_hw, &snd_vxpocket_ops, - sizeof(struct snd_vxpocket) - sizeof(vx_core_t)); + sizeof(struct snd_vxpocket) - sizeof(struct vx_core)); if (! chip) return NULL; @@ -218,10 +218,10 @@ static struct snd_vxpocket *snd_vxpocket_new(snd_card_t *card, int ibl) * * returns 0 if successful, or a negative error code. */ -static int snd_vxpocket_assign_resources(vx_core_t *chip, int port, int irq) +static int snd_vxpocket_assign_resources(struct vx_core *chip, int port, int irq) { int err; - snd_card_t *card = chip->card; + 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); @@ -250,7 +250,7 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) static void vxpocket_config(dev_link_t *link) { client_handle_t handle = link->handle; - vx_core_t *chip = link->priv; + struct vx_core *chip = link->priv; struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip; tuple_t tuple; cisparse_t *parse; @@ -324,7 +324,7 @@ failed: static int vxpocket_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - vx_core_t *chip = link->priv; + struct vx_core *chip = link->priv; switch (event) { case CS_EVENT_CARD_REMOVAL: @@ -379,7 +379,7 @@ static int vxpocket_event(event_t event, int priority, event_callback_args_t *ar */ static dev_link_t *vxpocket_attach(void) { - snd_card_t *card; + struct snd_card *card; struct snd_vxpocket *vxp; int i; @@ -421,14 +421,14 @@ static dev_link_t *vxpocket_attach(void) static void vxpocket_detach(dev_link_t *link) { struct snd_vxpocket *vxp; - vx_core_t *chip; + struct vx_core *chip; dev_link_t **linkp; if (! link) return; vxp = link->priv; - chip = (vx_core_t *)vxp; + chip = (struct vx_core *)vxp; card_alloc &= ~(1 << vxp->index); /* Remove the interface data from the linked list */ -- cgit v1.2.3-59-g8ed1b From 0ed1cad172176a4595f82e8cd9055938ad54bd4b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:06:05 +0100 Subject: [ALSA] vx-driver - Fix PM support Fix PM support on VX drivers (vxpocket and vx222). Signed-off-by: Takashi Iwai --- include/sound/vx_core.h | 6 ++++++ sound/drivers/vx/vx_core.c | 18 ++++++++---------- sound/pci/vx222/vx222.c | 33 ++++++++++++++++++++++++++++++++- sound/pcmcia/vx/vxpocket.c | 9 +++++---- 4 files changed, 51 insertions(+), 15 deletions(-) (limited to 'sound/pcmcia/vx/vxpocket.c') diff --git a/include/sound/vx_core.h b/include/sound/vx_core.h index 0a85c37d1bc7..5fd6f3305e0d 100644 --- a/include/sound/vx_core.h +++ b/include/sound/vx_core.h @@ -346,6 +346,12 @@ void vx_set_internal_clock(struct vx_core *chip, unsigned int freq); int vx_change_frequency(struct vx_core *chip); +/* + * PM + */ +int snd_vx_suspend(struct vx_core *card, pm_message_t state); +int snd_vx_resume(struct vx_core *card); + /* * hardware constants */ diff --git a/sound/drivers/vx/vx_core.c b/sound/drivers/vx/vx_core.c index 5abf42351772..43f615d7a545 100644 --- a/sound/drivers/vx/vx_core.c +++ b/sound/drivers/vx/vx_core.c @@ -709,13 +709,11 @@ int snd_vx_dsp_load(struct vx_core *chip, const struct firmware *dsp) /* * suspend */ -static int snd_vx_suspend(struct snd_card *card, pm_message_t state) +int snd_vx_suspend(struct vx_core *chip, pm_message_t state) { - struct vx_core *chip = card->pm_private_data; unsigned int i; - snd_assert(chip, return -EINVAL); - + snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot); chip->chip_status |= VX_STAT_IN_SUSPEND; for (i = 0; i < chip->hw->num_codecs; i++) snd_pcm_suspend_all(chip->pcm[i]); @@ -726,13 +724,10 @@ static int snd_vx_suspend(struct snd_card *card, pm_message_t state) /* * resume */ -static int snd_vx_resume(struct snd_card *card) +int snd_vx_resume(struct vx_core *chip) { - struct vx_core *chip = card->pm_private_data; int i, err; - snd_assert(chip, return -EINVAL); - chip->chip_status &= ~VX_STAT_CHIP_INIT; for (i = 0; i < 4; i++) { @@ -748,6 +743,7 @@ static int snd_vx_resume(struct snd_card *card) chip->chip_status |= VX_STAT_CHIP_INIT; chip->chip_status &= ~VX_STAT_IN_SUSPEND; + snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0); return 0; } @@ -789,8 +785,6 @@ struct vx_core *snd_vx_create(struct snd_card *card, struct snd_vx_hardware *hw, strcpy(card->driver, hw->name); sprintf(card->shortname, "Digigram %s", hw->name); - snd_card_set_pm_callback(card, snd_vx_suspend, snd_vx_resume, chip); - vx_proc_init(chip); return chip; @@ -822,3 +816,7 @@ EXPORT_SYMBOL(snd_vx_irq_handler); EXPORT_SYMBOL(snd_vx_dsp_boot); EXPORT_SYMBOL(snd_vx_dsp_load); EXPORT_SYMBOL(snd_vx_load_boot_image); +#ifdef CONFIG_PM +EXPORT_SYMBOL(snd_vx_suspend); +EXPORT_SYMBOL(snd_vx_resume); +#endif diff --git a/sound/pci/vx222/vx222.c b/sound/pci/vx222/vx222.c index 4ebbabedb3c3..c816ddf1b215 100644 --- a/sound/pci/vx222/vx222.c +++ b/sound/pci/vx222/vx222.c @@ -218,6 +218,7 @@ static int __devinit snd_vx222_probe(struct pci_dev *pci, snd_card_free(card); return err; } + card->private_data = vx; vx->core.ibl.size = ibl[dev]; sprintf(card->longname, "%s at 0x%lx & 0x%lx, irq %i", @@ -250,12 +251,42 @@ static void __devexit snd_vx222_remove(struct pci_dev *pci) pci_set_drvdata(pci, NULL); } +#ifdef CONFIG_PM +static int snd_vx222_suspend(struct pci_dev *pci, pm_message_t state) +{ + struct snd_card *card = pci_get_drvdata(pci); + struct snd_vx222 *vx = card->private_data; + int err; + + err = snd_vx_suspend(&vx->core, state); + pci_set_power_state(pci, PCI_D3hot); + pci_disable_device(pci); + pci_save_state(pci); + return err; +} + +static int snd_vx222_resume(struct pci_dev *pci) +{ + struct snd_card *card = pci_get_drvdata(pci); + struct snd_vx222 *vx = card->private_data; + + pci_restore_state(pci); + pci_enable_device(pci); + pci_set_power_state(pci, PCI_D0); + pci_set_master(pci); + return snd_vx_resume(&vx->core); +} +#endif + static struct pci_driver driver = { .name = "Digigram VX222", .id_table = snd_vx222_ids, .probe = snd_vx222_probe, .remove = __devexit_p(snd_vx222_remove), - SND_PCI_PM_CALLBACKS +#ifdef CONFIG_PM + .suspend = snd_vx222_suspend, + .resume = snd_vx222_resume, +#endif }; static int __init alsa_card_vx222_init(void) diff --git a/sound/pcmcia/vx/vxpocket.c b/sound/pcmcia/vx/vxpocket.c index 009629714140..5bb079d17959 100644 --- a/sound/pcmcia/vx/vxpocket.c +++ b/sound/pcmcia/vx/vxpocket.c @@ -342,9 +342,9 @@ static int vxpocket_event(event_t event, int priority, event_callback_args_t *ar case CS_EVENT_PM_SUSPEND: snd_printdd(KERN_DEBUG "SUSPEND\n"); link->state |= DEV_SUSPEND; - if (chip && chip->card->pm_suspend) { + if (chip) { snd_printdd(KERN_DEBUG "snd_vx_suspend calling\n"); - chip->card->pm_suspend(chip->card, PMSG_SUSPEND); + snd_vx_suspend(chip, PMSG_SUSPEND); } /* Fall through... */ case CS_EVENT_RESET_PHYSICAL: @@ -362,9 +362,9 @@ static int vxpocket_event(event_t event, int priority, event_callback_args_t *ar //struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip; snd_printdd(KERN_DEBUG "requestconfig...\n"); pcmcia_request_configuration(link->handle, &link->conf); - if (chip && chip->card->pm_resume) { + if (chip) { snd_printdd(KERN_DEBUG "calling snd_vx_resume\n"); - chip->card->pm_resume(chip->card); + snd_vx_resume(chip); } } snd_printdd(KERN_DEBUG "resume done!\n"); @@ -407,6 +407,7 @@ static dev_link_t *vxpocket_attach(void) snd_card_free(card); return NULL; } + card->private_data = vxp; vxp->index = i; card_alloc |= 1 << i; -- cgit v1.2.3-59-g8ed1b From efe3cd105f2a19e72ce9280bb22c7c80752e4314 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Fri, 6 Jan 2006 00:27:16 +0100 Subject: [PATCH] pcmcia: fix sound drivers Update the PCMCIA sound drivers to handle the recent changes to the PCMCIA core. A part of this merge was done by Takashi Iwai . Signed-off-by: Dominik Brodowski --- sound/pcmcia/pdaudiocf/pdaudiocf.c | 154 ++++++++++++++---------------------- sound/pcmcia/vx/vxpocket.c | 155 +++++++++++++------------------------ 2 files changed, 115 insertions(+), 194 deletions(-) (limited to 'sound/pcmcia/vx/vxpocket.c') diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.c b/sound/pcmcia/pdaudiocf/pdaudiocf.c index a7cd2d4df757..77caf43a3109 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf.c @@ -52,16 +52,13 @@ MODULE_PARM_DESC(enable, "Enable " CARD_NAME " soundcard."); /* */ -static dev_info_t dev_info = "snd-pdaudiocf"; static struct snd_card *card_list[SNDRV_CARDS]; -static dev_link_t *dev_list; /* * prototypes */ static void pdacf_config(dev_link_t *link); -static int pdacf_event(event_t event, int priority, event_callback_args_t *args); -static void snd_pdacf_detach(dev_link_t *link); +static void snd_pdacf_detach(struct pcmcia_device *p_dev); static void pdacf_release(dev_link_t *link) { @@ -83,10 +80,6 @@ static int snd_pdacf_free(struct snd_pdacf *pdacf) pdacf_release(link); - /* Break the link with Card Services */ - if (link->handle) - pcmcia_deregister_client(link->handle); - card_list[pdacf->index] = NULL; pdacf->card = NULL; @@ -103,11 +96,10 @@ static int snd_pdacf_dev_free(struct snd_device *device) /* * snd_pdacf_attach - attach callback for cs */ -static dev_link_t *snd_pdacf_attach(void) +static int snd_pdacf_attach(struct pcmcia_device *p_dev) { - client_reg_t client_reg; /* Register with cardmgr */ - dev_link_t *link; /* Info for cardmgr */ - int i, ret; + int i; + dev_link_t *link; /* Info for cardmgr */ struct snd_pdacf *pdacf; struct snd_card *card; static struct snd_device_ops ops = { @@ -122,26 +114,26 @@ static dev_link_t *snd_pdacf_attach(void) } if (i >= SNDRV_CARDS) { snd_printk(KERN_ERR "pdacf: too many cards found\n"); - return NULL; + return -EINVAL; } if (! enable[i]) - return NULL; /* disabled explicitly */ + 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 "pdacf: cannot create a card instance\n"); - return NULL; + return -ENOMEM; } pdacf = snd_pdacf_create(card); if (! pdacf) - return NULL; + return -EIO; if (snd_device_new(card, SNDRV_DEV_LOWLEVEL, pdacf, &ops) < 0) { kfree(pdacf); snd_card_free(card); - return NULL; + return -ENODEV; } pdacf->index = i; @@ -165,22 +157,12 @@ static dev_link_t *snd_pdacf_attach(void) link->conf.Present = PRESENT_OPTION; /* Chain drivers */ - link->next = dev_list; - dev_list = link; - - /* Register with Card Services */ - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != CS_SUCCESS) { - cs_error(link->handle, RegisterClient, ret); - snd_pdacf_detach(link); - return NULL; - } + link->next = NULL; - return link; + link->handle = p_dev; + pdacf_config(link); + + return 0; } @@ -227,21 +209,13 @@ static int snd_pdacf_assign_resources(struct snd_pdacf *pdacf, int port, int irq /* * snd_pdacf_detach - detach callback for cs */ -static void snd_pdacf_detach(dev_link_t *link) +static void snd_pdacf_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); struct snd_pdacf *chip = link->priv; snd_printdd(KERN_DEBUG "pdacf_detach called\n"); - /* Remove the interface data from the linked list */ - { - dev_link_t **linkp; - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) - break; - if (*linkp) - *linkp = link->next; - } + if (chip->chip_status & PDAUDIOCF_STAT_IS_CONFIGURED) snd_pdacf_powerdown(chip); chip->chip_status |= PDAUDIOCF_STAT_IS_STALE; /* to be sure */ @@ -310,62 +284,51 @@ failed: pcmcia_release_irq(link->handle, &link->irq); } -/* - * event callback - */ -static int pdacf_event(event_t event, int priority, event_callback_args_t *args) +#ifdef CONFIG_PM + +static int pdacf_suspend(struct pcmcia_device *dev) { - dev_link_t *link = args->client_data; + dev_link_t *link = dev_to_instance(dev); struct snd_pdacf *chip = link->priv; - switch (event) { - case CS_EVENT_CARD_REMOVAL: - snd_printdd(KERN_DEBUG "CARD_REMOVAL..\n"); - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { - chip->chip_status |= PDAUDIOCF_STAT_IS_STALE; - } - break; - case CS_EVENT_CARD_INSERTION: - snd_printdd(KERN_DEBUG "CARD_INSERTION..\n"); - link->state |= DEV_PRESENT; - pdacf_config(link); - break; -#ifdef CONFIG_PM - case CS_EVENT_PM_SUSPEND: - snd_printdd(KERN_DEBUG "SUSPEND\n"); - link->state |= DEV_SUSPEND; + snd_printdd(KERN_DEBUG "SUSPEND\n"); + link->state |= DEV_SUSPEND; + if (chip) { + snd_printdd(KERN_DEBUG "snd_pdacf_suspend calling\n"); + snd_pdacf_suspend(chip, PMSG_SUSPEND); + } + + snd_printdd(KERN_DEBUG "RESET_PHYSICAL\n"); + if (link->state & DEV_CONFIG) + pcmcia_release_configuration(link->handle); + + return 0; +} + +static int pdacf_resume(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + struct snd_pdacf *chip = link->priv; + + snd_printdd(KERN_DEBUG "RESUME\n"); + link->state &= ~DEV_SUSPEND; + + snd_printdd(KERN_DEBUG "CARD_RESET\n"); + if (DEV_OK(link)) { + snd_printdd(KERN_DEBUG "requestconfig...\n"); + pcmcia_request_configuration(link->handle, &link->conf); if (chip) { - snd_printdd(KERN_DEBUG "snd_pdacf_suspend calling\n"); - snd_pdacf_suspend(chip, PMSG_SUSPEND); - } - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - snd_printdd(KERN_DEBUG "RESET_PHYSICAL\n"); - if (link->state & DEV_CONFIG) - pcmcia_release_configuration(link->handle); - break; - case CS_EVENT_PM_RESUME: - snd_printdd(KERN_DEBUG "RESUME\n"); - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - snd_printdd(KERN_DEBUG "CARD_RESET\n"); - if (DEV_OK(link)) { - snd_printdd(KERN_DEBUG "requestconfig...\n"); - pcmcia_request_configuration(link->handle, &link->conf); - if (chip) { - snd_printdd(KERN_DEBUG "calling snd_pdacf_resume\n"); - snd_pdacf_resume(chip); - } + snd_printdd(KERN_DEBUG "calling snd_pdacf_resume\n"); + snd_pdacf_resume(chip); } - snd_printdd(KERN_DEBUG "resume done!\n"); - break; -#endif } + snd_printdd(KERN_DEBUG "resume done!\n"); + return 0; } +#endif + /* * Module entry points */ @@ -380,10 +343,14 @@ static struct pcmcia_driver pdacf_cs_driver = { .drv = { .name = "snd-pdaudiocf", }, - .attach = snd_pdacf_attach, - .event = pdacf_event, - .detach = snd_pdacf_detach, + .probe = snd_pdacf_attach, + .remove = snd_pdacf_detach, .id_table = snd_pdacf_ids, +#ifdef CONFIG_PM + .suspend = pdacf_suspend, + .resume = pdacf_resume, +#endif + }; static int __init init_pdacf(void) @@ -394,7 +361,6 @@ static int __init init_pdacf(void) static void __exit exit_pdacf(void) { pcmcia_unregister_driver(&pdacf_cs_driver); - BUG_ON(dev_list != NULL); } module_init(init_pdacf); diff --git a/sound/pcmcia/vx/vxpocket.c b/sound/pcmcia/vx/vxpocket.c index 5bb079d17959..66900d20a42f 100644 --- a/sound/pcmcia/vx/vxpocket.c +++ b/sound/pcmcia/vx/vxpocket.c @@ -55,11 +55,6 @@ MODULE_PARM_DESC(ibl, "Capture IBL size for VXPocket soundcard."); */ static unsigned int card_alloc; -static dev_link_t *dev_list; /* Linked list of devices */ -static dev_info_t dev_info = "snd-vxpocket"; - - -static int vxpocket_event(event_t event, int priority, event_callback_args_t *args); /* @@ -73,11 +68,6 @@ static void vxpocket_release(dev_link_t *link) pcmcia_release_irq(link->handle, &link->irq); link->state &= ~DEV_CONFIG; } - if (link->handle) { - /* Break the link with Card Services */ - pcmcia_deregister_client(link->handle); - link->handle = NULL; - } } /* @@ -144,11 +134,9 @@ static struct snd_vx_hardware vxp440_hw = { */ static struct snd_vxpocket *snd_vxpocket_new(struct snd_card *card, int ibl) { - client_reg_t client_reg; /* Register with cardmgr */ dev_link_t *link; /* Info for cardmgr */ struct vx_core *chip; struct snd_vxpocket *vxp; - int ret; static struct snd_device_ops ops = { .dev_free = snd_vxpocket_dev_free, }; @@ -184,26 +172,6 @@ static struct snd_vxpocket *snd_vxpocket_new(struct snd_card *card, int ibl) link->conf.ConfigIndex = 1; link->conf.Present = PRESENT_OPTION; - /* Register with Card Services */ - memset(&client_reg, 0, sizeof(client_reg)); - client_reg.dev_info = &dev_info; - client_reg.EventMask = - CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL -#ifdef CONFIG_PM - | CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET - | CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME -#endif - ; - client_reg.event_handler = &vxpocket_event; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != CS_SUCCESS) { - cs_error(link->handle, RegisterClient, ret); - return NULL; - } - return vxp; } @@ -317,67 +285,55 @@ failed: kfree(parse); } +#ifdef CONFIG_PM -/* - * event callback - */ -static int vxpocket_event(event_t event, int priority, event_callback_args_t *args) +static int vxp_suspend(struct pcmcia_device *dev) { - dev_link_t *link = args->client_data; + dev_link_t *link = dev_to_instance(dev); struct vx_core *chip = link->priv; - switch (event) { - case CS_EVENT_CARD_REMOVAL: - snd_printdd(KERN_DEBUG "CARD_REMOVAL..\n"); - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) - chip->chip_status |= VX_STAT_IS_STALE; - break; - case CS_EVENT_CARD_INSERTION: - snd_printdd(KERN_DEBUG "CARD_INSERTION..\n"); - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - vxpocket_config(link); - break; -#ifdef CONFIG_PM - case CS_EVENT_PM_SUSPEND: - snd_printdd(KERN_DEBUG "SUSPEND\n"); - link->state |= DEV_SUSPEND; + snd_printdd(KERN_DEBUG "SUSPEND\n"); + link->state |= DEV_SUSPEND; + if (chip) { + snd_printdd(KERN_DEBUG "snd_vx_suspend calling\n"); + snd_vx_suspend(chip, PMSG_SUSPEND); + } + snd_printdd(KERN_DEBUG "RESET_PHYSICAL\n"); + if (link->state & DEV_CONFIG) + pcmcia_release_configuration(link->handle); + + return 0; +} + +static int vxp_resume(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + struct vx_core *chip = link->priv; + + snd_printdd(KERN_DEBUG "RESUME\n"); + link->state &= ~DEV_SUSPEND; + + snd_printdd(KERN_DEBUG "CARD_RESET\n"); + if (DEV_OK(link)) { + //struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip; + snd_printdd(KERN_DEBUG "requestconfig...\n"); + pcmcia_request_configuration(link->handle, &link->conf); if (chip) { - snd_printdd(KERN_DEBUG "snd_vx_suspend calling\n"); - snd_vx_suspend(chip, PMSG_SUSPEND); + snd_printdd(KERN_DEBUG "calling snd_vx_resume\n"); + snd_vx_resume(chip); } - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - snd_printdd(KERN_DEBUG "RESET_PHYSICAL\n"); - if (link->state & DEV_CONFIG) - pcmcia_release_configuration(link->handle); - break; - case CS_EVENT_PM_RESUME: - snd_printdd(KERN_DEBUG "RESUME\n"); - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - snd_printdd(KERN_DEBUG "CARD_RESET\n"); - if (DEV_OK(link)) { - //struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip; - snd_printdd(KERN_DEBUG "requestconfig...\n"); - pcmcia_request_configuration(link->handle, &link->conf); - if (chip) { - snd_printdd(KERN_DEBUG "calling snd_vx_resume\n"); - snd_vx_resume(chip); - } - } - snd_printdd(KERN_DEBUG "resume done!\n"); - break; -#endif } + snd_printdd(KERN_DEBUG "resume done!\n"); + return 0; } +#endif + /* */ -static dev_link_t *vxpocket_attach(void) +static int vxpocket_attach(struct pcmcia_device *p_dev) { struct snd_card *card; struct snd_vxpocket *vxp; @@ -390,22 +346,22 @@ static dev_link_t *vxpocket_attach(void) } if (i >= SNDRV_CARDS) { snd_printk(KERN_ERR "vxpocket: too many cards found\n"); - return NULL; + return -EINVAL; } if (! enable[i]) - return NULL; /* disabled explicitly */ + 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 NULL; + return -ENOMEM; } vxp = snd_vxpocket_new(card, ibl[i]); if (! vxp) { snd_card_free(card); - return NULL; + return -ENODEV; } card->private_data = vxp; @@ -413,17 +369,21 @@ static dev_link_t *vxpocket_attach(void) card_alloc |= 1 << i; /* Chain drivers */ - vxp->link.next = dev_list; - dev_list = &vxp->link; + vxp->link.next = NULL; + + vxp->link.handle = p_dev; + vxp->link.state |= DEV_PRESENT | DEV_CONFIG_PENDING; + p_dev->instance = &vxp->link; + vxpocket_config(&vxp->link); - return &vxp->link; + return 0; } -static void vxpocket_detach(dev_link_t *link) +static void vxpocket_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); struct snd_vxpocket *vxp; struct vx_core *chip; - dev_link_t **linkp; if (! link) return; @@ -432,13 +392,6 @@ static void vxpocket_detach(dev_link_t *link) chip = (struct vx_core *)vxp; card_alloc &= ~(1 << vxp->index); - /* Remove the interface data from the linked list */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) { - *linkp = link->next; - break; - } - chip->chip_status |= VX_STAT_IS_STALE; /* to be sure */ snd_card_disconnect(chip->card); vxpocket_release(link); @@ -460,10 +413,13 @@ static struct pcmcia_driver vxp_cs_driver = { .drv = { .name = "snd-vxpocket", }, - .attach = vxpocket_attach, - .detach = vxpocket_detach, - .event = vxpocket_event, + .probe = vxpocket_attach, + .remove = vxpocket_detach, .id_table = vxp_ids, +#ifdef CONFIG_PM + .suspend = vxp_suspend, + .resume = vxp_resume, +#endif }; static int __init init_vxpocket(void) @@ -474,7 +430,6 @@ static int __init init_vxpocket(void) static void __exit exit_vxpocket(void) { pcmcia_unregister_driver(&vxp_cs_driver); - BUG_ON(dev_list != NULL); } module_init(init_vxpocket); -- cgit v1.2.3-59-g8ed1b