mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
ALSA: via82xx: Allocate resources with device-managed APIs
This patch converts the resource management in PCI via82xx drivers with devres as a clean up. Each manual resource management is converted with the corresponding devres helper, and the card object release is managed now via card->private_free instead of a lowlevel snd_device. This should give no user-visible functional changes. Link: https://lore.kernel.org/r/20210715075941.23332-26-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
2ca6cbde6a
commit
afaf99751d
2 changed files with 49 additions and 155 deletions
|
@ -1911,13 +1911,12 @@ static int snd_via82xx_mixer_new(struct via82xx *chip, const char *quirk_overrid
|
||||||
static int snd_via686_create_gameport(struct via82xx *chip, unsigned char *legacy)
|
static int snd_via686_create_gameport(struct via82xx *chip, unsigned char *legacy)
|
||||||
{
|
{
|
||||||
struct gameport *gp;
|
struct gameport *gp;
|
||||||
struct resource *r;
|
|
||||||
|
|
||||||
if (!joystick)
|
if (!joystick)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
r = request_region(JOYSTICK_ADDR, 8, "VIA686 gameport");
|
if (!devm_request_region(chip->card->dev, JOYSTICK_ADDR, 8,
|
||||||
if (!r) {
|
"VIA686 gameport")) {
|
||||||
dev_warn(chip->card->dev, "cannot reserve joystick port %#x\n",
|
dev_warn(chip->card->dev, "cannot reserve joystick port %#x\n",
|
||||||
JOYSTICK_ADDR);
|
JOYSTICK_ADDR);
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
@ -1927,7 +1926,6 @@ static int snd_via686_create_gameport(struct via82xx *chip, unsigned char *legac
|
||||||
if (!gp) {
|
if (!gp) {
|
||||||
dev_err(chip->card->dev,
|
dev_err(chip->card->dev,
|
||||||
"cannot allocate memory for gameport\n");
|
"cannot allocate memory for gameport\n");
|
||||||
release_and_free_resource(r);
|
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1935,7 +1933,6 @@ static int snd_via686_create_gameport(struct via82xx *chip, unsigned char *legac
|
||||||
gameport_set_phys(gp, "pci%s/gameport0", pci_name(chip->pci));
|
gameport_set_phys(gp, "pci%s/gameport0", pci_name(chip->pci));
|
||||||
gameport_set_dev_parent(gp, &chip->pci->dev);
|
gameport_set_dev_parent(gp, &chip->pci->dev);
|
||||||
gp->io = JOYSTICK_ADDR;
|
gp->io = JOYSTICK_ADDR;
|
||||||
gameport_set_port_data(gp, r);
|
|
||||||
|
|
||||||
/* Enable legacy joystick port */
|
/* Enable legacy joystick port */
|
||||||
*legacy |= VIA_FUNC_ENABLE_GAME;
|
*legacy |= VIA_FUNC_ENABLE_GAME;
|
||||||
|
@ -1949,11 +1946,8 @@ static int snd_via686_create_gameport(struct via82xx *chip, unsigned char *legac
|
||||||
static void snd_via686_free_gameport(struct via82xx *chip)
|
static void snd_via686_free_gameport(struct via82xx *chip)
|
||||||
{
|
{
|
||||||
if (chip->gameport) {
|
if (chip->gameport) {
|
||||||
struct resource *r = gameport_get_port_data(chip->gameport);
|
|
||||||
|
|
||||||
gameport_unregister_port(chip->gameport);
|
gameport_unregister_port(chip->gameport);
|
||||||
chip->gameport = NULL;
|
chip->gameport = NULL;
|
||||||
release_and_free_resource(r);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -2063,7 +2057,8 @@ static int snd_via686_init_misc(struct via82xx *chip)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mpu_port >= 0x200)
|
if (mpu_port >= 0x200)
|
||||||
chip->mpu_res = request_region(mpu_port, 2, "VIA82xx MPU401");
|
chip->mpu_res = devm_request_region(&chip->pci->dev, mpu_port,
|
||||||
|
2, "VIA82xx MPU401");
|
||||||
if (chip->mpu_res) {
|
if (chip->mpu_res) {
|
||||||
if (rev_h)
|
if (rev_h)
|
||||||
legacy |= VIA_FUNC_MIDI_PNP; /* enable PCI I/O 2 */
|
legacy |= VIA_FUNC_MIDI_PNP; /* enable PCI I/O 2 */
|
||||||
|
@ -2302,61 +2297,35 @@ static SIMPLE_DEV_PM_OPS(snd_via82xx_pm, snd_via82xx_suspend, snd_via82xx_resume
|
||||||
#define SND_VIA82XX_PM_OPS NULL
|
#define SND_VIA82XX_PM_OPS NULL
|
||||||
#endif /* CONFIG_PM_SLEEP */
|
#endif /* CONFIG_PM_SLEEP */
|
||||||
|
|
||||||
static int snd_via82xx_free(struct via82xx *chip)
|
static void snd_via82xx_free(struct snd_card *card)
|
||||||
{
|
{
|
||||||
|
struct via82xx *chip = card->private_data;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (chip->irq < 0)
|
|
||||||
goto __end_hw;
|
|
||||||
/* disable interrupts */
|
/* disable interrupts */
|
||||||
for (i = 0; i < chip->num_devs; i++)
|
for (i = 0; i < chip->num_devs; i++)
|
||||||
snd_via82xx_channel_reset(chip, &chip->devs[i]);
|
snd_via82xx_channel_reset(chip, &chip->devs[i]);
|
||||||
|
|
||||||
if (chip->irq >= 0)
|
|
||||||
free_irq(chip->irq, chip);
|
|
||||||
__end_hw:
|
|
||||||
release_and_free_resource(chip->mpu_res);
|
|
||||||
pci_release_regions(chip->pci);
|
|
||||||
|
|
||||||
if (chip->chip_type == TYPE_VIA686) {
|
if (chip->chip_type == TYPE_VIA686) {
|
||||||
snd_via686_free_gameport(chip);
|
snd_via686_free_gameport(chip);
|
||||||
pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, chip->old_legacy);
|
pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, chip->old_legacy);
|
||||||
pci_write_config_byte(chip->pci, VIA_PNP_CONTROL, chip->old_legacy_cfg);
|
pci_write_config_byte(chip->pci, VIA_PNP_CONTROL, chip->old_legacy_cfg);
|
||||||
}
|
}
|
||||||
pci_disable_device(chip->pci);
|
|
||||||
kfree(chip);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int snd_via82xx_dev_free(struct snd_device *device)
|
|
||||||
{
|
|
||||||
struct via82xx *chip = device->device_data;
|
|
||||||
return snd_via82xx_free(chip);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int snd_via82xx_create(struct snd_card *card,
|
static int snd_via82xx_create(struct snd_card *card,
|
||||||
struct pci_dev *pci,
|
struct pci_dev *pci,
|
||||||
int chip_type,
|
int chip_type,
|
||||||
int revision,
|
int revision,
|
||||||
unsigned int ac97_clock,
|
unsigned int ac97_clock)
|
||||||
struct via82xx **r_via)
|
|
||||||
{
|
{
|
||||||
struct via82xx *chip;
|
struct via82xx *chip = card->private_data;
|
||||||
int err;
|
int err;
|
||||||
static const struct snd_device_ops ops = {
|
|
||||||
.dev_free = snd_via82xx_dev_free,
|
|
||||||
};
|
|
||||||
|
|
||||||
err = pci_enable_device(pci);
|
err = pcim_enable_device(pci);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
chip = kzalloc(sizeof(*chip), GFP_KERNEL);
|
|
||||||
if (!chip) {
|
|
||||||
pci_disable_device(pci);
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
chip->chip_type = chip_type;
|
chip->chip_type = chip_type;
|
||||||
chip->revision = revision;
|
chip->revision = revision;
|
||||||
|
|
||||||
|
@ -2373,44 +2342,31 @@ static int snd_via82xx_create(struct snd_card *card,
|
||||||
chip->old_legacy & ~(VIA_FUNC_ENABLE_SB|VIA_FUNC_ENABLE_FM));
|
chip->old_legacy & ~(VIA_FUNC_ENABLE_SB|VIA_FUNC_ENABLE_FM));
|
||||||
|
|
||||||
err = pci_request_regions(pci, card->driver);
|
err = pci_request_regions(pci, card->driver);
|
||||||
if (err < 0) {
|
if (err < 0)
|
||||||
kfree(chip);
|
|
||||||
pci_disable_device(pci);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
|
||||||
chip->port = pci_resource_start(pci, 0);
|
chip->port = pci_resource_start(pci, 0);
|
||||||
if (request_irq(pci->irq,
|
if (devm_request_irq(&pci->dev, pci->irq,
|
||||||
chip_type == TYPE_VIA8233 ?
|
chip_type == TYPE_VIA8233 ?
|
||||||
snd_via8233_interrupt : snd_via686_interrupt,
|
snd_via8233_interrupt : snd_via686_interrupt,
|
||||||
IRQF_SHARED,
|
IRQF_SHARED,
|
||||||
KBUILD_MODNAME, chip)) {
|
KBUILD_MODNAME, chip)) {
|
||||||
dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
|
dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
|
||||||
snd_via82xx_free(chip);
|
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
chip->irq = pci->irq;
|
chip->irq = pci->irq;
|
||||||
card->sync_irq = chip->irq;
|
card->sync_irq = chip->irq;
|
||||||
|
card->private_free = snd_via82xx_free;
|
||||||
if (ac97_clock >= 8000 && ac97_clock <= 48000)
|
if (ac97_clock >= 8000 && ac97_clock <= 48000)
|
||||||
chip->ac97_clock = ac97_clock;
|
chip->ac97_clock = ac97_clock;
|
||||||
|
|
||||||
err = snd_via82xx_chip_init(chip);
|
err = snd_via82xx_chip_init(chip);
|
||||||
if (err < 0) {
|
if (err < 0)
|
||||||
snd_via82xx_free(chip);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
|
||||||
|
|
||||||
err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
|
|
||||||
if (err < 0) {
|
|
||||||
snd_via82xx_free(chip);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The 8233 ac97 controller does not implement the master bit
|
/* The 8233 ac97 controller does not implement the master bit
|
||||||
* in the pci command register. IMHO this is a violation of the PCI spec.
|
* in the pci command register. IMHO this is a violation of the PCI spec.
|
||||||
* We call pci_set_master here because it does not hurt. */
|
* We call pci_set_master here because it does not hurt. */
|
||||||
pci_set_master(pci);
|
pci_set_master(pci);
|
||||||
|
|
||||||
*r_via = chip;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2511,9 +2467,11 @@ static int snd_via82xx_probe(struct pci_dev *pci,
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card);
|
err = snd_devm_card_new(&pci->dev, index, id, THIS_MODULE,
|
||||||
|
sizeof(*chip), &card);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
chip = card->private_data;
|
||||||
|
|
||||||
card_type = pci_id->driver_data;
|
card_type = pci_id->driver_data;
|
||||||
switch (card_type) {
|
switch (card_type) {
|
||||||
|
@ -2552,36 +2510,34 @@ static int snd_via82xx_probe(struct pci_dev *pci,
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dev_err(card->dev, "invalid card type %d\n", card_type);
|
dev_err(card->dev, "invalid card type %d\n", card_type);
|
||||||
err = -EINVAL;
|
return -EINVAL;
|
||||||
goto __error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = snd_via82xx_create(card, pci, chip_type, pci->revision,
|
err = snd_via82xx_create(card, pci, chip_type, pci->revision,
|
||||||
ac97_clock, &chip);
|
ac97_clock);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto __error;
|
return err;
|
||||||
card->private_data = chip;
|
|
||||||
err = snd_via82xx_mixer_new(chip, ac97_quirk);
|
err = snd_via82xx_mixer_new(chip, ac97_quirk);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto __error;
|
return err;
|
||||||
|
|
||||||
if (chip_type == TYPE_VIA686) {
|
if (chip_type == TYPE_VIA686) {
|
||||||
err = snd_via686_pcm_new(chip);
|
err = snd_via686_pcm_new(chip);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto __error;
|
return err;
|
||||||
err = snd_via686_init_misc(chip);
|
err = snd_via686_init_misc(chip);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto __error;
|
return err;
|
||||||
} else {
|
} else {
|
||||||
if (chip_type == TYPE_VIA8233A) {
|
if (chip_type == TYPE_VIA8233A) {
|
||||||
err = snd_via8233a_pcm_new(chip);
|
err = snd_via8233a_pcm_new(chip);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto __error;
|
return err;
|
||||||
// chip->dxs_fixed = 1; /* FIXME: use 48k for DXS #3? */
|
// chip->dxs_fixed = 1; /* FIXME: use 48k for DXS #3? */
|
||||||
} else {
|
} else {
|
||||||
err = snd_via8233_pcm_new(chip);
|
err = snd_via8233_pcm_new(chip);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto __error;
|
return err;
|
||||||
if (dxs_support == VIA_DXS_48K)
|
if (dxs_support == VIA_DXS_48K)
|
||||||
chip->dxs_fixed = 1;
|
chip->dxs_fixed = 1;
|
||||||
else if (dxs_support == VIA_DXS_NO_VRA)
|
else if (dxs_support == VIA_DXS_NO_VRA)
|
||||||
|
@ -2593,7 +2549,7 @@ static int snd_via82xx_probe(struct pci_dev *pci,
|
||||||
}
|
}
|
||||||
err = snd_via8233_init_misc(chip);
|
err = snd_via8233_init_misc(chip);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto __error;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* disable interrupts */
|
/* disable interrupts */
|
||||||
|
@ -2607,28 +2563,16 @@ static int snd_via82xx_probe(struct pci_dev *pci,
|
||||||
snd_via82xx_proc_init(chip);
|
snd_via82xx_proc_init(chip);
|
||||||
|
|
||||||
err = snd_card_register(card);
|
err = snd_card_register(card);
|
||||||
if (err < 0) {
|
if (err < 0)
|
||||||
snd_card_free(card);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
|
||||||
pci_set_drvdata(pci, card);
|
pci_set_drvdata(pci, card);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
__error:
|
|
||||||
snd_card_free(card);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void snd_via82xx_remove(struct pci_dev *pci)
|
|
||||||
{
|
|
||||||
snd_card_free(pci_get_drvdata(pci));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct pci_driver via82xx_driver = {
|
static struct pci_driver via82xx_driver = {
|
||||||
.name = KBUILD_MODNAME,
|
.name = KBUILD_MODNAME,
|
||||||
.id_table = snd_via82xx_ids,
|
.id_table = snd_via82xx_ids,
|
||||||
.probe = snd_via82xx_probe,
|
.probe = snd_via82xx_probe,
|
||||||
.remove = snd_via82xx_remove,
|
|
||||||
.driver = {
|
.driver = {
|
||||||
.pm = SND_VIA82XX_PM_OPS,
|
.pm = SND_VIA82XX_PM_OPS,
|
||||||
},
|
},
|
||||||
|
|
|
@ -1048,95 +1048,57 @@ static SIMPLE_DEV_PM_OPS(snd_via82xx_pm, snd_via82xx_suspend, snd_via82xx_resume
|
||||||
#define SND_VIA82XX_PM_OPS NULL
|
#define SND_VIA82XX_PM_OPS NULL
|
||||||
#endif /* CONFIG_PM_SLEEP */
|
#endif /* CONFIG_PM_SLEEP */
|
||||||
|
|
||||||
static int snd_via82xx_free(struct via82xx_modem *chip)
|
static void snd_via82xx_free(struct snd_card *card)
|
||||||
{
|
{
|
||||||
|
struct via82xx_modem *chip = card->private_data;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (chip->irq < 0)
|
|
||||||
goto __end_hw;
|
|
||||||
/* disable interrupts */
|
/* disable interrupts */
|
||||||
for (i = 0; i < chip->num_devs; i++)
|
for (i = 0; i < chip->num_devs; i++)
|
||||||
snd_via82xx_channel_reset(chip, &chip->devs[i]);
|
snd_via82xx_channel_reset(chip, &chip->devs[i]);
|
||||||
|
|
||||||
__end_hw:
|
|
||||||
if (chip->irq >= 0)
|
|
||||||
free_irq(chip->irq, chip);
|
|
||||||
pci_release_regions(chip->pci);
|
|
||||||
pci_disable_device(chip->pci);
|
|
||||||
kfree(chip);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int snd_via82xx_dev_free(struct snd_device *device)
|
|
||||||
{
|
|
||||||
struct via82xx_modem *chip = device->device_data;
|
|
||||||
return snd_via82xx_free(chip);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int snd_via82xx_create(struct snd_card *card,
|
static int snd_via82xx_create(struct snd_card *card,
|
||||||
struct pci_dev *pci,
|
struct pci_dev *pci,
|
||||||
int chip_type,
|
int chip_type,
|
||||||
int revision,
|
int revision,
|
||||||
unsigned int ac97_clock,
|
unsigned int ac97_clock)
|
||||||
struct via82xx_modem **r_via)
|
|
||||||
{
|
{
|
||||||
struct via82xx_modem *chip;
|
struct via82xx_modem *chip = card->private_data;
|
||||||
int err;
|
int err;
|
||||||
static const struct snd_device_ops ops = {
|
|
||||||
.dev_free = snd_via82xx_dev_free,
|
|
||||||
};
|
|
||||||
|
|
||||||
err = pci_enable_device(pci);
|
err = pcim_enable_device(pci);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
chip = kzalloc(sizeof(*chip), GFP_KERNEL);
|
|
||||||
if (!chip) {
|
|
||||||
pci_disable_device(pci);
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
spin_lock_init(&chip->reg_lock);
|
spin_lock_init(&chip->reg_lock);
|
||||||
chip->card = card;
|
chip->card = card;
|
||||||
chip->pci = pci;
|
chip->pci = pci;
|
||||||
chip->irq = -1;
|
chip->irq = -1;
|
||||||
|
|
||||||
err = pci_request_regions(pci, card->driver);
|
err = pci_request_regions(pci, card->driver);
|
||||||
if (err < 0) {
|
if (err < 0)
|
||||||
kfree(chip);
|
|
||||||
pci_disable_device(pci);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
|
||||||
chip->port = pci_resource_start(pci, 0);
|
chip->port = pci_resource_start(pci, 0);
|
||||||
if (request_irq(pci->irq, snd_via82xx_interrupt, IRQF_SHARED,
|
if (devm_request_irq(&pci->dev, pci->irq, snd_via82xx_interrupt,
|
||||||
KBUILD_MODNAME, chip)) {
|
IRQF_SHARED, KBUILD_MODNAME, chip)) {
|
||||||
dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
|
dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
|
||||||
snd_via82xx_free(chip);
|
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
chip->irq = pci->irq;
|
chip->irq = pci->irq;
|
||||||
card->sync_irq = chip->irq;
|
card->sync_irq = chip->irq;
|
||||||
|
card->private_free = snd_via82xx_free;
|
||||||
if (ac97_clock >= 8000 && ac97_clock <= 48000)
|
if (ac97_clock >= 8000 && ac97_clock <= 48000)
|
||||||
chip->ac97_clock = ac97_clock;
|
chip->ac97_clock = ac97_clock;
|
||||||
|
|
||||||
err = snd_via82xx_chip_init(chip);
|
err = snd_via82xx_chip_init(chip);
|
||||||
if (err < 0) {
|
if (err < 0)
|
||||||
snd_via82xx_free(chip);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
|
||||||
|
|
||||||
err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
|
|
||||||
if (err < 0) {
|
|
||||||
snd_via82xx_free(chip);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The 8233 ac97 controller does not implement the master bit
|
/* The 8233 ac97 controller does not implement the master bit
|
||||||
* in the pci command register. IMHO this is a violation of the PCI spec.
|
* in the pci command register. IMHO this is a violation of the PCI spec.
|
||||||
* We call pci_set_master here because it does not hurt. */
|
* We call pci_set_master here because it does not hurt. */
|
||||||
pci_set_master(pci);
|
pci_set_master(pci);
|
||||||
|
|
||||||
*r_via = chip;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1150,9 +1112,11 @@ static int snd_via82xx_probe(struct pci_dev *pci,
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card);
|
err = snd_devm_card_new(&pci->dev, index, id, THIS_MODULE,
|
||||||
|
sizeof(*chip), &card);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
chip = card->private_data;
|
||||||
|
|
||||||
card_type = pci_id->driver_data;
|
card_type = pci_id->driver_data;
|
||||||
switch (card_type) {
|
switch (card_type) {
|
||||||
|
@ -1162,22 +1126,20 @@ static int snd_via82xx_probe(struct pci_dev *pci,
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dev_err(card->dev, "invalid card type %d\n", card_type);
|
dev_err(card->dev, "invalid card type %d\n", card_type);
|
||||||
err = -EINVAL;
|
return -EINVAL;
|
||||||
goto __error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = snd_via82xx_create(card, pci, chip_type, pci->revision,
|
err = snd_via82xx_create(card, pci, chip_type, pci->revision,
|
||||||
ac97_clock, &chip);
|
ac97_clock);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto __error;
|
return err;
|
||||||
card->private_data = chip;
|
|
||||||
err = snd_via82xx_mixer_new(chip);
|
err = snd_via82xx_mixer_new(chip);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto __error;
|
return err;
|
||||||
|
|
||||||
err = snd_via686_pcm_new(chip);
|
err = snd_via686_pcm_new(chip);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto __error;
|
return err;
|
||||||
|
|
||||||
/* disable interrupts */
|
/* disable interrupts */
|
||||||
for (i = 0; i < chip->num_devs; i++)
|
for (i = 0; i < chip->num_devs; i++)
|
||||||
|
@ -1189,28 +1151,16 @@ static int snd_via82xx_probe(struct pci_dev *pci,
|
||||||
snd_via82xx_proc_init(chip);
|
snd_via82xx_proc_init(chip);
|
||||||
|
|
||||||
err = snd_card_register(card);
|
err = snd_card_register(card);
|
||||||
if (err < 0) {
|
if (err < 0)
|
||||||
snd_card_free(card);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
|
||||||
pci_set_drvdata(pci, card);
|
pci_set_drvdata(pci, card);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
__error:
|
|
||||||
snd_card_free(card);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void snd_via82xx_remove(struct pci_dev *pci)
|
|
||||||
{
|
|
||||||
snd_card_free(pci_get_drvdata(pci));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct pci_driver via82xx_modem_driver = {
|
static struct pci_driver via82xx_modem_driver = {
|
||||||
.name = KBUILD_MODNAME,
|
.name = KBUILD_MODNAME,
|
||||||
.id_table = snd_via82xx_modem_ids,
|
.id_table = snd_via82xx_modem_ids,
|
||||||
.probe = snd_via82xx_probe,
|
.probe = snd_via82xx_probe,
|
||||||
.remove = snd_via82xx_remove,
|
|
||||||
.driver = {
|
.driver = {
|
||||||
.pm = SND_VIA82XX_PM_OPS,
|
.pm = SND_VIA82XX_PM_OPS,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue