Linux 6.9-rc4
[sfrench/cifs-2.6.git] / sound / isa / sb / sb8.c
index ed3a87ebe3f4119cc0698dc3852471891826c03a..e5ef1777161fed7fdacbf9a4dd07e764893646af 100644 (file)
@@ -54,15 +54,6 @@ static irqreturn_t snd_sb8_interrupt(int irq, void *dev_id)
        }
 }
 
-static void snd_sb8_free(struct snd_card *card)
-{
-       struct snd_sb8 *acard = card->private_data;
-
-       if (acard == NULL)
-               return;
-       release_and_free_resource(acard->fm_res);
-}
-
 static int snd_sb8_match(struct device *pdev, unsigned int dev)
 {
        if (!enable[dev])
@@ -86,28 +77,26 @@ static int snd_sb8_probe(struct device *pdev, unsigned int dev)
        struct snd_opl3 *opl3;
        int err;
 
-       err = snd_card_new(pdev, index[dev], id[dev], THIS_MODULE,
-                          sizeof(struct snd_sb8), &card);
+       err = snd_devm_card_new(pdev, index[dev], id[dev], THIS_MODULE,
+                               sizeof(struct snd_sb8), &card);
        if (err < 0)
                return err;
        acard = card->private_data;
-       card->private_free = snd_sb8_free;
 
        /*
         * Block the 0x388 port to avoid PnP conflicts.
         * No need to check this value after request_region,
         * as we never do anything with it.
         */
-       acard->fm_res = request_region(0x388, 4, "SoundBlaster FM");
+       acard->fm_res = devm_request_region(card->dev, 0x388, 4,
+                                           "SoundBlaster FM");
 
        if (port[dev] != SNDRV_AUTO_PORT) {
-               if ((err = snd_sbdsp_create(card, port[dev], irq[dev],
-                                           snd_sb8_interrupt,
-                                           dma8[dev],
-                                           -1,
-                                           SB_HW_AUTO,
-                                           &chip)) < 0)
-                       goto _err;
+               err = snd_sbdsp_create(card, port[dev], irq[dev],
+                                      snd_sb8_interrupt, dma8[dev],
+                                      -1, SB_HW_AUTO, &chip);
+               if (err < 0)
+                       return err;
        } else {
                /* auto-probe legacy ports */
                static const unsigned long possible_ports[] = {
@@ -127,10 +116,8 @@ static int snd_sb8_probe(struct device *pdev, unsigned int dev)
                                break;
                        }
                }
-               if (i >= ARRAY_SIZE(possible_ports)) {
-                       err = -EINVAL;
-                       goto _err;
-               }
+               if (i >= ARRAY_SIZE(possible_ports))
+                       return -EINVAL;
        }
        acard->chip = chip;
                        
@@ -141,37 +128,39 @@ static int snd_sb8_probe(struct device *pdev, unsigned int dev)
                else
                        snd_printk(KERN_WARNING "SB 16 chip detected at 0x%lx, try snd-sb16 module\n",
                                   port[dev]);
-               err = -ENODEV;
-               goto _err;
+               return -ENODEV;
        }
 
-       if ((err = snd_sb8dsp_pcm(chip, 0)) < 0)
-               goto _err;
+       err = snd_sb8dsp_pcm(chip, 0);
+       if (err < 0)
+               return err;
 
-       if ((err = snd_sbmixer_new(chip)) < 0)
-               goto _err;
+       err = snd_sbmixer_new(chip);
+       if (err < 0)
+               return err;
 
        if (chip->hardware == SB_HW_10 || chip->hardware == SB_HW_20) {
-               if ((err = snd_opl3_create(card, chip->port + 8, 0,
-                                          OPL3_HW_AUTO, 1,
-                                          &opl3)) < 0) {
+               err = snd_opl3_create(card, chip->port + 8, 0,
+                                     OPL3_HW_AUTO, 1, &opl3);
+               if (err < 0)
                        snd_printk(KERN_WARNING "sb8: no OPL device at 0x%lx\n", chip->port + 8);
-               }
        } else {
-               if ((err = snd_opl3_create(card, chip->port, chip->port + 2,
-                                          OPL3_HW_AUTO, 1,
-                                          &opl3)) < 0) {
+               err = snd_opl3_create(card, chip->port, chip->port + 2,
+                                     OPL3_HW_AUTO, 1, &opl3);
+               if (err < 0) {
                        snd_printk(KERN_WARNING "sb8: no OPL device at 0x%lx-0x%lx\n",
                                   chip->port, chip->port + 2);
                }
        }
        if (err >= 0) {
-               if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0)
-                       goto _err;
+               err = snd_opl3_hwdep_new(opl3, 0, 1, NULL);
+               if (err < 0)
+                       return err;
        }
 
-       if ((err = snd_sb8dsp_midi(chip, 0)) < 0)
-               goto _err;
+       err = snd_sb8dsp_midi(chip, 0);
+       if (err < 0)
+               return err;
 
        strcpy(card->driver, chip->hardware == SB_HW_PRO ? "SB Pro" : "SB8");
        strcpy(card->shortname, chip->name);
@@ -180,20 +169,12 @@ static int snd_sb8_probe(struct device *pdev, unsigned int dev)
                chip->port,
                irq[dev], dma8[dev]);
 
-       if ((err = snd_card_register(card)) < 0)
-               goto _err;
+       err = snd_card_register(card);
+       if (err < 0)
+               return err;
 
        dev_set_drvdata(pdev, card);
        return 0;
-
- _err:
-       snd_card_free(card);
-       return err;
-}
-
-static void snd_sb8_remove(struct device *pdev, unsigned int dev)
-{
-       snd_card_free(dev_get_drvdata(pdev));
 }
 
 #ifdef CONFIG_PM
@@ -227,7 +208,6 @@ static int snd_sb8_resume(struct device *dev, unsigned int n)
 static struct isa_driver snd_sb8_driver = {
        .match          = snd_sb8_match,
        .probe          = snd_sb8_probe,
-       .remove         = snd_sb8_remove,
 #ifdef CONFIG_PM
        .suspend        = snd_sb8_suspend,
        .resume         = snd_sb8_resume,