forked from Minki/linux
ALSA: es1688: Allocate resources with device-managed APIs
This patch converts the resource management in ISA es1688 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/20210715075941.23332-63-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
4287864eb0
commit
1bb11c1c7f
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
struct snd_es1688 {
|
struct snd_es1688 {
|
||||||
unsigned long port; /* port of ESS chip */
|
unsigned long port; /* port of ESS chip */
|
||||||
struct resource *res_port;
|
|
||||||
unsigned long mpu_port; /* MPU-401 port of ESS chip */
|
unsigned long mpu_port; /* MPU-401 port of ESS chip */
|
||||||
int irq; /* IRQ number of ESS chip */
|
int irq; /* IRQ number of ESS chip */
|
||||||
int mpu_irq; /* MPU IRQ */
|
int mpu_irq; /* MPU IRQ */
|
||||||
|
@ -166,36 +166,27 @@ static int snd_es1688_isa_probe(struct device *dev, unsigned int n)
|
|||||||
struct snd_card *card;
|
struct snd_card *card;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
error = snd_card_new(dev, index[n], id[n], THIS_MODULE,
|
error = snd_devm_card_new(dev, index[n], id[n], THIS_MODULE,
|
||||||
sizeof(struct snd_es1688), &card);
|
sizeof(struct snd_es1688), &card);
|
||||||
if (error < 0)
|
if (error < 0)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
error = snd_es1688_legacy_create(card, dev, n);
|
error = snd_es1688_legacy_create(card, dev, n);
|
||||||
if (error < 0)
|
if (error < 0)
|
||||||
goto out;
|
return error;
|
||||||
|
|
||||||
error = snd_es1688_probe(card, n);
|
error = snd_es1688_probe(card, n);
|
||||||
if (error < 0)
|
if (error < 0)
|
||||||
goto out;
|
return error;
|
||||||
|
|
||||||
dev_set_drvdata(dev, card);
|
dev_set_drvdata(dev, card);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
out:
|
|
||||||
snd_card_free(card);
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void snd_es1688_isa_remove(struct device *dev, unsigned int n)
|
|
||||||
{
|
|
||||||
snd_card_free(dev_get_drvdata(dev));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct isa_driver snd_es1688_driver = {
|
static struct isa_driver snd_es1688_driver = {
|
||||||
.match = snd_es1688_match,
|
.match = snd_es1688_match,
|
||||||
.probe = snd_es1688_isa_probe,
|
.probe = snd_es1688_isa_probe,
|
||||||
.remove = snd_es1688_isa_remove,
|
|
||||||
#if 0 /* FIXME */
|
#if 0 /* FIXME */
|
||||||
.suspend = snd_es1688_suspend,
|
.suspend = snd_es1688_suspend,
|
||||||
.resume = snd_es1688_resume,
|
.resume = snd_es1688_resume,
|
||||||
@ -249,22 +240,18 @@ static int snd_es968_pnp_detect(struct pnp_card_link *pcard,
|
|||||||
if (dev == SNDRV_CARDS)
|
if (dev == SNDRV_CARDS)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
error = snd_card_new(&pcard->card->dev,
|
error = snd_devm_card_new(&pcard->card->dev,
|
||||||
index[dev], id[dev], THIS_MODULE,
|
index[dev], id[dev], THIS_MODULE,
|
||||||
sizeof(struct snd_es1688), &card);
|
sizeof(struct snd_es1688), &card);
|
||||||
if (error < 0)
|
if (error < 0)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
error = snd_card_es968_pnp(card, dev, pcard, pid);
|
error = snd_card_es968_pnp(card, dev, pcard, pid);
|
||||||
if (error < 0) {
|
if (error < 0)
|
||||||
snd_card_free(card);
|
|
||||||
return error;
|
return error;
|
||||||
}
|
|
||||||
error = snd_es1688_probe(card, dev);
|
error = snd_es1688_probe(card, dev);
|
||||||
if (error < 0) {
|
if (error < 0)
|
||||||
snd_card_free(card);
|
|
||||||
return error;
|
return error;
|
||||||
}
|
|
||||||
pnp_set_card_drvdata(pcard, card);
|
pnp_set_card_drvdata(pcard, card);
|
||||||
snd_es968_pnp_is_probed = 1;
|
snd_es968_pnp_is_probed = 1;
|
||||||
return 0;
|
return 0;
|
||||||
@ -272,8 +259,6 @@ static int snd_es968_pnp_detect(struct pnp_card_link *pcard,
|
|||||||
|
|
||||||
static void snd_es968_pnp_remove(struct pnp_card_link *pcard)
|
static void snd_es968_pnp_remove(struct pnp_card_link *pcard)
|
||||||
{
|
{
|
||||||
snd_card_free(pnp_get_card_drvdata(pcard));
|
|
||||||
pnp_set_card_drvdata(pcard, NULL);
|
|
||||||
snd_es968_pnp_is_probed = 0;
|
snd_es968_pnp_is_probed = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -580,13 +580,6 @@ static int snd_es1688_free(struct snd_es1688 *chip)
|
|||||||
{
|
{
|
||||||
if (chip->hardware != ES1688_HW_UNDEF)
|
if (chip->hardware != ES1688_HW_UNDEF)
|
||||||
snd_es1688_init(chip, 0);
|
snd_es1688_init(chip, 0);
|
||||||
release_and_free_resource(chip->res_port);
|
|
||||||
if (chip->irq >= 0)
|
|
||||||
free_irq(chip->irq, (void *) chip);
|
|
||||||
if (chip->dma8 >= 0) {
|
|
||||||
disable_dma(chip->dma8);
|
|
||||||
free_dma(chip->dma8);
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -624,26 +617,25 @@ int snd_es1688_create(struct snd_card *card,
|
|||||||
chip->dma8 = -1;
|
chip->dma8 = -1;
|
||||||
chip->hardware = ES1688_HW_UNDEF;
|
chip->hardware = ES1688_HW_UNDEF;
|
||||||
|
|
||||||
chip->res_port = request_region(port + 4, 12, "ES1688");
|
if (!devm_request_region(card->dev, port + 4, 12, "ES1688")) {
|
||||||
if (chip->res_port == NULL) {
|
|
||||||
snd_printk(KERN_ERR "es1688: can't grab port 0x%lx\n", port + 4);
|
snd_printk(KERN_ERR "es1688: can't grab port 0x%lx\n", port + 4);
|
||||||
err = -EBUSY;
|
return -EBUSY;
|
||||||
goto exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = request_irq(irq, snd_es1688_interrupt, 0, "ES1688", (void *) chip);
|
err = devm_request_irq(card->dev, irq, snd_es1688_interrupt, 0,
|
||||||
|
"ES1688", (void *) chip);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
snd_printk(KERN_ERR "es1688: can't grab IRQ %d\n", irq);
|
snd_printk(KERN_ERR "es1688: can't grab IRQ %d\n", irq);
|
||||||
goto exit;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
chip->irq = irq;
|
chip->irq = irq;
|
||||||
card->sync_irq = chip->irq;
|
card->sync_irq = chip->irq;
|
||||||
err = request_dma(dma8, "ES1688");
|
err = snd_devm_request_dma(card->dev, dma8, "ES1688");
|
||||||
|
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
snd_printk(KERN_ERR "es1688: can't grab DMA8 %d\n", dma8);
|
snd_printk(KERN_ERR "es1688: can't grab DMA8 %d\n", dma8);
|
||||||
goto exit;
|
return err;
|
||||||
}
|
}
|
||||||
chip->dma8 = dma8;
|
chip->dma8 = dma8;
|
||||||
|
|
||||||
@ -659,17 +651,14 @@ int snd_es1688_create(struct snd_card *card,
|
|||||||
|
|
||||||
err = snd_es1688_probe(chip);
|
err = snd_es1688_probe(chip);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto exit;
|
return err;
|
||||||
|
|
||||||
err = snd_es1688_init(chip, 1);
|
err = snd_es1688_init(chip, 1);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto exit;
|
return err;
|
||||||
|
|
||||||
/* Register device */
|
/* Register device */
|
||||||
err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
|
err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
|
||||||
exit:
|
|
||||||
if (err)
|
|
||||||
snd_es1688_free(chip);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user