Skip to content

Commit

Permalink
ALSA: azt2320: Allocate resources with device-managed APIs
Browse files Browse the repository at this point in the history
This patch converts the resource management in ISA azt2320 driver with
devres as a clean up.  Each manual resource management is converted
with the corresponding devres helper.  The remove callback became
superfluous and dropped.

This should give no user-visible functional changes.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
tiwai committed Jul 19, 2021
1 parent 749cadc commit 39c4f9a
Showing 1 changed file with 12 additions and 37 deletions.
49 changes: 12 additions & 37 deletions sound/isa/azt2320.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,54 +169,42 @@ static int snd_card_azt2320_probe(int dev,
struct snd_wss *chip;
struct snd_opl3 *opl3;

error = snd_card_new(&pcard->card->dev,
index[dev], id[dev], THIS_MODULE,
sizeof(struct snd_card_azt2320), &card);
error = snd_devm_card_new(&pcard->card->dev,
index[dev], id[dev], THIS_MODULE,
sizeof(struct snd_card_azt2320), &card);
if (error < 0)
return error;
acard = card->private_data;

error = snd_card_azt2320_pnp(dev, acard, pcard, pid);
if (error) {
snd_card_free(card);
if (error)
return error;
}

error = snd_card_azt2320_enable_wss(port[dev]);
if (error) {
snd_card_free(card);
if (error)
return error;
}

error = snd_wss_create(card, wss_port[dev], -1,
irq[dev],
dma1[dev], dma2[dev],
WSS_HW_DETECT, 0, &chip);
if (error < 0) {
snd_card_free(card);
if (error < 0)
return error;
}

strcpy(card->driver, "AZT2320");
strcpy(card->shortname, "Aztech AZT2320");
sprintf(card->longname, "%s, WSS at 0x%lx, irq %i, dma %i&%i",
card->shortname, chip->port, irq[dev], dma1[dev], dma2[dev]);

error = snd_wss_pcm(chip, 0);
if (error < 0) {
snd_card_free(card);
if (error < 0)
return error;
}
error = snd_wss_mixer(chip);
if (error < 0) {
snd_card_free(card);
if (error < 0)
return error;
}
error = snd_wss_timer(chip, 0);
if (error < 0) {
snd_card_free(card);
if (error < 0)
return error;
}

if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) {
if (snd_mpu401_uart_new(card, 0, MPU401_HW_AZT2320,
Expand All @@ -233,23 +221,17 @@ static int snd_card_azt2320_probe(int dev,
fm_port[dev], fm_port[dev] + 2);
} else {
error = snd_opl3_timer_new(opl3, 1, 2);
if (error < 0) {
snd_card_free(card);
if (error < 0)
return error;
}
error = snd_opl3_hwdep_new(opl3, 0, 1, NULL);
if (error < 0) {
snd_card_free(card);
if (error < 0)
return error;
}
}
}

error = snd_card_register(card);
if (error < 0) {
snd_card_free(card);
if (error < 0)
return error;
}
pnp_set_card_drvdata(pcard, card);
return 0;
}
Expand All @@ -275,12 +257,6 @@ static int snd_azt2320_pnp_detect(struct pnp_card_link *card,
return -ENODEV;
}

static void snd_azt2320_pnp_remove(struct pnp_card_link *pcard)
{
snd_card_free(pnp_get_card_drvdata(pcard));
pnp_set_card_drvdata(pcard, NULL);
}

#ifdef CONFIG_PM
static int snd_azt2320_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state)
{
Expand Down Expand Up @@ -310,7 +286,6 @@ static struct pnp_card_driver azt2320_pnpc_driver = {
.name = "azt2320",
.id_table = snd_azt2320_pnpids,
.probe = snd_azt2320_pnp_detect,
.remove = snd_azt2320_pnp_remove,
#ifdef CONFIG_PM
.suspend = snd_azt2320_pnp_suspend,
.resume = snd_azt2320_pnp_resume,
Expand Down

0 comments on commit 39c4f9a

Please sign in to comment.