Skip to content

Commit c5433f0

Browse files
committed
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: 5b88da3 ("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>
1 parent 9d2e19e commit c5433f0

File tree

1 file changed

+31
-30
lines changed

1 file changed

+31
-30
lines changed

sound/isa/gus/interwave.c

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -618,12 +618,19 @@ static int snd_interwave_card_new(struct device *pdev, int dev,
618618
return 0;
619619
}
620620

621-
static int snd_interwave_probe(struct snd_card *card, int dev)
621+
static int snd_interwave_probe_gus(struct snd_card *card, int dev,
622+
struct snd_gus_card **gusp)
623+
{
624+
return snd_gus_create(card, port[dev], -irq[dev], dma1[dev], dma2[dev],
625+
0, 32, pcm_channels[dev], effect[dev], gusp);
626+
}
627+
628+
static int snd_interwave_probe(struct snd_card *card, int dev,
629+
struct snd_gus_card *gus)
622630
{
623631
int xirq, xdma1, xdma2;
624632
struct snd_interwave *iwcard = card->private_data;
625633
struct snd_wss *wss;
626-
struct snd_gus_card *gus;
627634
#ifdef SNDRV_STB
628635
struct snd_i2c_bus *i2c_bus;
629636
#endif
@@ -634,14 +641,6 @@ static int snd_interwave_probe(struct snd_card *card, int dev)
634641
xdma1 = dma1[dev];
635642
xdma2 = dma2[dev];
636643

637-
err = snd_gus_create(card,
638-
port[dev],
639-
-xirq, xdma1, xdma2,
640-
0, 32,
641-
pcm_channels[dev], effect[dev], &gus);
642-
if (err < 0)
643-
return err;
644-
645644
err = snd_interwave_detect(iwcard, gus, dev
646645
#ifdef SNDRV_STB
647646
, &i2c_bus
@@ -757,22 +756,6 @@ static int snd_interwave_probe(struct snd_card *card, int dev)
757756
return 0;
758757
}
759758

760-
static int snd_interwave_isa_probe1(int dev, struct device *devptr)
761-
{
762-
struct snd_card *card;
763-
int err;
764-
765-
err = snd_interwave_card_new(devptr, dev, &card);
766-
if (err < 0)
767-
return err;
768-
769-
err = snd_interwave_probe(card, dev);
770-
if (err < 0)
771-
return err;
772-
dev_set_drvdata(devptr, card);
773-
return 0;
774-
}
775-
776759
static int snd_interwave_isa_match(struct device *pdev,
777760
unsigned int dev)
778761
{
@@ -788,6 +771,8 @@ static int snd_interwave_isa_match(struct device *pdev,
788771
static int snd_interwave_isa_probe(struct device *pdev,
789772
unsigned int dev)
790773
{
774+
struct snd_card *card;
775+
struct snd_gus_card *gus;
791776
int err;
792777
static const int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1};
793778
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,
814799
}
815800
}
816801

802+
err = snd_interwave_card_new(pdev, dev, &card);
803+
if (err < 0)
804+
return err;
805+
817806
if (port[dev] != SNDRV_AUTO_PORT)
818-
return snd_interwave_isa_probe1(dev, pdev);
807+
err = snd_interwave_probe_gus(card, dev, &gus);
819808
else {
820809
static const long possible_ports[] = {0x210, 0x220, 0x230, 0x240, 0x250, 0x260};
821810
int i;
822811
for (i = 0; i < ARRAY_SIZE(possible_ports); i++) {
823812
port[dev] = possible_ports[i];
824-
err = snd_interwave_isa_probe1(dev, pdev);
813+
err = snd_interwave_probe_gus(card, dev, &gus);
825814
if (! err)
826815
return 0;
827816
}
828-
return err;
829817
}
818+
if (err < 0)
819+
return err;
820+
821+
err = snd_interwave_probe(card, dev, gus);
822+
if (err < 0)
823+
return err;
824+
825+
dev_set_drvdata(pdev, card);
826+
return 0;
830827
}
831828

832829
static struct isa_driver snd_interwave_driver = {
@@ -844,6 +841,7 @@ static int snd_interwave_pnp_detect(struct pnp_card_link *pcard,
844841
{
845842
static int dev;
846843
struct snd_card *card;
844+
struct snd_gus_card *gus;
847845
int res;
848846

849847
for ( ; dev < SNDRV_CARDS; dev++) {
@@ -860,7 +858,10 @@ static int snd_interwave_pnp_detect(struct pnp_card_link *pcard,
860858
res = snd_interwave_pnp(dev, card->private_data, pcard, pid);
861859
if (res < 0)
862860
return res;
863-
res = snd_interwave_probe(card, dev);
861+
res = snd_interwave_probe_gus(card, dev, &gus);
862+
if (res < 0)
863+
return res;
864+
res = snd_interwave_probe(card, dev, gus);
864865
if (res < 0)
865866
return res;
866867
pnp_set_card_drvdata(pcard, card);

0 commit comments

Comments
 (0)