Changeset 717 for GPL/trunk/alsa-kernel/pci/es1938.c
- Timestamp:
- Aug 7, 2022, 6:11:12 PM (3 years ago)
- Location:
- GPL/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk
- Property svn:mergeinfo changed
/GPL/branches/uniaud32-next merged: 710-716
- Property svn:mergeinfo changed
-
GPL/trunk/alsa-kernel/pci/es1938.c
r703 r717 1557 1557 #endif /* SUPPORT_JOYSTICK */ 1558 1558 1559 static int snd_es1938_free(struct es1938 *chip) 1560 { 1559 static void snd_es1938_free(struct snd_card *card) 1560 { 1561 struct es1938 *chip = card->private_data; 1562 1561 1563 /* disable irqs */ 1562 1564 outb(0x00, SLIO_REG(chip, IRQCONTROL)); … … 1568 1570 if (chip->irq >= 0) 1569 1571 free_irq(chip->irq, chip); 1570 pci_release_regions(chip->pci);1571 pci_disable_device(chip->pci);1572 kfree(chip);1573 return 0;1574 }1575 1576 static int snd_es1938_dev_free(struct snd_device *device)1577 {1578 struct es1938 *chip = device->device_data;1579 return snd_es1938_free(chip);1580 1572 } 1581 1573 1582 1574 static int snd_es1938_create(struct snd_card *card, 1583 struct pci_dev *pci, 1584 struct es1938 **rchip) 1585 { 1586 struct es1938 *chip; 1575 struct pci_dev *pci) 1576 { 1577 struct es1938 *chip = card->private_data; 1587 1578 int err; 1588 static const struct snd_device_ops ops = {1589 .dev_free = snd_es1938_dev_free,1590 };1591 1592 *rchip = NULL;1593 1579 1594 1580 /* enable PCI device */ 1595 err = pci _enable_device(pci);1581 err = pcim_enable_device(pci); 1596 1582 if (err < 0) 1597 1583 return err; … … 1600 1586 dev_err(card->dev, 1601 1587 "architecture does not support 24bit PCI busmaster DMA\n"); 1602 pci_disable_device(pci);1603 1588 return -ENXIO; 1604 1589 } 1605 1590 1606 chip = kzalloc(sizeof(*chip), GFP_KERNEL);1607 if (chip == NULL) {1608 pci_disable_device(pci);1609 return -ENOMEM;1610 }1611 1591 spin_lock_init(&chip->reg_lock); 1612 1592 spin_lock_init(&chip->mixer_lock); … … 1615 1595 chip->irq = -1; 1616 1596 err = pci_request_regions(pci, "ESS Solo-1"); 1617 if (err < 0) { 1618 kfree(chip); 1619 pci_disable_device(pci); 1597 if (err < 0) 1620 1598 return err; 1621 }1622 1599 chip->io_port = pci_resource_start(pci, 0); 1623 1600 chip->sb_port = pci_resource_start(pci, 1); … … 1625 1602 chip->mpu_port = pci_resource_start(pci, 3); 1626 1603 chip->game_port = pci_resource_start(pci, 4); 1604 /* still use non-managed irq handler as it's re-acquired at PM resume */ 1627 1605 if (request_irq(pci->irq, snd_es1938_interrupt, IRQF_SHARED, 1628 1606 KBUILD_MODNAME, chip)) { 1629 1607 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); 1630 snd_es1938_free(chip);1631 1608 return -EBUSY; 1632 1609 } 1633 1610 chip->irq = pci->irq; 1634 1611 card->sync_irq = chip->irq; 1612 card->private_free = snd_es1938_free; 1635 1613 dev_dbg(card->dev, 1636 1614 "create: io: 0x%lx, sb: 0x%lx, vc: 0x%lx, mpu: 0x%lx, game: 0x%lx\n", … … 1640 1618 1641 1619 snd_es1938_chip_init(chip); 1642 1643 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);1644 if (err < 0) {1645 snd_es1938_free(chip);1646 return err;1647 }1648 1649 *rchip = chip;1650 1620 return 0; 1651 1621 } … … 1782 1752 1783 1753 1784 static int snd_es1938_probe(struct pci_dev *pci,1785 const struct pci_device_id *pci_id)1754 static int __snd_es1938_probe(struct pci_dev *pci, 1755 const struct pci_device_id *pci_id) 1786 1756 { 1787 1757 static int dev; … … 1798 1768 } 1799 1769 1800 err = snd_ card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,1801 0, &card);1770 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 1771 sizeof(*chip), &card); 1802 1772 if (err < 0) 1803 1773 return err; 1804 for (idx = 0; idx < 5; idx++) { 1774 chip = card->private_data; 1775 1776 for (idx = 0; idx < 5; idx++) 1805 1777 if (pci_resource_start(pci, idx) == 0 || 1806 !(pci_resource_flags(pci, idx) & IORESOURCE_IO)) { 1807 snd_card_free(card); 1808 return -ENODEV; 1809 } 1810 } 1811 err = snd_es1938_create(card, pci, &chip); 1812 if (err < 0) { 1813 snd_card_free(card); 1778 !(pci_resource_flags(pci, idx) & IORESOURCE_IO)) 1779 return -ENODEV; 1780 1781 err = snd_es1938_create(card, pci); 1782 if (err < 0) 1814 1783 return err; 1815 }1816 card->private_data = chip;1817 1784 1818 1785 strcpy(card->driver, "ES1938"); … … 1824 1791 1825 1792 err = snd_es1938_new_pcm(chip, 0); 1826 if (err < 0) { 1827 snd_card_free(card); 1793 if (err < 0) 1828 1794 return err; 1829 }1830 1795 err = snd_es1938_mixer(chip); 1831 if (err < 0) { 1832 snd_card_free(card); 1796 if (err < 0) 1833 1797 return err; 1834 }1835 1798 if (snd_opl3_create(card, 1836 1799 SLSB_REG(chip, FMLOWADDR), … … 1841 1804 } else { 1842 1805 err = snd_opl3_timer_new(opl3, 0, 1); 1843 if (err < 0) { 1844 snd_card_free(card); 1806 if (err < 0) 1845 1807 return err; 1846 }1847 1808 err = snd_opl3_hwdep_new(opl3, 0, 1, NULL); 1848 if (err < 0) { 1849 snd_card_free(card); 1809 if (err < 0) 1850 1810 return err; 1851 }1852 1811 } 1853 1812 if (snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, … … 1865 1824 1866 1825 err = snd_card_register(card); 1867 if (err < 0) { 1868 snd_card_free(card); 1826 if (err < 0) 1869 1827 return err; 1870 }1871 1828 1872 1829 pci_set_drvdata(pci, card); … … 1875 1832 } 1876 1833 1877 static void snd_es1938_remove(struct pci_dev *pci) 1878 { 1879 snd_card_free(pci_get_drvdata(pci)); 1834 static int snd_es1938_probe(struct pci_dev *pci, 1835 const struct pci_device_id *pci_id) 1836 { 1837 return snd_card_free_on_error(&pci->dev, __snd_es1938_probe(pci, pci_id)); 1880 1838 } 1881 1839 … … 1884 1842 .id_table = snd_es1938_ids, 1885 1843 .probe = snd_es1938_probe, 1886 .remove = snd_es1938_remove,1887 1844 .driver = { 1888 1845 .pm = ES1938_PM_OPS,
Note:
See TracChangeset
for help on using the changeset viewer.