Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: es1688: Avoid devres management for es1688 object creation

The recent refactoring of es1688 object creation with the use of
devres caused a problem with the non-PnP probe of GUS driver, as it
tries to probe multiple times with different parameters That is, this
object needs the immediate resource release and the devres doesn't fit
for it.

This patch reverts partially the commit for restoring the classic
resource management for es1688 object.

Fixes: 1bb11c1c7f6e ("ALSA: es1688: Allocate resources with device-managed APIs")
Reported-by: kernel test robot <oliver.sang@intel.com>
Link: https://lore.kernel.org/r/20210805032513.GA30485@xsang-OptiPlex-9020
Link: https://lore.kernel.org/r/20210805062148.30951-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>

+21 -9
+1
include/sound/es1688.h
··· 18 18 19 19 struct snd_es1688 { 20 20 unsigned long port; /* port of ESS chip */ 21 + struct resource *res_port; 21 22 unsigned long mpu_port; /* MPU-401 port of ESS chip */ 22 23 int irq; /* IRQ number of ESS chip */ 23 24 int mpu_irq; /* MPU IRQ */
+20 -9
sound/isa/es1688/es1688_lib.c
··· 580 580 { 581 581 if (chip->hardware != ES1688_HW_UNDEF) 582 582 snd_es1688_init(chip, 0); 583 + release_and_free_resource(chip->res_port); 584 + if (chip->irq >= 0) 585 + free_irq(chip->irq, (void *) chip); 586 + if (chip->dma8 >= 0) { 587 + disable_dma(chip->dma8); 588 + free_dma(chip->dma8); 589 + } 583 590 return 0; 584 591 } 585 592 ··· 624 617 chip->dma8 = -1; 625 618 chip->hardware = ES1688_HW_UNDEF; 626 619 627 - if (!devm_request_region(card->dev, port + 4, 12, "ES1688")) { 620 + chip->res_port = request_region(port + 4, 12, "ES1688"); 621 + if (chip->res_port == NULL) { 628 622 snd_printk(KERN_ERR "es1688: can't grab port 0x%lx\n", port + 4); 629 - return -EBUSY; 623 + err = -EBUSY; 624 + goto exit; 630 625 } 631 626 632 - err = devm_request_irq(card->dev, irq, snd_es1688_interrupt, 0, 633 - "ES1688", (void *) chip); 627 + err = request_irq(irq, snd_es1688_interrupt, 0, "ES1688", (void *) chip); 634 628 if (err < 0) { 635 629 snd_printk(KERN_ERR "es1688: can't grab IRQ %d\n", irq); 636 - return err; 630 + goto exit; 637 631 } 638 632 639 633 chip->irq = irq; 640 634 card->sync_irq = chip->irq; 641 - err = snd_devm_request_dma(card->dev, dma8, "ES1688"); 635 + err = request_dma(dma8, "ES1688"); 642 636 643 637 if (err < 0) { 644 638 snd_printk(KERN_ERR "es1688: can't grab DMA8 %d\n", dma8); 645 - return err; 639 + goto exit; 646 640 } 647 641 chip->dma8 = dma8; 648 642 ··· 659 651 660 652 err = snd_es1688_probe(chip); 661 653 if (err < 0) 662 - return err; 654 + goto exit; 663 655 664 656 err = snd_es1688_init(chip, 1); 665 657 if (err < 0) 666 - return err; 658 + goto exit; 667 659 668 660 /* Register device */ 669 661 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); 662 + exit: 663 + if (err) 664 + snd_es1688_free(chip); 670 665 return err; 671 666 } 672 667