diff options
Diffstat (limited to 'sound/drivers/pcsp/pcsp.c')
-rw-r--r-- | sound/drivers/pcsp/pcsp.c | 49 |
1 files changed, 16 insertions, 33 deletions
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, }; |