diff options
Diffstat (limited to 'sound/isa/sb/emu8000.c')
-rw-r--r-- | sound/isa/sb/emu8000.c | 75 |
1 files changed, 22 insertions, 53 deletions
diff --git a/sound/isa/sb/emu8000.c b/sound/isa/sb/emu8000.c index 0aa545ac6e60..312b217491d4 100644 --- a/sound/isa/sb/emu8000.c +++ b/sound/isa/sb/emu8000.c @@ -14,6 +14,7 @@ #include <linux/export.h> #include <linux/delay.h> #include <linux/io.h> +#include <linux/string.h> #include <sound/core.h> #include <sound/emu8000.h> #include <sound/emu8000_reg.h> @@ -160,8 +161,8 @@ snd_emu8000_detect(struct snd_emu8000 *emu) if ((EMU8000_HWCF2_READ(emu) & 0x0003) != 0x0003) return -ENODEV; - snd_printdd("EMU8000 [0x%lx]: Synth chip found\n", - emu->port1); + dev_dbg(emu->card->dev, "EMU8000 [0x%lx]: Synth chip found\n", + emu->port1); return 0; } @@ -652,7 +653,7 @@ snd_emu8000_load_chorus_fx(struct snd_emu8000 *emu, int mode, const void __user { struct soundfont_chorus_fx rec; if (mode < SNDRV_EMU8000_CHORUS_PREDEFINED || mode >= SNDRV_EMU8000_CHORUS_NUMBERS) { - snd_printk(KERN_WARNING "invalid chorus mode %d for uploading\n", mode); + dev_warn(emu->card->dev, "invalid chorus mode %d for uploading\n", mode); return -EINVAL; } if (len < (long)sizeof(rec) || copy_from_user(&rec, buf, sizeof(rec))) @@ -780,7 +781,7 @@ snd_emu8000_load_reverb_fx(struct snd_emu8000 *emu, int mode, const void __user struct soundfont_reverb_fx rec; if (mode < SNDRV_EMU8000_REVERB_PREDEFINED || mode >= SNDRV_EMU8000_REVERB_NUMBERS) { - snd_printk(KERN_WARNING "invalid reverb mode %d for uploading\n", mode); + dev_warn(emu->card->dev, "invalid reverb mode %d for uploading\n", mode); return -EINVAL; } if (len < (long)sizeof(rec) || copy_from_user(&rec, buf, sizeof(rec))) @@ -1020,6 +1021,7 @@ static const struct snd_kcontrol_new *mixer_defs[EMU8000_NUM_CONTROLS] = { static int snd_emu8000_create_mixer(struct snd_card *card, struct snd_emu8000 *emu) { + struct snd_kcontrol *kctl; int i, err = 0; if (snd_BUG_ON(!emu || !card)) @@ -1029,42 +1031,20 @@ snd_emu8000_create_mixer(struct snd_card *card, struct snd_emu8000 *emu) memset(emu->controls, 0, sizeof(emu->controls)); for (i = 0; i < EMU8000_NUM_CONTROLS; i++) { - if ((err = snd_ctl_add(card, emu->controls[i] = snd_ctl_new1(mixer_defs[i], emu))) < 0) + kctl = snd_ctl_new1(mixer_defs[i], emu); + err = snd_ctl_add(card, kctl); + if (err < 0) goto __error; + emu->controls[i] = kctl; } return 0; __error: - for (i = 0; i < EMU8000_NUM_CONTROLS; i++) { - down_write(&card->controls_rwsem); - if (emu->controls[i]) - snd_ctl_remove(card, emu->controls[i]); - up_write(&card->controls_rwsem); - } + for (i = 0; i < EMU8000_NUM_CONTROLS; i++) + snd_ctl_remove(card, emu->controls[i]); return err; } - -/* - * free resources - */ -static int snd_emu8000_free(struct snd_emu8000 *hw) -{ - release_and_free_resource(hw->res_port1); - release_and_free_resource(hw->res_port2); - release_and_free_resource(hw->res_port3); - kfree(hw); - return 0; -} - -/* - */ -static int snd_emu8000_dev_free(struct snd_device *device) -{ - struct snd_emu8000 *hw = device->device_data; - return snd_emu8000_free(hw); -} - /* * initialize and register emu8000 synth device. */ @@ -1075,9 +1055,6 @@ snd_emu8000_new(struct snd_card *card, int index, long port, int seq_ports, struct snd_seq_device *awe; struct snd_emu8000 *hw; int err; - static const struct snd_device_ops ops = { - .dev_free = snd_emu8000_dev_free, - }; if (awe_ret) *awe_ret = NULL; @@ -1085,7 +1062,7 @@ snd_emu8000_new(struct snd_card *card, int index, long port, int seq_ports, if (seq_ports <= 0) return 0; - hw = kzalloc(sizeof(*hw), GFP_KERNEL); + hw = devm_kzalloc(card->dev, sizeof(*hw), GFP_KERNEL); if (hw == NULL) return -ENOMEM; spin_lock_init(&hw->reg_lock); @@ -1093,11 +1070,11 @@ snd_emu8000_new(struct snd_card *card, int index, long port, int seq_ports, hw->port1 = port; hw->port2 = port + 0x400; hw->port3 = port + 0x800; - if (!(hw->res_port1 = request_region(hw->port1, 4, "Emu8000-1")) || - !(hw->res_port2 = request_region(hw->port2, 4, "Emu8000-2")) || - !(hw->res_port3 = request_region(hw->port3, 4, "Emu8000-3"))) { - snd_printk(KERN_ERR "sbawe: can't grab ports 0x%lx, 0x%lx, 0x%lx\n", hw->port1, hw->port2, hw->port3); - snd_emu8000_free(hw); + if (!devm_request_region(card->dev, hw->port1, 4, "Emu8000-1") || + !devm_request_region(card->dev, hw->port2, 4, "Emu8000-2") || + !devm_request_region(card->dev, hw->port3, 4, "Emu8000-3")) { + dev_err(card->dev, "sbawe: can't grab ports 0x%lx, 0x%lx, 0x%lx\n", + hw->port1, hw->port2, hw->port3); return -EBUSY; } hw->mem_size = 0; @@ -1110,25 +1087,17 @@ snd_emu8000_new(struct snd_card *card, int index, long port, int seq_ports, hw->fm_chorus_depth = 0; hw->fm_reverb_depth = 0; - if (snd_emu8000_detect(hw) < 0) { - snd_emu8000_free(hw); + if (snd_emu8000_detect(hw) < 0) return -ENODEV; - } snd_emu8000_init_hw(hw); - if ((err = snd_emu8000_create_mixer(card, hw)) < 0) { - snd_emu8000_free(hw); + err = snd_emu8000_create_mixer(card, hw); + if (err < 0) return err; - } - - if ((err = snd_device_new(card, SNDRV_DEV_CODEC, hw, &ops)) < 0) { - snd_emu8000_free(hw); - return err; - } #if IS_ENABLED(CONFIG_SND_SEQUENCER) if (snd_seq_device_new(card, index, SNDRV_SEQ_DEV_ID_EMU8000, sizeof(struct snd_emu8000*), &awe) >= 0) { - strcpy(awe->name, "EMU-8000"); + strscpy(awe->name, "EMU-8000"); *(struct snd_emu8000 **)SNDRV_SEQ_DEVICE_ARGPTR(awe) = hw; } #else |