diff options
Diffstat (limited to 'sound/isa/galaxy/galaxy.c')
| -rw-r--r-- | sound/isa/galaxy/galaxy.c | 106 |
1 files changed, 42 insertions, 64 deletions
diff --git a/sound/isa/galaxy/galaxy.c b/sound/isa/galaxy/galaxy.c index b9994cc9f5fb..b0f1562d0fc0 100644 --- a/sound/isa/galaxy/galaxy.c +++ b/sound/isa/galaxy/galaxy.c @@ -1,20 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Aztech AZT1605/AZT2316 Driver * Copyright (C) 2007,2010 Rene Herman - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * */ #include <linux/kernel.h> @@ -260,6 +247,7 @@ static int snd_galaxy_match(struct device *dev, unsigned int n) break; case 2: irq[n] = 9; + fallthrough; case 9: wss_config[n] |= WSS_CONFIG_IRQ_9; break; @@ -304,6 +292,7 @@ static int snd_galaxy_match(struct device *dev, unsigned int n) case 1: if (dma1[n] == 0) break; + fallthrough; default: dev_err(dev, "invalid capture DMA %d\n", dma2[n]); return 0; @@ -333,6 +322,7 @@ mpu: break; case 2: mpu_irq[n] = 9; + fallthrough; case 9: config[n] |= GALAXY_CONFIG_MPUIRQ_2; break; @@ -482,23 +472,13 @@ static void snd_galaxy_free(struct snd_card *card) { struct snd_galaxy *galaxy = card->private_data; - if (galaxy->wss_port) { + if (galaxy->wss_port) wss_set_config(galaxy->wss_port, 0); - ioport_unmap(galaxy->wss_port); - release_and_free_resource(galaxy->res_wss_port); - } - if (galaxy->config_port) { + if (galaxy->config_port) galaxy_set_config(galaxy, galaxy->config); - ioport_unmap(galaxy->config_port); - release_and_free_resource(galaxy->res_config_port); - } - if (galaxy->port) { - ioport_unmap(galaxy->port); - release_and_free_resource(galaxy->res_port); - } } -static int snd_galaxy_probe(struct device *dev, unsigned int n) +static int __snd_galaxy_probe(struct device *dev, unsigned int n) { struct snd_galaxy *galaxy; struct snd_wss *chip; @@ -506,60 +486,64 @@ static int snd_galaxy_probe(struct device *dev, unsigned int n) u8 type; int err; - err = snd_card_new(dev, index[n], id[n], THIS_MODULE, - sizeof(*galaxy), &card); + err = snd_devm_card_new(dev, index[n], id[n], THIS_MODULE, + sizeof(*galaxy), &card); if (err < 0) return err; card->private_free = snd_galaxy_free; galaxy = card->private_data; - galaxy->res_port = request_region(port[n], 16, DRV_NAME); + galaxy->res_port = devm_request_region(dev, port[n], 16, DRV_NAME); if (!galaxy->res_port) { dev_err(dev, "could not grab ports %#lx-%#lx\n", port[n], port[n] + 15); - err = -EBUSY; - goto error; + return -EBUSY; } - galaxy->port = ioport_map(port[n], 16); + galaxy->port = devm_ioport_map(dev, port[n], 16); + if (!galaxy->port) + return -ENOMEM; err = galaxy_init(galaxy, &type); if (err < 0) { dev_err(dev, "did not find a Sound Galaxy at %#lx\n", port[n]); - goto error; + return err; } dev_info(dev, "Sound Galaxy (type %d) found at %#lx\n", type, port[n]); - galaxy->res_config_port = request_region(port[n] + GALAXY_PORT_CONFIG, - 16, DRV_NAME); + galaxy->res_config_port = + devm_request_region(dev, port[n] + GALAXY_PORT_CONFIG, 16, + DRV_NAME); if (!galaxy->res_config_port) { dev_err(dev, "could not grab ports %#lx-%#lx\n", port[n] + GALAXY_PORT_CONFIG, port[n] + GALAXY_PORT_CONFIG + 15); - err = -EBUSY; - goto error; + return -EBUSY; } - galaxy->config_port = ioport_map(port[n] + GALAXY_PORT_CONFIG, 16); - + galaxy->config_port = + devm_ioport_map(dev, port[n] + GALAXY_PORT_CONFIG, 16); + if (!galaxy->config_port) + return -ENOMEM; galaxy_config(galaxy, config[n]); - galaxy->res_wss_port = request_region(wss_port[n], 4, DRV_NAME); + galaxy->res_wss_port = devm_request_region(dev, wss_port[n], 4, DRV_NAME); if (!galaxy->res_wss_port) { dev_err(dev, "could not grab ports %#lx-%#lx\n", wss_port[n], wss_port[n] + 3); - err = -EBUSY; - goto error; + return -EBUSY; } - galaxy->wss_port = ioport_map(wss_port[n], 4); + galaxy->wss_port = devm_ioport_map(dev, wss_port[n], 4); + if (!galaxy->wss_port) + return -ENOMEM; err = galaxy_wss_config(galaxy, wss_config[n]); if (err < 0) { dev_err(dev, "could not configure WSS\n"); - goto error; + return err; } - strcpy(card->driver, DRV_NAME); - strcpy(card->shortname, DRV_NAME); + strscpy(card->driver, DRV_NAME); + strscpy(card->shortname, DRV_NAME); sprintf(card->longname, "%s at %#lx/%#lx, irq %d, dma %d/%d", card->shortname, port[n], wss_port[n], irq[n], dma1[n], dma2[n]); @@ -567,25 +551,25 @@ static int snd_galaxy_probe(struct device *dev, unsigned int n) err = snd_wss_create(card, wss_port[n] + 4, -1, irq[n], dma1[n], dma2[n], WSS_HW_DETECT, 0, &chip); if (err < 0) - goto error; + return err; err = snd_wss_pcm(chip, 0); if (err < 0) - goto error; + return err; err = snd_wss_mixer(chip); if (err < 0) - goto error; + return err; err = snd_wss_timer(chip, 0); if (err < 0) - goto error; + return err; if (mpu_port[n] >= 0) { err = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, mpu_port[n], 0, mpu_irq[n], NULL); if (err < 0) - goto error; + return err; } if (fm_port[n] >= 0) { @@ -595,39 +579,33 @@ static int snd_galaxy_probe(struct device *dev, unsigned int n) OPL3_HW_AUTO, 0, &opl3); if (err < 0) { dev_err(dev, "no OPL device at %#lx\n", fm_port[n]); - goto error; + return err; } err = snd_opl3_timer_new(opl3, 1, 2); if (err < 0) - goto error; + return err; err = snd_opl3_hwdep_new(opl3, 0, 1, NULL); if (err < 0) - goto error; + return err; } err = snd_card_register(card); if (err < 0) - goto error; + return err; dev_set_drvdata(dev, card); return 0; - -error: - snd_card_free(card); - return err; } -static int snd_galaxy_remove(struct device *dev, unsigned int n) +static int snd_galaxy_probe(struct device *dev, unsigned int n) { - snd_card_free(dev_get_drvdata(dev)); - return 0; + return snd_card_free_on_error(dev, __snd_galaxy_probe(dev, n)); } static struct isa_driver snd_galaxy_driver = { .match = snd_galaxy_match, .probe = snd_galaxy_probe, - .remove = snd_galaxy_remove, .driver = { .name = DEV_NAME |
