diff options
Diffstat (limited to 'sound/drivers')
-rw-r--r-- | sound/drivers/Kconfig | 2 | ||||
-rw-r--r-- | sound/drivers/aloop.c | 26 | ||||
-rw-r--r-- | sound/drivers/dummy.c | 24 | ||||
-rw-r--r-- | sound/drivers/mpu401/mpu401.c | 34 | ||||
-rw-r--r-- | sound/drivers/mtpav.c | 30 | ||||
-rw-r--r-- | sound/drivers/pcsp/pcsp.c | 49 | ||||
-rw-r--r-- | sound/drivers/pcsp/pcsp_input.c | 14 | ||||
-rw-r--r-- | sound/drivers/pcsp/pcsp_input.h | 1 | ||||
-rw-r--r-- | sound/drivers/serial-u16550.c | 57 | ||||
-rw-r--r-- | sound/drivers/virmidi.c | 21 | ||||
-rw-r--r-- | sound/drivers/vx/vx_core.c | 12 |
11 files changed, 73 insertions, 197 deletions
diff --git a/sound/drivers/Kconfig b/sound/drivers/Kconfig index 7141f73cddd3..ca4cdf666f82 100644 --- a/sound/drivers/Kconfig +++ b/sound/drivers/Kconfig @@ -102,7 +102,7 @@ config SND_ALOOP configured number of substreams (see the pcm_substreams module parameter). - The loopback device allows time sychronization with an external + The loopback device allows time synchronization with an external timing source using the time shift universal control (+-20% of system time). diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c index 80b814b9922a..9b4a7cdb103a 100644 --- a/sound/drivers/aloop.c +++ b/sound/drivers/aloop.c @@ -1712,8 +1712,8 @@ static int loopback_probe(struct platform_device *devptr) int dev = devptr->id; int err; - err = snd_card_new(&devptr->dev, index[dev], id[dev], THIS_MODULE, - sizeof(struct loopback), &card); + err = snd_devm_card_new(&devptr->dev, index[dev], id[dev], THIS_MODULE, + sizeof(struct loopback), &card); if (err < 0) return err; loopback = card->private_data; @@ -1730,13 +1730,13 @@ static int loopback_probe(struct platform_device *devptr) err = loopback_pcm_new(loopback, 0, pcm_substreams[dev]); if (err < 0) - goto __nodev; + return err; err = loopback_pcm_new(loopback, 1, pcm_substreams[dev]); if (err < 0) - goto __nodev; + return err; err = loopback_mixer_new(loopback, pcm_notify[dev] ? 1 : 0); if (err < 0) - goto __nodev; + return err; loopback_cable_proc_new(loopback, 0); loopback_cable_proc_new(loopback, 1); loopback_timer_source_proc_new(loopback); @@ -1744,18 +1744,9 @@ static int loopback_probe(struct platform_device *devptr) strcpy(card->shortname, "Loopback"); sprintf(card->longname, "Loopback %i", dev + 1); err = snd_card_register(card); - if (!err) { - platform_set_drvdata(devptr, card); - return 0; - } - __nodev: - snd_card_free(card); - return err; -} - -static int loopback_remove(struct platform_device *devptr) -{ - snd_card_free(platform_get_drvdata(devptr)); + if (err < 0) + return err; + platform_set_drvdata(devptr, card); return 0; } @@ -1786,7 +1777,6 @@ static SIMPLE_DEV_PM_OPS(loopback_pm, loopback_suspend, loopback_resume); static struct platform_driver loopback_driver = { .probe = loopback_probe, - .remove = loopback_remove, .driver = { .name = SND_LOOPBACK_DRIVER, .pm = LOOPBACK_PM_OPS, diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c index 01a3eab50d7b..2a7fc49c1a7c 100644 --- a/sound/drivers/dummy.c +++ b/sound/drivers/dummy.c @@ -1025,8 +1025,8 @@ static int snd_dummy_probe(struct platform_device *devptr) int idx, err; int dev = devptr->id; - err = snd_card_new(&devptr->dev, index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_dummy), &card); + err = snd_devm_card_new(&devptr->dev, index[dev], id[dev], THIS_MODULE, + sizeof(struct snd_dummy), &card); if (err < 0) return err; dummy = card->private_data; @@ -1047,7 +1047,7 @@ static int snd_dummy_probe(struct platform_device *devptr) pcm_substreams[dev] = MAX_PCM_SUBSTREAMS; err = snd_card_dummy_pcm(dummy, idx, pcm_substreams[dev]); if (err < 0) - goto __nodev; + return err; } dummy->pcm_hw = dummy_pcm_hardware; @@ -1078,7 +1078,7 @@ static int snd_dummy_probe(struct platform_device *devptr) err = snd_card_dummy_new_mixer(dummy); if (err < 0) - goto __nodev; + return err; strcpy(card->driver, "Dummy"); strcpy(card->shortname, "Dummy"); sprintf(card->longname, "Dummy %i", dev + 1); @@ -1086,18 +1086,9 @@ static int snd_dummy_probe(struct platform_device *devptr) dummy_proc_init(dummy); err = snd_card_register(card); - if (err == 0) { - platform_set_drvdata(devptr, card); - return 0; - } - __nodev: - snd_card_free(card); - return err; -} - -static int snd_dummy_remove(struct platform_device *devptr) -{ - snd_card_free(platform_get_drvdata(devptr)); + if (err < 0) + return err; + platform_set_drvdata(devptr, card); return 0; } @@ -1128,7 +1119,6 @@ static SIMPLE_DEV_PM_OPS(snd_dummy_pm, snd_dummy_suspend, snd_dummy_resume); static struct platform_driver snd_dummy_driver = { .probe = snd_dummy_probe, - .remove = snd_dummy_remove, .driver = { .name = SND_DUMMY_DRIVER, .pm = SND_DUMMY_PM_OPS, diff --git a/sound/drivers/mpu401/mpu401.c b/sound/drivers/mpu401/mpu401.c index d0b55dbb411a..3398aee33baa 100644 --- a/sound/drivers/mpu401/mpu401.c +++ b/sound/drivers/mpu401/mpu401.c @@ -59,8 +59,8 @@ static int snd_mpu401_create(struct device *devptr, int dev, snd_printk(KERN_ERR "the uart_enter option is obsolete; remove it\n"); *rcard = NULL; - err = snd_card_new(devptr, index[dev], id[dev], THIS_MODULE, - 0, &card); + err = snd_devm_card_new(devptr, index[dev], id[dev], THIS_MODULE, + 0, &card); if (err < 0) return err; strcpy(card->driver, "MPU-401 UART"); @@ -76,15 +76,11 @@ static int snd_mpu401_create(struct device *devptr, int dev, irq[dev], NULL); if (err < 0) { printk(KERN_ERR "MPU401 not detected at 0x%lx\n", port[dev]); - goto _err; + return err; } *rcard = card; return 0; - - _err: - snd_card_free(card); - return err; } static int snd_mpu401_probe(struct platform_device *devptr) @@ -105,25 +101,16 @@ static int snd_mpu401_probe(struct platform_device *devptr) if (err < 0) return err; err = snd_card_register(card); - if (err < 0) { - snd_card_free(card); + if (err < 0) return err; - } platform_set_drvdata(devptr, card); return 0; } -static int snd_mpu401_remove(struct platform_device *devptr) -{ - snd_card_free(platform_get_drvdata(devptr)); - return 0; -} - #define SND_MPU401_DRIVER "snd_mpu401" static struct platform_driver snd_mpu401_driver = { .probe = snd_mpu401_probe, - .remove = snd_mpu401_remove, .driver = { .name = SND_MPU401_DRIVER, }, @@ -184,10 +171,8 @@ static int snd_mpu401_pnp_probe(struct pnp_dev *pnp_dev, if (err < 0) return err; err = snd_card_register(card); - if (err < 0) { - snd_card_free(card); + if (err < 0) return err; - } pnp_set_drvdata(pnp_dev, card); snd_mpu401_devices++; ++dev; @@ -196,19 +181,10 @@ static int snd_mpu401_pnp_probe(struct pnp_dev *pnp_dev, return -ENODEV; } -static void snd_mpu401_pnp_remove(struct pnp_dev *dev) -{ - struct snd_card *card = (struct snd_card *) pnp_get_drvdata(dev); - - snd_card_disconnect(card); - snd_card_free_when_closed(card); -} - static struct pnp_driver snd_mpu401_pnp_driver = { .name = "mpu401", .id_table = snd_mpu401_pnpids, .probe = snd_mpu401_pnp_probe, - .remove = snd_mpu401_pnp_remove, }; #else static struct pnp_driver snd_mpu401_pnp_driver; diff --git a/sound/drivers/mtpav.c b/sound/drivers/mtpav.c index 0e95b08d34d6..11235baaf6fa 100644 --- a/sound/drivers/mtpav.c +++ b/sound/drivers/mtpav.c @@ -566,13 +566,15 @@ static irqreturn_t snd_mtpav_irqh(int irq, void *dev_id) */ static int snd_mtpav_get_ISA(struct mtpav *mcard) { - mcard->res_port = request_region(port, 3, "MotuMTPAV MIDI"); + mcard->res_port = devm_request_region(mcard->card->dev, port, 3, + "MotuMTPAV MIDI"); if (!mcard->res_port) { snd_printk(KERN_ERR "MTVAP port 0x%lx is busy\n", port); return -EBUSY; } mcard->port = port; - if (request_irq(irq, snd_mtpav_irqh, 0, "MOTU MTPAV", mcard)) { + if (devm_request_irq(mcard->card->dev, irq, snd_mtpav_irqh, 0, + "MOTU MTPAV", mcard)) { snd_printk(KERN_ERR "MTVAP IRQ %d busy\n", irq); return -EBUSY; } @@ -667,9 +669,6 @@ static void snd_mtpav_free(struct snd_card *card) if (crd->istimer > 0) snd_mtpav_remove_output_timer(crd); spin_unlock_irqrestore(&crd->spinlock, flags); - if (crd->irq >= 0) - free_irq(crd->irq, (void *)crd); - release_and_free_resource(crd->res_port); } /* @@ -680,8 +679,8 @@ static int snd_mtpav_probe(struct platform_device *dev) int err; struct mtpav *mtp_card; - err = snd_card_new(&dev->dev, index, id, THIS_MODULE, - sizeof(*mtp_card), &card); + err = snd_devm_card_new(&dev->dev, index, id, THIS_MODULE, + sizeof(*mtp_card), &card); if (err < 0) return err; @@ -698,13 +697,13 @@ static int snd_mtpav_probe(struct platform_device *dev) err = snd_mtpav_get_RAWMIDI(mtp_card); if (err < 0) - goto __error; + return err; mtp_card->inmidiport = mtp_card->num_ports + MTPAV_PIDX_BROADCAST; err = snd_mtpav_get_ISA(mtp_card); if (err < 0) - goto __error; + return err; strcpy(card->driver, "MTPAV"); strcpy(card->shortname, "MTPAV on parallel port"); @@ -715,28 +714,17 @@ static int snd_mtpav_probe(struct platform_device *dev) err = snd_card_register(mtp_card->card); if (err < 0) - goto __error; + return err; platform_set_drvdata(dev, card); printk(KERN_INFO "Motu MidiTimePiece on parallel port irq: %d ioport: 0x%lx\n", irq, port); return 0; - - __error: - snd_card_free(card); - return err; -} - -static int snd_mtpav_remove(struct platform_device *devptr) -{ - snd_card_free(platform_get_drvdata(devptr)); - return 0; } #define SND_MTPAV_DRIVER "snd_mtpav" static struct platform_driver snd_mtpav_driver = { .probe = snd_mtpav_probe, - .remove = snd_mtpav_remove, .driver = { .name = SND_MTPAV_DRIVER, }, diff --git a/sound/drivers/pcsp/pcsp.c b/sound/drivers/pcsp/pcsp.c index 7689fa2f9531..c7be1c395bcb 100644 --- a/sound/drivers/pcsp/pcsp.c +++ b/sound/drivers/pcsp/pcsp.c @@ -42,9 +42,8 @@ struct snd_pcsp pcsp_chip; static int snd_pcsp_create(struct snd_card *card) { - static const struct snd_device_ops ops = { }; unsigned int resolution = hrtimer_resolution; - int err, div, min_div, order; + int div, min_div, order; if (!nopcm) { if (resolution > PCSP_MAX_PERIOD_NS) { @@ -83,15 +82,18 @@ static int snd_pcsp_create(struct snd_card *card) pcsp_chip.port = 0x61; pcsp_chip.irq = -1; pcsp_chip.dma = -1; - - /* Register device */ - err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, &pcsp_chip, &ops); - if (err < 0) - return err; + card->private_data = &pcsp_chip; return 0; } +static void pcsp_stop_beep(struct snd_pcsp *chip); + +static void alsa_card_pcsp_free(struct snd_card *card) +{ + pcsp_stop_beep(card->private_data); +} + static int snd_card_pcsp_probe(int devnum, struct device *dev) { struct snd_card *card; @@ -103,22 +105,22 @@ static int snd_card_pcsp_probe(int devnum, struct device *dev) hrtimer_init(&pcsp_chip.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); pcsp_chip.timer.function = pcsp_do_timer; - err = snd_card_new(dev, index, id, THIS_MODULE, 0, &card); + err = snd_devm_card_new(dev, index, id, THIS_MODULE, 0, &card); if (err < 0) return err; err = snd_pcsp_create(card); if (err < 0) - goto free_card; + return err; if (!nopcm) { err = snd_pcsp_new_pcm(&pcsp_chip); if (err < 0) - goto free_card; + return err; } err = snd_pcsp_new_mixer(&pcsp_chip, nopcm); if (err < 0) - goto free_card; + return err; strcpy(card->driver, "PC-Speaker"); strcpy(card->shortname, "pcsp"); @@ -127,13 +129,10 @@ static int snd_card_pcsp_probe(int devnum, struct device *dev) err = snd_card_register(card); if (err < 0) - goto free_card; + return err; + card->private_free = alsa_card_pcsp_free; return 0; - -free_card: - snd_card_free(card); - return err; } static int alsa_card_pcsp_init(struct device *dev) @@ -155,11 +154,6 @@ static int alsa_card_pcsp_init(struct device *dev) return 0; } -static void alsa_card_pcsp_exit(struct snd_pcsp *chip) -{ - snd_card_free(chip->card); -} - static int pcsp_probe(struct platform_device *dev) { int err; @@ -169,23 +163,13 @@ static int pcsp_probe(struct platform_device *dev) return err; err = alsa_card_pcsp_init(&dev->dev); - if (err < 0) { - pcspkr_input_remove(pcsp_chip.input_dev); + if (err < 0) return err; - } platform_set_drvdata(dev, &pcsp_chip); return 0; } -static int pcsp_remove(struct platform_device *dev) -{ - struct snd_pcsp *chip = platform_get_drvdata(dev); - pcspkr_input_remove(chip->input_dev); - alsa_card_pcsp_exit(chip); - return 0; -} - static void pcsp_stop_beep(struct snd_pcsp *chip) { pcsp_sync_stop(chip); @@ -218,7 +202,6 @@ static struct platform_driver pcsp_platform_driver = { .pm = PCSP_PM_OPS, }, .probe = pcsp_probe, - .remove = pcsp_remove, .shutdown = pcsp_shutdown, }; diff --git a/sound/drivers/pcsp/pcsp_input.c b/sound/drivers/pcsp/pcsp_input.c index e79603fe743d..5a799f7f00a2 100644 --- a/sound/drivers/pcsp/pcsp_input.c +++ b/sound/drivers/pcsp/pcsp_input.c @@ -78,7 +78,7 @@ int pcspkr_input_init(struct input_dev **rdev, struct device *dev) { int err; - struct input_dev *input_dev = input_allocate_device(); + struct input_dev *input_dev = devm_input_allocate_device(dev); if (!input_dev) return -ENOMEM; @@ -95,19 +95,9 @@ int pcspkr_input_init(struct input_dev **rdev, struct device *dev) input_dev->event = pcspkr_input_event; err = input_register_device(input_dev); - if (err) { - input_free_device(input_dev); + if (err) return err; - } *rdev = input_dev; return 0; } - -int pcspkr_input_remove(struct input_dev *dev) -{ - pcspkr_stop_sound(); - input_unregister_device(dev); /* this also does kfree() */ - - return 0; -} diff --git a/sound/drivers/pcsp/pcsp_input.h b/sound/drivers/pcsp/pcsp_input.h index e80079b38a56..42bfc9eab6eb 100644 --- a/sound/drivers/pcsp/pcsp_input.h +++ b/sound/drivers/pcsp/pcsp_input.h @@ -9,7 +9,6 @@ #define __PCSP_INPUT_H__ int pcspkr_input_init(struct input_dev **rdev, struct device *dev); -int pcspkr_input_remove(struct input_dev *dev); void pcspkr_stop_sound(void); #endif diff --git a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c index da9983cba01c..3cbc7a4adcb4 100644 --- a/sound/drivers/serial-u16550.c +++ b/sound/drivers/serial-u16550.c @@ -115,7 +115,6 @@ struct snd_uart16550 { int irq; unsigned long base; - struct resource *res_base; unsigned int speed; unsigned int speed_base; @@ -323,8 +322,7 @@ static int snd_uart16550_detect(struct snd_uart16550 *uart) return -ENODEV; /* Not configured */ } - uart->res_base = request_region(io_base, 8, "Serial MIDI"); - if (uart->res_base == NULL) { + if (!devm_request_region(uart->card->dev, io_base, 8, "Serial MIDI")) { snd_printk(KERN_ERR "u16550: can't grab port 0x%lx\n", io_base); return -EBUSY; } @@ -752,21 +750,6 @@ static const struct snd_rawmidi_ops snd_uart16550_input = .trigger = snd_uart16550_input_trigger, }; -static int snd_uart16550_free(struct snd_uart16550 *uart) -{ - if (uart->irq >= 0) - free_irq(uart->irq, uart); - release_and_free_resource(uart->res_base); - kfree(uart); - return 0; -}; - -static int snd_uart16550_dev_free(struct snd_device *device) -{ - struct snd_uart16550 *uart = device->device_data; - return snd_uart16550_free(uart); -} - static int snd_uart16550_create(struct snd_card *card, unsigned long iobase, int irq, @@ -776,14 +759,11 @@ static int snd_uart16550_create(struct snd_card *card, int droponfull, struct snd_uart16550 **ruart) { - static const struct snd_device_ops ops = { - .dev_free = snd_uart16550_dev_free, - }; struct snd_uart16550 *uart; int err; - uart = kzalloc(sizeof(*uart), GFP_KERNEL); + uart = devm_kzalloc(card->dev, sizeof(*uart), GFP_KERNEL); if (!uart) return -ENOMEM; uart->adaptor = adaptor; @@ -796,13 +776,12 @@ static int snd_uart16550_create(struct snd_card *card, err = snd_uart16550_detect(uart); if (err <= 0) { printk(KERN_ERR "no UART detected at 0x%lx\n", iobase); - snd_uart16550_free(uart); return -ENODEV; } if (irq >= 0 && irq != SNDRV_AUTO_IRQ) { - if (request_irq(irq, snd_uart16550_interrupt, - 0, "Serial MIDI", uart)) { + if (devm_request_irq(card->dev, irq, snd_uart16550_interrupt, + 0, "Serial MIDI", uart)) { snd_printk(KERN_WARNING "irq %d busy. Using Polling.\n", irq); } else { @@ -819,13 +798,6 @@ static int snd_uart16550_create(struct snd_card *card, timer_setup(&uart->buffer_timer, snd_uart16550_buffer_timer, 0); uart->timer_running = 0; - /* Register device */ - err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, uart, &ops); - if (err < 0) { - snd_uart16550_free(uart); - return err; - } - switch (uart->adaptor) { case SNDRV_SERIAL_MS124W_SA: case SNDRV_SERIAL_MS124W_MB: @@ -927,8 +899,8 @@ static int snd_serial_probe(struct platform_device *devptr) return -ENODEV; } - err = snd_card_new(&devptr->dev, index[dev], id[dev], THIS_MODULE, - 0, &card); + err = snd_devm_card_new(&devptr->dev, index[dev], id[dev], THIS_MODULE, + 0, &card); if (err < 0) return err; @@ -939,11 +911,11 @@ static int snd_serial_probe(struct platform_device *devptr) base[dev], adaptor[dev], droponfull[dev], &uart); if (err < 0) - goto _err; + return err; err = snd_uart16550_rmidi(uart, 0, outs[dev], ins[dev], &uart->rmidi); if (err < 0) - goto _err; + return err; sprintf(card->longname, "%s [%s] at %#lx, irq %d", card->shortname, @@ -953,27 +925,16 @@ static int snd_serial_probe(struct platform_device *devptr) err = snd_card_register(card); if (err < 0) - goto _err; + return err; platform_set_drvdata(devptr, card); return 0; - - _err: - snd_card_free(card); - return err; -} - -static int snd_serial_remove(struct platform_device *devptr) -{ - snd_card_free(platform_get_drvdata(devptr)); - return 0; } #define SND_SERIAL_DRIVER "snd_serial_u16550" static struct platform_driver snd_serial_driver = { .probe = snd_serial_probe, - .remove = snd_serial_remove, .driver = { .name = SND_SERIAL_DRIVER, }, diff --git a/sound/drivers/virmidi.c b/sound/drivers/virmidi.c index 4206d93ab47e..7f7eed6faaae 100644 --- a/sound/drivers/virmidi.c +++ b/sound/drivers/virmidi.c @@ -75,8 +75,8 @@ static int snd_virmidi_probe(struct platform_device *devptr) int idx, err; int dev = devptr->id; - err = snd_card_new(&devptr->dev, index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_card_virmidi), &card); + err = snd_devm_card_new(&devptr->dev, index[dev], id[dev], THIS_MODULE, + sizeof(struct snd_card_virmidi), &card); if (err < 0) return err; vmidi = card->private_data; @@ -94,7 +94,7 @@ static int snd_virmidi_probe(struct platform_device *devptr) err = snd_virmidi_new(card, idx, &rmidi); if (err < 0) - goto __nodev; + return err; rdev = rmidi->private_data; vmidi->midi[idx] = rmidi; strcpy(rmidi->name, "Virtual Raw MIDI"); @@ -106,18 +106,10 @@ static int snd_virmidi_probe(struct platform_device *devptr) sprintf(card->longname, "Virtual MIDI Card %i", dev + 1); err = snd_card_register(card); - if (!err) { - platform_set_drvdata(devptr, card); - return 0; - } -__nodev: - snd_card_free(card); - return err; -} + if (err) + return err; -static int snd_virmidi_remove(struct platform_device *devptr) -{ - snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, card); return 0; } @@ -125,7 +117,6 @@ static int snd_virmidi_remove(struct platform_device *devptr) static struct platform_driver snd_virmidi_driver = { .probe = snd_virmidi_probe, - .remove = snd_virmidi_remove, .driver = { .name = SND_VIRMIDI_DRIVER, }, diff --git a/sound/drivers/vx/vx_core.c b/sound/drivers/vx/vx_core.c index a10449af5a76..18901e5bcfcf 100644 --- a/sound/drivers/vx/vx_core.c +++ b/sound/drivers/vx/vx_core.c @@ -774,6 +774,11 @@ int snd_vx_resume(struct vx_core *chip) EXPORT_SYMBOL(snd_vx_resume); #endif +static void snd_vx_release(struct device *dev, void *data) +{ + snd_vx_free_firmware(data); +} + /** * snd_vx_create - constructor for struct vx_core * @card: card instance @@ -784,6 +789,8 @@ EXPORT_SYMBOL(snd_vx_resume); * this function allocates the instance and prepare for the hardware * initialization. * + * The object is managed via devres, and will be automatically released. + * * return the instance pointer if successful, NULL in error. */ struct vx_core *snd_vx_create(struct snd_card *card, @@ -796,8 +803,9 @@ struct vx_core *snd_vx_create(struct snd_card *card, if (snd_BUG_ON(!card || !hw || !ops)) return NULL; - chip = kzalloc(sizeof(*chip) + extra_size, GFP_KERNEL); - if (! chip) + chip = devres_alloc(snd_vx_release, sizeof(*chip) + extra_size, + GFP_KERNEL); + if (!chip) return NULL; mutex_init(&chip->lock); chip->irq = -1; |