ALSA: wavefront: Allocate resources with device-managed APIs
This patch converts the resource management in ISA wavefront 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-72-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
bddc2ef132
commit
f082b1ad39
@ -308,18 +308,6 @@ static struct snd_rawmidi *snd_wavefront_new_midi(struct snd_card *card,
|
|||||||
return rmidi;
|
return rmidi;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
snd_wavefront_free(struct snd_card *card)
|
|
||||||
{
|
|
||||||
snd_wavefront_card_t *acard = (snd_wavefront_card_t *)card->private_data;
|
|
||||||
|
|
||||||
if (acard) {
|
|
||||||
release_and_free_resource(acard->wavefront.res_base);
|
|
||||||
if (acard->wavefront.irq > 0)
|
|
||||||
free_irq(acard->wavefront.irq, (void *)acard);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int snd_wavefront_card_new(struct device *pdev, int dev,
|
static int snd_wavefront_card_new(struct device *pdev, int dev,
|
||||||
struct snd_card **cardp)
|
struct snd_card **cardp)
|
||||||
{
|
{
|
||||||
@ -327,8 +315,8 @@ static int snd_wavefront_card_new(struct device *pdev, int dev,
|
|||||||
snd_wavefront_card_t *acard;
|
snd_wavefront_card_t *acard;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = snd_card_new(pdev, index[dev], id[dev], THIS_MODULE,
|
err = snd_devm_card_new(pdev, index[dev], id[dev], THIS_MODULE,
|
||||||
sizeof(snd_wavefront_card_t), &card);
|
sizeof(snd_wavefront_card_t), &card);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
@ -339,7 +327,6 @@ static int snd_wavefront_card_new(struct device *pdev, int dev,
|
|||||||
spin_lock_init(&acard->wavefront.midi.open);
|
spin_lock_init(&acard->wavefront.midi.open);
|
||||||
spin_lock_init(&acard->wavefront.midi.virtual);
|
spin_lock_init(&acard->wavefront.midi.virtual);
|
||||||
acard->wavefront.card = card;
|
acard->wavefront.card = card;
|
||||||
card->private_free = snd_wavefront_free;
|
|
||||||
|
|
||||||
*cardp = card;
|
*cardp = card;
|
||||||
return 0;
|
return 0;
|
||||||
@ -394,15 +381,17 @@ snd_wavefront_probe (struct snd_card *card, int dev)
|
|||||||
|
|
||||||
/* ------- ICS2115 Wavetable synth ------- */
|
/* ------- ICS2115 Wavetable synth ------- */
|
||||||
|
|
||||||
acard->wavefront.res_base = request_region(ics2115_port[dev], 16,
|
acard->wavefront.res_base =
|
||||||
"ICS2115");
|
devm_request_region(card->dev, ics2115_port[dev], 16,
|
||||||
|
"ICS2115");
|
||||||
if (acard->wavefront.res_base == NULL) {
|
if (acard->wavefront.res_base == NULL) {
|
||||||
snd_printk(KERN_ERR "unable to grab ICS2115 i/o region 0x%lx-0x%lx\n",
|
snd_printk(KERN_ERR "unable to grab ICS2115 i/o region 0x%lx-0x%lx\n",
|
||||||
ics2115_port[dev], ics2115_port[dev] + 16 - 1);
|
ics2115_port[dev], ics2115_port[dev] + 16 - 1);
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
if (request_irq(ics2115_irq[dev], snd_wavefront_ics2115_interrupt,
|
if (devm_request_irq(card->dev, ics2115_irq[dev],
|
||||||
0, "ICS2115", acard)) {
|
snd_wavefront_ics2115_interrupt,
|
||||||
|
0, "ICS2115", acard)) {
|
||||||
snd_printk(KERN_ERR "unable to use ICS2115 IRQ %d\n", ics2115_irq[dev]);
|
snd_printk(KERN_ERR "unable to use ICS2115 IRQ %d\n", ics2115_irq[dev]);
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
@ -556,27 +545,18 @@ static int snd_wavefront_isa_probe(struct device *pdev,
|
|||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
err = snd_wavefront_probe(card, dev);
|
err = snd_wavefront_probe(card, dev);
|
||||||
if (err < 0) {
|
if (err < 0)
|
||||||
snd_card_free(card);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
|
||||||
|
|
||||||
dev_set_drvdata(pdev, card);
|
dev_set_drvdata(pdev, card);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void snd_wavefront_isa_remove(struct device *devptr,
|
|
||||||
unsigned int dev)
|
|
||||||
{
|
|
||||||
snd_card_free(dev_get_drvdata(devptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
#define DEV_NAME "wavefront"
|
#define DEV_NAME "wavefront"
|
||||||
|
|
||||||
static struct isa_driver snd_wavefront_driver = {
|
static struct isa_driver snd_wavefront_driver = {
|
||||||
.match = snd_wavefront_isa_match,
|
.match = snd_wavefront_isa_match,
|
||||||
.probe = snd_wavefront_isa_probe,
|
.probe = snd_wavefront_isa_probe,
|
||||||
.remove = snd_wavefront_isa_remove,
|
|
||||||
/* FIXME: suspend, resume */
|
/* FIXME: suspend, resume */
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = DEV_NAME
|
.name = DEV_NAME
|
||||||
@ -606,7 +586,6 @@ static int snd_wavefront_pnp_detect(struct pnp_card_link *pcard,
|
|||||||
if (snd_wavefront_pnp (dev, card->private_data, pcard, pid) < 0) {
|
if (snd_wavefront_pnp (dev, card->private_data, pcard, pid) < 0) {
|
||||||
if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) {
|
if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) {
|
||||||
snd_printk (KERN_ERR "isapnp detection failed\n");
|
snd_printk (KERN_ERR "isapnp detection failed\n");
|
||||||
snd_card_free (card);
|
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -620,18 +599,11 @@ static int snd_wavefront_pnp_detect(struct pnp_card_link *pcard,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void snd_wavefront_pnp_remove(struct pnp_card_link *pcard)
|
|
||||||
{
|
|
||||||
snd_card_free(pnp_get_card_drvdata(pcard));
|
|
||||||
pnp_set_card_drvdata(pcard, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct pnp_card_driver wavefront_pnpc_driver = {
|
static struct pnp_card_driver wavefront_pnpc_driver = {
|
||||||
.flags = PNP_DRIVER_RES_DISABLE,
|
.flags = PNP_DRIVER_RES_DISABLE,
|
||||||
.name = "wavefront",
|
.name = "wavefront",
|
||||||
.id_table = snd_wavefront_pnpids,
|
.id_table = snd_wavefront_pnpids,
|
||||||
.probe = snd_wavefront_pnp_detect,
|
.probe = snd_wavefront_pnp_detect,
|
||||||
.remove = snd_wavefront_pnp_remove,
|
|
||||||
/* FIXME: suspend,resume */
|
/* FIXME: suspend,resume */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user