diff options
author | Takashi Iwai <tiwai@suse.de> | 2006-10-11 12:52:53 -0400 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2006-10-22 04:51:10 -0400 |
commit | 30b35399ceb2398d05837863476dcb12f12f3a82 (patch) | |
tree | 14a7cfad1c5d28d207bb1be8addb86ead33f7b63 /sound/pci/es1938.c | |
parent | c06134d73cdc02bb8ab1fad180f6da1f28d2e049 (diff) |
[ALSA] Various fixes for suspend/resume of ALSA PCI drivers
- Check the return value of pci_enable_device() and request_irq()
in the suspend. If any error occurs there, disable the device
using snd_card_disconnect().
- Call pci_set_power_state() properly with pci_choose_state().
- Fix the order to call pci_set_power_state().
- Removed obsolete house-made PM codes in some drivers.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound/pci/es1938.c')
-rw-r--r-- | sound/pci/es1938.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c index 2da988f78ba7..1a8d36df4b5d 100644 --- a/sound/pci/es1938.c +++ b/sound/pci/es1938.c | |||
@@ -1481,10 +1481,14 @@ static int es1938_suspend(struct pci_dev *pci, pm_message_t state) | |||
1481 | *d = snd_es1938_reg_read(chip, *s); | 1481 | *d = snd_es1938_reg_read(chip, *s); |
1482 | 1482 | ||
1483 | outb(0x00, SLIO_REG(chip, IRQCONTROL)); /* disable irqs */ | 1483 | outb(0x00, SLIO_REG(chip, IRQCONTROL)); /* disable irqs */ |
1484 | if (chip->irq >= 0) | 1484 | if (chip->irq >= 0) { |
1485 | synchronize_irq(chip->irq); | ||
1485 | free_irq(chip->irq, chip); | 1486 | free_irq(chip->irq, chip); |
1487 | chip->irq = -1; | ||
1488 | } | ||
1486 | pci_disable_device(pci); | 1489 | pci_disable_device(pci); |
1487 | pci_save_state(pci); | 1490 | pci_save_state(pci); |
1491 | pci_set_power_state(pci, pci_choose_state(pci, state)); | ||
1488 | return 0; | 1492 | return 0; |
1489 | } | 1493 | } |
1490 | 1494 | ||
@@ -1494,10 +1498,22 @@ static int es1938_resume(struct pci_dev *pci) | |||
1494 | struct es1938 *chip = card->private_data; | 1498 | struct es1938 *chip = card->private_data; |
1495 | unsigned char *s, *d; | 1499 | unsigned char *s, *d; |
1496 | 1500 | ||
1501 | pci_set_power_state(pci, PCI_D0); | ||
1497 | pci_restore_state(pci); | 1502 | pci_restore_state(pci); |
1498 | pci_enable_device(pci); | 1503 | if (pci_enable_device(pci) < 0) { |
1499 | request_irq(pci->irq, snd_es1938_interrupt, | 1504 | printk(KERN_ERR "es1938: pci_enable_device failed, " |
1500 | IRQF_DISABLED|IRQF_SHARED, "ES1938", chip); | 1505 | "disabling device\n"); |
1506 | snd_card_disconnect(card); | ||
1507 | return -EIO; | ||
1508 | } | ||
1509 | |||
1510 | if (request_irq(pci->irq, snd_es1938_interrupt, | ||
1511 | IRQF_DISABLED|IRQF_SHARED, "ES1938", chip)) { | ||
1512 | printk(KERN_ERR "es1938: unable to grab IRQ %d, " | ||
1513 | "disabling device\n", pci->irq); | ||
1514 | snd_card_disconnect(card); | ||
1515 | return -EIO; | ||
1516 | } | ||
1501 | chip->irq = pci->irq; | 1517 | chip->irq = pci->irq; |
1502 | snd_es1938_chip_init(chip); | 1518 | snd_es1938_chip_init(chip); |
1503 | 1519 | ||
@@ -1556,8 +1572,10 @@ static int snd_es1938_free(struct es1938 *chip) | |||
1556 | 1572 | ||
1557 | snd_es1938_free_gameport(chip); | 1573 | snd_es1938_free_gameport(chip); |
1558 | 1574 | ||
1559 | if (chip->irq >= 0) | 1575 | if (chip->irq >= 0) { |
1576 | synchronize_irq(chip->irq); | ||
1560 | free_irq(chip->irq, chip); | 1577 | free_irq(chip->irq, chip); |
1578 | } | ||
1561 | pci_release_regions(chip->pci); | 1579 | pci_release_regions(chip->pci); |
1562 | pci_disable_device(chip->pci); | 1580 | pci_disable_device(chip->pci); |
1563 | kfree(chip); | 1581 | kfree(chip); |
@@ -1602,6 +1620,7 @@ static int __devinit snd_es1938_create(struct snd_card *card, | |||
1602 | spin_lock_init(&chip->mixer_lock); | 1620 | spin_lock_init(&chip->mixer_lock); |
1603 | chip->card = card; | 1621 | chip->card = card; |
1604 | chip->pci = pci; | 1622 | chip->pci = pci; |
1623 | chip->irq = -1; | ||
1605 | if ((err = pci_request_regions(pci, "ESS Solo-1")) < 0) { | 1624 | if ((err = pci_request_regions(pci, "ESS Solo-1")) < 0) { |
1606 | kfree(chip); | 1625 | kfree(chip); |
1607 | pci_disable_device(pci); | 1626 | pci_disable_device(pci); |