Skip to content

Commit

Permalink
ALSA: gus: Fix repeated probe for ISA interwave card
Browse files Browse the repository at this point in the history
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: 5b88da3 ("ALSA: gus: Allocate resources with device-managed APIs")
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
tiwai committed Sep 7, 2021
1 parent 9d2e19e commit c5433f0
Showing 1 changed file with 31 additions and 30 deletions.
61 changes: 31 additions & 30 deletions sound/isa/gus/interwave.c
Original file line number Diff line number Diff line change
Expand Up @@ -618,12 +618,19 @@ static int snd_interwave_card_new(struct device *pdev, int dev,
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;
struct snd_interwave *iwcard = card->private_data;
struct snd_wss *wss;
struct snd_gus_card *gus;
#ifdef SNDRV_STB
struct snd_i2c_bus *i2c_bus;
#endif
Expand All @@ -634,14 +641,6 @@ static int snd_interwave_probe(struct snd_card *card, int dev)
xdma1 = dma1[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
#ifdef SNDRV_STB
, &i2c_bus
Expand Down Expand Up @@ -757,22 +756,6 @@ static int snd_interwave_probe(struct snd_card *card, int dev)
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,
unsigned int dev)
{
Expand All @@ -788,6 +771,8 @@ static int snd_interwave_isa_match(struct device *pdev,
static int snd_interwave_isa_probe(struct device *pdev,
unsigned int dev)
{
struct snd_card *card;
struct snd_gus_card *gus;
int err;
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};
Expand All @@ -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)
return snd_interwave_isa_probe1(dev, pdev);
err = snd_interwave_probe_gus(card, dev, &gus);
else {
static const long possible_ports[] = {0x210, 0x220, 0x230, 0x240, 0x250, 0x260};
int i;
for (i = 0; i < ARRAY_SIZE(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)
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 = {
Expand All @@ -844,6 +841,7 @@ static int snd_interwave_pnp_detect(struct pnp_card_link *pcard,
{
static int dev;
struct snd_card *card;
struct snd_gus_card *gus;
int res;

for ( ; dev < SNDRV_CARDS; dev++) {
Expand All @@ -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);
if (res < 0)
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)
return res;
pnp_set_card_drvdata(pcard, card);
Expand Down

0 comments on commit c5433f0

Please sign in to comment.