ALSA: gus: Fix repeated probe for ISA interwave card

The legacy ISA probe tries to probe the card repeatedly, and this
would conflict with the refactoring using devres.  Put the card
creation out of the loop and only probe GUS object repeatedly.

Fixes: 5b88da3c80 ("ALSA: gus: Allocate resources with device-managed APIs")
Link: https://lore.kernel.org/r/20210907093930.29009-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Takashi Iwai 2021-09-07 11:39:30 +02:00
parent 9d2e19e349
commit c5433f026b
1 changed files with 31 additions and 30 deletions

View File

@ -618,12 +618,19 @@ static int snd_interwave_card_new(struct device *pdev, int dev,
return 0; return 0;
} }
static int snd_interwave_probe(struct snd_card *card, int dev) static int snd_interwave_probe_gus(struct snd_card *card, int dev,
struct snd_gus_card **gusp)
{
return snd_gus_create(card, port[dev], -irq[dev], dma1[dev], dma2[dev],
0, 32, pcm_channels[dev], effect[dev], gusp);
}
static int snd_interwave_probe(struct snd_card *card, int dev,
struct snd_gus_card *gus)
{ {
int xirq, xdma1, xdma2; int xirq, xdma1, xdma2;
struct snd_interwave *iwcard = card->private_data; struct snd_interwave *iwcard = card->private_data;
struct snd_wss *wss; struct snd_wss *wss;
struct snd_gus_card *gus;
#ifdef SNDRV_STB #ifdef SNDRV_STB
struct snd_i2c_bus *i2c_bus; struct snd_i2c_bus *i2c_bus;
#endif #endif
@ -634,14 +641,6 @@ static int snd_interwave_probe(struct snd_card *card, int dev)
xdma1 = dma1[dev]; xdma1 = dma1[dev];
xdma2 = dma2[dev]; xdma2 = dma2[dev];
err = snd_gus_create(card,
port[dev],
-xirq, xdma1, xdma2,
0, 32,
pcm_channels[dev], effect[dev], &gus);
if (err < 0)
return err;
err = snd_interwave_detect(iwcard, gus, dev err = snd_interwave_detect(iwcard, gus, dev
#ifdef SNDRV_STB #ifdef SNDRV_STB
, &i2c_bus , &i2c_bus
@ -757,22 +756,6 @@ static int snd_interwave_probe(struct snd_card *card, int dev)
return 0; return 0;
} }
static int snd_interwave_isa_probe1(int dev, struct device *devptr)
{
struct snd_card *card;
int err;
err = snd_interwave_card_new(devptr, dev, &card);
if (err < 0)
return err;
err = snd_interwave_probe(card, dev);
if (err < 0)
return err;
dev_set_drvdata(devptr, card);
return 0;
}
static int snd_interwave_isa_match(struct device *pdev, static int snd_interwave_isa_match(struct device *pdev,
unsigned int dev) unsigned int dev)
{ {
@ -788,6 +771,8 @@ static int snd_interwave_isa_match(struct device *pdev,
static int snd_interwave_isa_probe(struct device *pdev, static int snd_interwave_isa_probe(struct device *pdev,
unsigned int dev) unsigned int dev)
{ {
struct snd_card *card;
struct snd_gus_card *gus;
int err; int err;
static const int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; static const int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1};
static const int possible_dmas[] = {0, 1, 3, 5, 6, 7, -1}; static const int possible_dmas[] = {0, 1, 3, 5, 6, 7, -1};
@ -814,19 +799,31 @@ static int snd_interwave_isa_probe(struct device *pdev,
} }
} }
err = snd_interwave_card_new(pdev, dev, &card);
if (err < 0)
return err;
if (port[dev] != SNDRV_AUTO_PORT) if (port[dev] != SNDRV_AUTO_PORT)
return snd_interwave_isa_probe1(dev, pdev); err = snd_interwave_probe_gus(card, dev, &gus);
else { else {
static const long possible_ports[] = {0x210, 0x220, 0x230, 0x240, 0x250, 0x260}; static const long possible_ports[] = {0x210, 0x220, 0x230, 0x240, 0x250, 0x260};
int i; int i;
for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { for (i = 0; i < ARRAY_SIZE(possible_ports); i++) {
port[dev] = possible_ports[i]; port[dev] = possible_ports[i];
err = snd_interwave_isa_probe1(dev, pdev); err = snd_interwave_probe_gus(card, dev, &gus);
if (! err) if (! err)
return 0; return 0;
} }
return err;
} }
if (err < 0)
return err;
err = snd_interwave_probe(card, dev, gus);
if (err < 0)
return err;
dev_set_drvdata(pdev, card);
return 0;
} }
static struct isa_driver snd_interwave_driver = { static struct isa_driver snd_interwave_driver = {
@ -844,6 +841,7 @@ static int snd_interwave_pnp_detect(struct pnp_card_link *pcard,
{ {
static int dev; static int dev;
struct snd_card *card; struct snd_card *card;
struct snd_gus_card *gus;
int res; int res;
for ( ; dev < SNDRV_CARDS; dev++) { for ( ; dev < SNDRV_CARDS; dev++) {
@ -860,7 +858,10 @@ static int snd_interwave_pnp_detect(struct pnp_card_link *pcard,
res = snd_interwave_pnp(dev, card->private_data, pcard, pid); res = snd_interwave_pnp(dev, card->private_data, pcard, pid);
if (res < 0) if (res < 0)
return res; return res;
res = snd_interwave_probe(card, dev); res = snd_interwave_probe_gus(card, dev, &gus);
if (res < 0)
return res;
res = snd_interwave_probe(card, dev, gus);
if (res < 0) if (res < 0)
return res; return res;
pnp_set_card_drvdata(pcard, card); pnp_set_card_drvdata(pcard, card);