diff --git a/Documentation/sound/alsa/HD-Audio.txt b/Documentation/sound/alsa/HD-Audio.txt index c5948f2f9a253eab2e2764a7002e912ae478fc8c..88b7433d2f117900e8c21823cc6917c736cb8e4e 100644 --- a/Documentation/sound/alsa/HD-Audio.txt +++ b/Documentation/sound/alsa/HD-Audio.txt @@ -169,7 +169,7 @@ PCI SSID look-up. What `model` option values are available depends on the codec chip. Check your codec chip from the codec proc file (see "Codec Proc-File" section below). It will show the vendor/product name of your codec -chip. Then, see Documentation/sound/alsa/HD-Audio-Modelstxt file, +chip. Then, see Documentation/sound/alsa/HD-Audio-Models.txt file, the section of HD-audio driver. You can find a list of codecs and `model` options belonging to each codec. For example, for Realtek ALC262 codec chip, pass `model=ultra` for devices that are compatible @@ -177,7 +177,7 @@ with Samsung Q1 Ultra. Thus, the first thing you can do for any brand-new, unsupported and non-working HD-audio hardware is to check HD-audio codec and several -different `model` option values. If you have a luck, some of them +different `model` option values. If you have any luck, some of them might suit with your device well. Some codecs such as ALC880 have a special model option `model=test`. diff --git a/include/sound/jack.h b/include/sound/jack.h index 6b013c6f6a049b980c6b6de1f7ac4f094597ef24..f236e426a706e9efa786ed0969959c26d6af3c1a 100644 --- a/include/sound/jack.h +++ b/include/sound/jack.h @@ -50,6 +50,8 @@ struct snd_jack { int type; const char *id; char name[100]; + void *private_data; + void (*private_free)(struct snd_jack *); }; #ifdef CONFIG_SND_JACK diff --git a/include/sound/pcm.h b/include/sound/pcm.h index 8904b1900d7ffa7969bf82603a9142dc8d2f7807..c172968916170b3e3c4e42aa1793b729f21e3670 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -268,7 +268,8 @@ struct snd_pcm_runtime { int overrange; snd_pcm_uframes_t avail_max; snd_pcm_uframes_t hw_ptr_base; /* Position at buffer restart */ - snd_pcm_uframes_t hw_ptr_interrupt; /* Position at interrupt time*/ + snd_pcm_uframes_t hw_ptr_interrupt; /* Position at interrupt time */ + unsigned long hw_ptr_jiffies; /* Time when hw_ptr is updated */ /* -- HW params -- */ snd_pcm_access_t access; /* access mode */ diff --git a/sound/core/control.c b/sound/core/control.c index 4b20fa2b7e6d72db78821ac4c39aba2f68d71c56..17b8d47a5cd07f2fca53ec7ef31d935a8958b327 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -723,14 +723,11 @@ static int snd_ctl_elem_read_user(struct snd_card *card, { struct snd_ctl_elem_value *control; int result; - - control = kmalloc(sizeof(*control), GFP_KERNEL); - if (control == NULL) - return -ENOMEM; - if (copy_from_user(control, _control, sizeof(*control))) { - kfree(control); - return -EFAULT; - } + + control = memdup_user(_control, sizeof(*control)); + if (IS_ERR(control)) + return PTR_ERR(control); + snd_power_lock(card); result = snd_power_wait(card, SNDRV_CTL_POWER_D0); if (result >= 0) @@ -784,13 +781,10 @@ static int snd_ctl_elem_write_user(struct snd_ctl_file *file, struct snd_card *card; int result; - control = kmalloc(sizeof(*control), GFP_KERNEL); - if (control == NULL) - return -ENOMEM; - if (copy_from_user(control, _control, sizeof(*control))) { - kfree(control); - return -EFAULT; - } + control = memdup_user(_control, sizeof(*control)); + if (IS_ERR(control)) + return PTR_ERR(control); + card = file->card; snd_power_lock(card); result = snd_power_wait(card, SNDRV_CTL_POWER_D0); @@ -916,13 +910,10 @@ static int snd_ctl_elem_user_tlv(struct snd_kcontrol *kcontrol, if (op_flag > 0) { if (size > 1024 * 128) /* sane value */ return -EINVAL; - new_data = kmalloc(size, GFP_KERNEL); - if (new_data == NULL) - return -ENOMEM; - if (copy_from_user(new_data, tlv, size)) { - kfree(new_data); - return -EFAULT; - } + + new_data = memdup_user(tlv, size); + if (IS_ERR(new_data)) + return PTR_ERR(new_data); change = ue->tlv_data_size != size; if (!change) change = memcmp(ue->tlv_data, new_data, size); diff --git a/sound/core/jack.c b/sound/core/jack.c index c8254c667c6247cef5e402161b0b1ef076782a5e..d54d1a05fe65af20009da1330b3e659d032e6217 100644 --- a/sound/core/jack.c +++ b/sound/core/jack.c @@ -35,6 +35,9 @@ static int snd_jack_dev_free(struct snd_device *device) { struct snd_jack *jack = device->device_data; + if (jack->private_free) + jack->private_free(jack); + /* If the input device is registered with the input subsystem * then we need to use a different deallocator. */ if (jack->registered) diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c index 36d7a5998234f472bec63b603bc5e7366f07f90d..08bfed594a83bfcf323472edbde17003f6fdeb28 100644 --- a/sound/core/pcm_compat.c +++ b/sound/core/pcm_compat.c @@ -232,14 +232,11 @@ static int snd_pcm_ioctl_hw_params_compat(struct snd_pcm_substream *substream, if (! (runtime = substream->runtime)) return -ENOTTY; - data = kmalloc(sizeof(*data), GFP_KERNEL); - if (data == NULL) - return -ENOMEM; /* only fifo_size is different, so just copy all */ - if (copy_from_user(data, data32, sizeof(*data32))) { - err = -EFAULT; - goto error; - } + data = memdup_user(data32, sizeof(*data32)); + if (IS_ERR(data)) + return PTR_ERR(data); + if (refine) err = snd_pcm_hw_refine(substream, data); else diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index fbb2e391591ea2c1a5e1933c65f6b946e7a0bd2c..63d088f2265f5c33ce8a26d707ff220bd61c2a1e 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -209,9 +209,11 @@ static int snd_pcm_update_hw_ptr_interrupt(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_uframes_t pos; - snd_pcm_uframes_t new_hw_ptr, hw_ptr_interrupt, hw_base; - snd_pcm_sframes_t delta; + snd_pcm_uframes_t old_hw_ptr, new_hw_ptr, hw_ptr_interrupt, hw_base; + snd_pcm_sframes_t hdelta, delta; + unsigned long jdelta; + old_hw_ptr = runtime->status->hw_ptr; pos = snd_pcm_update_hw_ptr_pos(substream, runtime); if (pos == SNDRV_PCM_POS_XRUN) { xrun(substream); @@ -247,7 +249,30 @@ static int snd_pcm_update_hw_ptr_interrupt(struct snd_pcm_substream *substream) new_hw_ptr = hw_base + pos; } } - if (delta > runtime->period_size) { + hdelta = new_hw_ptr - old_hw_ptr; + jdelta = jiffies - runtime->hw_ptr_jiffies; + if (((hdelta * HZ) / runtime->rate) > jdelta + HZ/100) { + delta = jdelta / + (((runtime->period_size * HZ) / runtime->rate) + + HZ/100); + hw_ptr_error(substream, + "hw_ptr skipping! [Q] " + "(pos=%ld, delta=%ld, period=%ld, " + "jdelta=%lu/%lu/%lu)\n", + (long)pos, (long)hdelta, + (long)runtime->period_size, jdelta, + ((hdelta * HZ) / runtime->rate), delta); + hw_ptr_interrupt = runtime->hw_ptr_interrupt + + runtime->period_size * delta; + if (hw_ptr_interrupt >= runtime->boundary) + hw_ptr_interrupt -= runtime->boundary; + /* rebase to interrupt position */ + hw_base = new_hw_ptr = hw_ptr_interrupt; + /* align hw_base to buffer_size */ + hw_base -= hw_base % runtime->buffer_size; + delta = 0; + } + if (delta > runtime->period_size + runtime->period_size / 2) { hw_ptr_error(substream, "Lost interrupts? " "(stream=%i, delta=%ld, intr_ptr=%ld)\n", @@ -263,6 +288,7 @@ static int snd_pcm_update_hw_ptr_interrupt(struct snd_pcm_substream *substream) runtime->hw_ptr_base = hw_base; runtime->status->hw_ptr = new_hw_ptr; + runtime->hw_ptr_jiffies = jiffies; runtime->hw_ptr_interrupt = hw_ptr_interrupt; return snd_pcm_update_hw_ptr_post(substream, runtime); @@ -275,6 +301,7 @@ int snd_pcm_update_hw_ptr(struct snd_pcm_substream *substream) snd_pcm_uframes_t pos; snd_pcm_uframes_t old_hw_ptr, new_hw_ptr, hw_base; snd_pcm_sframes_t delta; + unsigned long jdelta; old_hw_ptr = runtime->status->hw_ptr; pos = snd_pcm_update_hw_ptr_pos(substream, runtime); @@ -286,14 +313,15 @@ int snd_pcm_update_hw_ptr(struct snd_pcm_substream *substream) new_hw_ptr = hw_base + pos; delta = new_hw_ptr - old_hw_ptr; + jdelta = jiffies - runtime->hw_ptr_jiffies; if (delta < 0) { delta += runtime->buffer_size; if (delta < 0) { hw_ptr_error(substream, "Unexpected hw_pointer value [2] " - "(stream=%i, pos=%ld, old_ptr=%ld)\n", + "(stream=%i, pos=%ld, old_ptr=%ld, jdelta=%li)\n", substream->stream, (long)pos, - (long)old_hw_ptr); + (long)old_hw_ptr, jdelta); return 0; } hw_base += runtime->buffer_size; @@ -301,12 +329,13 @@ int snd_pcm_update_hw_ptr(struct snd_pcm_substream *substream) hw_base = 0; new_hw_ptr = hw_base + pos; } - if (delta > runtime->period_size && runtime->periods > 1) { + if (((delta * HZ) / runtime->rate) > jdelta + HZ/100) { hw_ptr_error(substream, "hw_ptr skipping! " - "(pos=%ld, delta=%ld, period=%ld)\n", + "(pos=%ld, delta=%ld, period=%ld, jdelta=%lu/%lu)\n", (long)pos, (long)delta, - (long)runtime->period_size); + (long)runtime->period_size, jdelta, + ((delta * HZ) / runtime->rate)); return 0; } if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && @@ -315,6 +344,7 @@ int snd_pcm_update_hw_ptr(struct snd_pcm_substream *substream) runtime->hw_ptr_base = hw_base; runtime->status->hw_ptr = new_hw_ptr; + runtime->hw_ptr_jiffies = jiffies; return snd_pcm_update_hw_ptr_post(substream, runtime); } @@ -1441,6 +1471,7 @@ static int snd_pcm_lib_ioctl_reset(struct snd_pcm_substream *substream, runtime->status->hw_ptr %= runtime->buffer_size; else runtime->status->hw_ptr = 0; + runtime->hw_ptr_jiffies = jiffies; snd_pcm_stream_unlock_irqrestore(substream, flags); return 0; } diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index a151fb01ba82a70b1a4a2c4eb9d7d079e2cf9912..fc6f98e257df5e27d67a71a092eaa85fd6765ca1 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -327,21 +327,16 @@ static int snd_pcm_hw_refine_user(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params; int err; - params = kmalloc(sizeof(*params), GFP_KERNEL); - if (!params) { - err = -ENOMEM; - goto out; - } - if (copy_from_user(params, _params, sizeof(*params))) { - err = -EFAULT; - goto out; - } + params = memdup_user(_params, sizeof(*params)); + if (IS_ERR(params)) + return PTR_ERR(params); + err = snd_pcm_hw_refine(substream, params); if (copy_to_user(_params, params, sizeof(*params))) { if (!err) err = -EFAULT; } -out: + kfree(params); return err; } @@ -465,21 +460,16 @@ static int snd_pcm_hw_params_user(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params; int err; - params = kmalloc(sizeof(*params), GFP_KERNEL); - if (!params) { - err = -ENOMEM; - goto out; - } - if (copy_from_user(params, _params, sizeof(*params))) { - err = -EFAULT; - goto out; - } + params = memdup_user(_params, sizeof(*params)); + if (IS_ERR(params)) + return PTR_ERR(params); + err = snd_pcm_hw_params(substream, params); if (copy_to_user(_params, params, sizeof(*params))) { if (!err) err = -EFAULT; } -out: + kfree(params); return err; } @@ -2593,13 +2583,11 @@ static int snd_pcm_playback_ioctl1(struct file *file, return -EFAULT; if (copy_from_user(&xfern, _xfern, sizeof(xfern))) return -EFAULT; - bufs = kmalloc(sizeof(void *) * runtime->channels, GFP_KERNEL); - if (bufs == NULL) - return -ENOMEM; - if (copy_from_user(bufs, xfern.bufs, sizeof(void *) * runtime->channels)) { - kfree(bufs); - return -EFAULT; - } + + bufs = memdup_user(xfern.bufs, + sizeof(void *) * runtime->channels); + if (IS_ERR(bufs)) + return PTR_ERR(bufs); result = snd_pcm_lib_writev(substream, bufs, xfern.frames); kfree(bufs); __put_user(result, &_xfern->result); @@ -2675,13 +2663,11 @@ static int snd_pcm_capture_ioctl1(struct file *file, return -EFAULT; if (copy_from_user(&xfern, _xfern, sizeof(xfern))) return -EFAULT; - bufs = kmalloc(sizeof(void *) * runtime->channels, GFP_KERNEL); - if (bufs == NULL) - return -ENOMEM; - if (copy_from_user(bufs, xfern.bufs, sizeof(void *) * runtime->channels)) { - kfree(bufs); - return -EFAULT; - } + + bufs = memdup_user(xfern.bufs, + sizeof(void *) * runtime->channels); + if (IS_ERR(bufs)) + return PTR_ERR(bufs); result = snd_pcm_lib_readv(substream, bufs, xfern.frames); kfree(bufs); __put_user(result, &_xfern->result); @@ -3312,18 +3298,12 @@ static int snd_pcm_hw_refine_old_user(struct snd_pcm_substream *substream, int err; params = kmalloc(sizeof(*params), GFP_KERNEL); - if (!params) { - err = -ENOMEM; - goto out; - } - oparams = kmalloc(sizeof(*oparams), GFP_KERNEL); - if (!oparams) { - err = -ENOMEM; - goto out; - } + if (!params) + return -ENOMEM; - if (copy_from_user(oparams, _oparams, sizeof(*oparams))) { - err = -EFAULT; + oparams = memdup_user(_oparams, sizeof(*oparams)); + if (IS_ERR(oparams)) { + err = PTR_ERR(oparams); goto out; } snd_pcm_hw_convert_from_old_params(params, oparams); @@ -3333,9 +3313,10 @@ static int snd_pcm_hw_refine_old_user(struct snd_pcm_substream *substream, if (!err) err = -EFAULT; } + + kfree(oparams); out: kfree(params); - kfree(oparams); return err; } @@ -3347,17 +3328,12 @@ static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream, int err; params = kmalloc(sizeof(*params), GFP_KERNEL); - if (!params) { - err = -ENOMEM; - goto out; - } - oparams = kmalloc(sizeof(*oparams), GFP_KERNEL); - if (!oparams) { - err = -ENOMEM; - goto out; - } - if (copy_from_user(oparams, _oparams, sizeof(*oparams))) { - err = -EFAULT; + if (!params) + return -ENOMEM; + + oparams = memdup_user(_oparams, sizeof(*oparams)); + if (IS_ERR(oparams)) { + err = PTR_ERR(oparams); goto out; } snd_pcm_hw_convert_from_old_params(params, oparams); @@ -3367,9 +3343,10 @@ static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream, if (!err) err = -EFAULT; } + + kfree(oparams); out: kfree(params); - kfree(oparams); return err; } #endif /* CONFIG_SND_SUPPORT_OLD_API */ diff --git a/sound/core/seq/seq_compat.c b/sound/core/seq/seq_compat.c index 38693f47c2625b2a5bf271c96b3ae124cc603588..c956fe462569238e1a396e69a86f73eb65200d45 100644 --- a/sound/core/seq/seq_compat.c +++ b/sound/core/seq/seq_compat.c @@ -48,12 +48,11 @@ static int snd_seq_call_port_info_ioctl(struct snd_seq_client *client, unsigned struct snd_seq_port_info *data; mm_segment_t fs; - data = kmalloc(sizeof(*data), GFP_KERNEL); - if (! data) - return -ENOMEM; + data = memdup_user(data32, sizeof(*data32)); + if (IS_ERR(data)) + return PTR_ERR(data); - if (copy_from_user(data, data32, sizeof(*data32)) || - get_user(data->flags, &data32->flags) || + if (get_user(data->flags, &data32->flags) || get_user(data->time_queue, &data32->time_queue)) goto error; data->kernel = NULL; diff --git a/sound/core/timer.c b/sound/core/timer.c index 3f0050d0b71eefbd27edbb5b3da245a91c6b85ac..8f8b17ac074df5d8e07821c638657e55a1730fb4 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -1395,13 +1395,10 @@ static int snd_timer_user_ginfo(struct file *file, struct list_head *p; int err = 0; - ginfo = kmalloc(sizeof(*ginfo), GFP_KERNEL); - if (! ginfo) - return -ENOMEM; - if (copy_from_user(ginfo, _ginfo, sizeof(*ginfo))) { - kfree(ginfo); - return -EFAULT; - } + ginfo = memdup_user(_ginfo, sizeof(*ginfo)); + if (IS_ERR(ginfo)) + return PTR_ERR(ginfo); + tid = ginfo->tid; memset(ginfo, 0, sizeof(*ginfo)); ginfo->tid = tid; diff --git a/sound/isa/sb/sb16_csp.c b/sound/isa/sb/sb16_csp.c index 49037d074c719f8e2ef2160b1d8730af1dec2cf6..bdc8dde4e4a219ab09736a1f9455207f63dfa3c1 100644 --- a/sound/isa/sb/sb16_csp.c +++ b/sound/isa/sb/sb16_csp.c @@ -684,15 +684,16 @@ static int snd_sb_csp_load(struct snd_sb_csp * p, const unsigned char *buf, int static int snd_sb_csp_load_user(struct snd_sb_csp * p, const unsigned char __user *buf, int size, int load_flags) { - int err = -ENOMEM; - unsigned char *kbuf = kmalloc(size, GFP_KERNEL); - if (kbuf) { - if (copy_from_user(kbuf, buf, size)) - err = -EFAULT; - else - err = snd_sb_csp_load(p, kbuf, size, load_flags); - kfree(kbuf); - } + int err; + unsigned char *kbuf; + + kbuf = memdup_user(buf, size); + if (IS_ERR(kbuf)) + return PTR_ERR(kbuf); + + err = snd_sb_csp_load(p, kbuf, size, load_flags); + + kfree(kbuf); return err; } diff --git a/sound/isa/wavefront/wavefront_fx.c b/sound/isa/wavefront/wavefront_fx.c index a4345fc0756198782b245468b3447cd36a6bc0b7..2bb1cee092555df10d6f445a288b554ddbdfc0f1 100644 --- a/sound/isa/wavefront/wavefront_fx.c +++ b/sound/isa/wavefront/wavefront_fx.c @@ -202,15 +202,11 @@ snd_wavefront_fx_ioctl (struct snd_hwdep *sdev, struct file *file, "> 512 bytes to FX\n"); return -EIO; } - page_data = kmalloc(r.data[2] * sizeof(short), GFP_KERNEL); - if (!page_data) - return -ENOMEM; - if (copy_from_user (page_data, - (unsigned char __user *) r.data[3], - r.data[2] * sizeof(short))) { - kfree(page_data); - return -EFAULT; - } + page_data = memdup_user((unsigned char __user *) + r.data[3], + r.data[2] * sizeof(short)); + if (IS_ERR(page_data)) + return PTR_ERR(page_data); pd = page_data; } diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c index beb312cca75b7bbea9598073eb2128010a346fe2..5d4ff48c4345418a4a2fb4fe4d8f782472484143 100644 --- a/sound/isa/wavefront/wavefront_synth.c +++ b/sound/isa/wavefront/wavefront_synth.c @@ -1664,12 +1664,11 @@ snd_wavefront_synth_ioctl (struct snd_hwdep *hw, struct file *file, break; case WFCTL_WFCMD: - wc = kmalloc(sizeof(*wc), GFP_KERNEL); - if (! wc) - return -ENOMEM; - if (copy_from_user (wc, argp, sizeof (*wc))) - err = -EFAULT; - else if (wavefront_synth_control (acard, wc) < 0) + wc = memdup_user(argp, sizeof(*wc)); + if (IS_ERR(wc)) + return PTR_ERR(wc); + + if (wavefront_synth_control (acard, wc) < 0) err = -EIO; else if (copy_to_user (argp, wc, sizeof (*wc))) err = -EFAULT; diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c index 191e1cd9997db53e8318ec4866efe327f9c012e4..4b302d86f5f26dbd547c8af4f9dc1705440f5b18 100644 --- a/sound/pci/emu10k1/emufx.c +++ b/sound/pci/emu10k1/emufx.c @@ -2493,24 +2493,17 @@ static int snd_emu10k1_fx8010_ioctl(struct snd_hwdep * hw, struct file *file, un case SNDRV_EMU10K1_IOCTL_CODE_POKE: if (!capable(CAP_SYS_ADMIN)) return -EPERM; - icode = kmalloc(sizeof(*icode), GFP_KERNEL); - if (icode == NULL) - return -ENOMEM; - if (copy_from_user(icode, argp, sizeof(*icode))) { - kfree(icode); - return -EFAULT; - } + + icode = memdup_user(argp, sizeof(*icode)); + if (IS_ERR(icode)) + return PTR_ERR(icode); res = snd_emu10k1_icode_poke(emu, icode); kfree(icode); return res; case SNDRV_EMU10K1_IOCTL_CODE_PEEK: - icode = kmalloc(sizeof(*icode), GFP_KERNEL); - if (icode == NULL) - return -ENOMEM; - if (copy_from_user(icode, argp, sizeof(*icode))) { - kfree(icode); - return -EFAULT; - } + icode = memdup_user(argp, sizeof(*icode)); + if (IS_ERR(icode)) + return PTR_ERR(icode); res = snd_emu10k1_icode_peek(emu, icode); if (res == 0 && copy_to_user(argp, icode, sizeof(*icode))) { kfree(icode); @@ -2519,24 +2512,16 @@ static int snd_emu10k1_fx8010_ioctl(struct snd_hwdep * hw, struct file *file, un kfree(icode); return res; case SNDRV_EMU10K1_IOCTL_PCM_POKE: - ipcm = kmalloc(sizeof(*ipcm), GFP_KERNEL); - if (ipcm == NULL) - return -ENOMEM; - if (copy_from_user(ipcm, argp, sizeof(*ipcm))) { - kfree(ipcm); - return -EFAULT; - } + ipcm = memdup_user(argp, sizeof(*ipcm)); + if (IS_ERR(ipcm)) + return PTR_ERR(ipcm); res = snd_emu10k1_ipcm_poke(emu, ipcm); kfree(ipcm); return res; case SNDRV_EMU10K1_IOCTL_PCM_PEEK: - ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL); - if (ipcm == NULL) - return -ENOMEM; - if (copy_from_user(ipcm, argp, sizeof(*ipcm))) { - kfree(ipcm); - return -EFAULT; - } + ipcm = memdup_user(argp, sizeof(*ipcm)); + if (IS_ERR(ipcm)) + return PTR_ERR(ipcm); res = snd_emu10k1_ipcm_peek(emu, ipcm); if (res == 0 && copy_to_user(argp, ipcm, sizeof(*ipcm))) { kfree(ipcm); diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index a4e5e59521157d8598553bc989b5e40e84b19a86..fd6e6f337d1054a7adc364738c31a2f77b153743 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -2250,7 +2250,11 @@ int snd_hda_codec_write_cache(struct hda_codec *codec, hda_nid_t nid, err = bus->ops.command(bus, res); if (!err) { struct hda_cache_head *c; - u32 key = build_cmd_cache_key(nid, verb); + u32 key; + /* parm may contain the verb stuff for get/set amp */ + verb = verb | (parm >> 8); + parm &= 0xff; + key = build_cmd_cache_key(nid, verb); c = get_alloc_hash(&codec->cmd_cache, key); if (c) c->val = parm; diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 7ba8db5d4c42176787b283aea0246685d63342f9..bc882f8f163c4f9843d9f594c81d5b90036af2ae 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -312,6 +312,9 @@ struct azx_dev { unsigned int period_bytes; /* size of the period in bytes */ unsigned int frags; /* number for period in the play buffer */ unsigned int fifo_size; /* FIFO size */ + unsigned int start_flag: 1; /* stream full start flag */ + unsigned long start_jiffies; /* start + minimum jiffies */ + unsigned long min_jiffies; /* minimum jiffies before position is valid */ void __iomem *sd_addr; /* stream descriptor pointer */ @@ -330,7 +333,6 @@ struct azx_dev { unsigned int opened :1; unsigned int running :1; unsigned int irq_pending :1; - unsigned int irq_ignore :1; /* * For VIA: * A flag to ensure DMA position is 0 @@ -975,7 +977,7 @@ static irqreturn_t azx_interrupt(int irq, void *dev_id) struct azx *chip = dev_id; struct azx_dev *azx_dev; u32 status; - int i; + int i, ok; spin_lock(&chip->reg_lock); @@ -991,18 +993,14 @@ static irqreturn_t azx_interrupt(int irq, void *dev_id) azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK); if (!azx_dev->substream || !azx_dev->running) continue; - /* ignore the first dummy IRQ (due to pos_adj) */ - if (azx_dev->irq_ignore) { - azx_dev->irq_ignore = 0; - continue; - } /* check whether this IRQ is really acceptable */ - if (azx_position_ok(chip, azx_dev)) { + ok = azx_position_ok(chip, azx_dev); + if (ok == 1) { azx_dev->irq_pending = 0; spin_unlock(&chip->reg_lock); snd_pcm_period_elapsed(azx_dev->substream); spin_lock(&chip->reg_lock); - } else if (chip->bus && chip->bus->workq) { + } else if (ok == 0 && chip->bus && chip->bus->workq) { /* bogus IRQ, process it later */ azx_dev->irq_pending = 1; queue_work(chip->bus->workq, @@ -1088,7 +1086,6 @@ static int azx_setup_periods(struct azx *chip, bdl = (u32 *)azx_dev->bdl.area; ofs = 0; azx_dev->frags = 0; - azx_dev->irq_ignore = 0; pos_adj = bdl_pos_adj[chip->dev_index]; if (pos_adj > 0) { struct snd_pcm_runtime *runtime = substream->runtime; @@ -1109,7 +1106,6 @@ static int azx_setup_periods(struct azx *chip, &bdl, ofs, pos_adj, 1); if (ofs < 0) goto error; - azx_dev->irq_ignore = 1; } } else pos_adj = 0; @@ -1155,6 +1151,9 @@ static void azx_stream_reset(struct azx *chip, struct azx_dev *azx_dev) while (((val = azx_sd_readb(azx_dev, SD_CTL)) & SD_CTL_STREAM_RESET) && --timeout) ; + + /* reset first position - may not be synced with hw at this time */ + *azx_dev->posbuf = 0; } /* @@ -1409,7 +1408,6 @@ static int azx_pcm_open(struct snd_pcm_substream *substream) snd_pcm_set_sync(substream); mutex_unlock(&chip->open_mutex); - azx_stream_reset(chip, azx_dev); return 0; } @@ -1474,6 +1472,7 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream) unsigned int bufsize, period_bytes, format_val; int err; + azx_stream_reset(chip, azx_dev); format_val = snd_hda_calc_stream_format(runtime->rate, runtime->channels, runtime->format, @@ -1502,6 +1501,8 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream) return err; } + azx_dev->min_jiffies = (runtime->period_size * HZ) / + (runtime->rate * 2); azx_setup_controller(chip, azx_dev); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) azx_dev->fifo_size = azx_sd_readw(azx_dev, SD_FIFOSIZE) + 1; @@ -1518,13 +1519,14 @@ static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) struct azx *chip = apcm->chip; struct azx_dev *azx_dev; struct snd_pcm_substream *s; - int start, nsync = 0, sbits = 0; + int rstart = 0, start, nsync = 0, sbits = 0; int nwait, timeout; switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + rstart = 1; case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: case SNDRV_PCM_TRIGGER_RESUME: - case SNDRV_PCM_TRIGGER_START: start = 1; break; case SNDRV_PCM_TRIGGER_PAUSE_PUSH: @@ -1554,6 +1556,10 @@ static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) if (s->pcm->card != substream->pcm->card) continue; azx_dev = get_azx_dev(s); + if (rstart) { + azx_dev->start_flag = 1; + azx_dev->start_jiffies = jiffies + azx_dev->min_jiffies; + } if (start) azx_stream_start(chip, azx_dev); else @@ -1703,6 +1709,11 @@ static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev) { unsigned int pos; + if (azx_dev->start_flag && + time_before_eq(jiffies, azx_dev->start_jiffies)) + return -1; /* bogus (too early) interrupt */ + azx_dev->start_flag = 0; + pos = azx_get_position(chip, azx_dev); if (chip->position_fix == POS_FIX_AUTO) { if (!pos) { diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 1f2ad76ca94b1d077f1bd7550eae9c789a23802e..56ce19e68cb5838a24e675828bb990f296717a24 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -350,12 +350,20 @@ static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol, } #ifdef CONFIG_SND_JACK +static void conexant_free_jack_priv(struct snd_jack *jack) +{ + struct conexant_jack *jacks = jack->private_data; + jacks->nid = 0; + jacks->jack = NULL; +} + static int conexant_add_jack(struct hda_codec *codec, hda_nid_t nid, int type) { struct conexant_spec *spec; struct conexant_jack *jack; const char *name; + int err; spec = codec->spec; snd_array_init(&spec->jacks, sizeof(*jack), 32); @@ -368,7 +376,12 @@ static int conexant_add_jack(struct hda_codec *codec, jack->nid = nid; jack->type = type; - return snd_jack_new(codec->bus->card, name, type, &jack->jack); + err = snd_jack_new(codec->bus->card, name, type, &jack->jack); + if (err < 0) + return err; + jack->jack->private_data = jack; + jack->jack->private_free = conexant_free_jack_priv; + return 0; } static void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid) @@ -455,8 +468,10 @@ static void conexant_free(struct hda_codec *codec) if (spec->jacks.list) { struct conexant_jack *jacks = spec->jacks.list; int i; - for (i = 0; i < spec->jacks.used; i++) - snd_device_free(codec->bus->card, &jacks[i].jack); + for (i = 0; i < spec->jacks.used; i++, jacks++) { + if (jacks->jack) + snd_device_free(codec->bus->card, jacks->jack); + } snd_array_free(&spec->jacks); } #endif diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index f35e58a2d9212a2e4870d6fefdf6f311835b6762..6ed787eedd067b5c45963eb21376d67a93c60ae3 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -8742,10 +8742,9 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = { SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD), SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch), SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), - SND_PCI_QUIRK(0x1734, 0x1107, "FSC AMILO Xi2550", + SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx", ALC883_FUJITSU_PI2515), - SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515), - SND_PCI_QUIRK(0x1734, 0x113d, "Fujitsu AMILO Xa3530", + SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx", ALC888_FUJITSU_XA3530), SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch), SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763), diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 61996a2f45dfdb02f9fda284ea9256356b5a7903..ce30b459aee66dd1ee4a4fad9d98074004542be3 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -3851,6 +3851,15 @@ static void stac_gpio_set(struct hda_codec *codec, unsigned int mask, AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */ } +#ifdef CONFIG_SND_JACK +static void stac92xx_free_jack_priv(struct snd_jack *jack) +{ + struct sigmatel_jack *jacks = jack->private_data; + jacks->nid = 0; + jacks->jack = NULL; +} +#endif + static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type) { @@ -3860,6 +3869,7 @@ static int stac92xx_add_jack(struct hda_codec *codec, int def_conf = snd_hda_codec_get_pincfg(codec, nid); int connectivity = get_defcfg_connect(def_conf); char name[32]; + int err; if (connectivity && connectivity != AC_JACK_PORT_FIXED) return 0; @@ -3876,10 +3886,15 @@ static int stac92xx_add_jack(struct hda_codec *codec, snd_hda_get_jack_connectivity(def_conf), snd_hda_get_jack_location(def_conf)); - return snd_jack_new(codec->bus->card, name, type, &jack->jack); -#else - return 0; + err = snd_jack_new(codec->bus->card, name, type, &jack->jack); + if (err < 0) { + jack->nid = 0; + return err; + } + jack->jack->private_data = jack; + jack->jack->private_free = stac92xx_free_jack_priv; #endif + return 0; } static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid, @@ -4138,8 +4153,10 @@ static void stac92xx_free_jacks(struct hda_codec *codec) if (!codec->bus->shutdown && spec->jacks.list) { struct sigmatel_jack *jacks = spec->jacks.list; int i; - for (i = 0; i < spec->jacks.used; i++) - snd_device_free(codec->bus->card, &jacks[i].jack); + for (i = 0; i < spec->jacks.used; i++, jacks++) { + if (jacks->jack) + snd_device_free(codec->bus->card, jacks->jack); + } } snd_array_free(&spec->jacks); #endif diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index 57648810eaf16430049f9e3300441e2a58954b9f..5dced5b793873409f32bd20f3e06588de8dfb662 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -355,6 +355,9 @@ struct ichdev { unsigned int fragsize1; unsigned int position; unsigned int pos_shift; + unsigned int last_pos; + unsigned long last_pos_jiffies; + unsigned int jiffy_to_bytes; int frags; int lvi; int lvi_frag; @@ -838,7 +841,10 @@ static int snd_intel8x0_pcm_trigger(struct snd_pcm_substream *substream, int cmd ichdev->suspended = 0; /* fallthru */ case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: val = ICH_IOCE | ICH_STARTBM; + ichdev->last_pos = ichdev->position; + ichdev->last_pos_jiffies = jiffies; break; case SNDRV_PCM_TRIGGER_SUSPEND: ichdev->suspended = 1; @@ -849,9 +855,6 @@ static int snd_intel8x0_pcm_trigger(struct snd_pcm_substream *substream, int cmd case SNDRV_PCM_TRIGGER_PAUSE_PUSH: val = ICH_IOCE; break; - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - val = ICH_IOCE | ICH_STARTBM; - break; default: return -EINVAL; } @@ -1045,6 +1048,7 @@ static int snd_intel8x0_pcm_prepare(struct snd_pcm_substream *substream) ichdev->pos_shift = (runtime->sample_bits > 16) ? 2 : 1; } snd_intel8x0_setup_periods(chip, ichdev); + ichdev->jiffy_to_bytes = (runtime->rate * 4 * ichdev->pos_shift) / HZ; return 0; } @@ -1053,7 +1057,7 @@ static snd_pcm_uframes_t snd_intel8x0_pcm_pointer(struct snd_pcm_substream *subs struct intel8x0 *chip = snd_pcm_substream_chip(substream); struct ichdev *ichdev = get_ichdev(substream); size_t ptr1, ptr; - int civ, timeout = 100; + int civ, timeout = 10; unsigned int position; spin_lock(&chip->reg_lock); @@ -1069,9 +1073,19 @@ static snd_pcm_uframes_t snd_intel8x0_pcm_pointer(struct snd_pcm_substream *subs ptr1 == igetword(chip, ichdev->reg_offset + ichdev->roff_picb)) break; } while (timeout--); - ptr1 <<= ichdev->pos_shift; - ptr = ichdev->fragsize1 - ptr1; - ptr += position; + if (ptr1 != 0) { + ptr1 <<= ichdev->pos_shift; + ptr = ichdev->fragsize1 - ptr1; + ptr += position; + ichdev->last_pos = ptr; + ichdev->last_pos_jiffies = jiffies; + } else { + ptr1 = jiffies - ichdev->last_pos_jiffies; + if (ptr1) + ptr1 -= 1; + ptr = ichdev->last_pos + ptr1 * ichdev->jiffy_to_bytes; + ptr %= ichdev->size; + } spin_unlock(&chip->reg_lock); if (ptr >= ichdev->size) return 0; @@ -2661,12 +2675,14 @@ static void __devinit intel8x0_measure_ac97_clock(struct intel8x0 *chip) struct snd_pcm_substream *subs; struct ichdev *ichdev; unsigned long port; - unsigned long pos, t; - struct timeval start_time, stop_time; + unsigned long pos, pos1, t; + int civ, timeout = 1000, attempt = 1; + struct timespec start_time, stop_time; if (chip->ac97_bus->clock != 48000) return; /* specified in module option */ + __again: subs = chip->pcm[0]->streams[0].substream; if (! subs || subs->dma_buffer.bytes < INTEL8X0_TESTBUF_SIZE) { snd_printk(KERN_WARNING "no playback buffer allocated - aborting measure ac97 clock\n"); @@ -2674,7 +2690,7 @@ static void __devinit intel8x0_measure_ac97_clock(struct intel8x0 *chip) } ichdev = &chip->ichd[ICHD_PCMOUT]; ichdev->physbuf = subs->dma_buffer.addr; - ichdev->size = chip->ichd[ICHD_PCMOUT].fragsize = INTEL8X0_TESTBUF_SIZE; + ichdev->size = ichdev->fragsize = INTEL8X0_TESTBUF_SIZE; ichdev->substream = NULL; /* don't process interrupts */ /* set rate */ @@ -2693,16 +2709,31 @@ static void __devinit intel8x0_measure_ac97_clock(struct intel8x0 *chip) iputbyte(chip, port + ICH_REG_OFF_CR, ICH_IOCE); iputdword(chip, ICHREG(ALI_DMACR), 1 << ichdev->ali_slot); } - do_gettimeofday(&start_time); + do_posix_clock_monotonic_gettime(&start_time); spin_unlock_irq(&chip->reg_lock); msleep(50); spin_lock_irq(&chip->reg_lock); /* check the position */ - pos = ichdev->fragsize1; - pos -= igetword(chip, ichdev->reg_offset + ichdev->roff_picb) << ichdev->pos_shift; - pos += ichdev->position; + do { + civ = igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV); + pos1 = igetword(chip, ichdev->reg_offset + ichdev->roff_picb); + if (pos1 == 0) { + udelay(10); + continue; + } + if (civ == igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV) && + pos1 == igetword(chip, ichdev->reg_offset + ichdev->roff_picb)) + break; + } while (timeout--); + if (pos1 == 0) { /* oops, this value is not reliable */ + pos = 0; + } else { + pos = ichdev->fragsize1; + pos -= pos1 << ichdev->pos_shift; + pos += ichdev->position; + } chip->in_measurement = 0; - do_gettimeofday(&stop_time); + do_posix_clock_monotonic_gettime(&stop_time); /* stop */ if (chip->device_type == DEVICE_ALI) { iputdword(chip, ICHREG(ALI_DMACR), 1 << (ichdev->ali_slot + 16)); @@ -2717,19 +2748,37 @@ static void __devinit intel8x0_measure_ac97_clock(struct intel8x0 *chip) iputbyte(chip, port + ICH_REG_OFF_CR, ICH_RESETREGS); spin_unlock_irq(&chip->reg_lock); + if (pos == 0) { + snd_printk(KERN_ERR "intel8x0: measure - unreliable DMA position..\n"); + __retry: + if (attempt < 2) { + attempt++; + goto __again; + } + return; + } + + pos /= 4; t = stop_time.tv_sec - start_time.tv_sec; t *= 1000000; - t += stop_time.tv_usec - start_time.tv_usec; - printk(KERN_INFO "%s: measured %lu usecs\n", __func__, t); + t += (stop_time.tv_nsec - start_time.tv_nsec) / 1000; + printk(KERN_INFO "%s: measured %lu usecs (%lu samples)\n", __func__, t, pos); if (t == 0) { - snd_printk(KERN_ERR "?? calculation error..\n"); - return; + snd_printk(KERN_ERR "intel8x0: ?? calculation error..\n"); + goto __retry; } - pos = (pos / 4) * 1000; + pos *= 1000; pos = (pos / t) * 1000 + ((pos % t) * 1000) / t; - if (pos < 40000 || pos >= 60000) + if (pos < 40000 || pos >= 60000) { /* abnormal value. hw problem? */ printk(KERN_INFO "intel8x0: measured clock %ld rejected\n", pos); + goto __retry; + } else if (pos > 40500 && pos < 41500) + /* first exception - 41000Hz reference clock */ + chip->ac97_bus->clock = 41000; + else if (pos > 43600 && pos < 44600) + /* second exception - 44100HZ reference clock */ + chip->ac97_bus->clock = 44100; else if (pos < 47500 || pos > 48500) /* not 48000Hz, tuning the clock.. */ chip->ac97_bus->clock = (chip->ac97_bus->clock * 48000) / pos; diff --git a/sound/soc/pxa/magician.c b/sound/soc/pxa/magician.c index f7c4544f7859d8a1f81b37ced890af4cf9e012f1..0625c342a1c909b9f14f7d5f05fad3a8f1060886 100644 --- a/sound/soc/pxa/magician.c +++ b/sound/soc/pxa/magician.c @@ -27,8 +27,6 @@ #include #include -#include -#include #include #include #include "../codecs/uda1380.h" diff --git a/sound/soc/s3c24xx/Kconfig b/sound/soc/s3c24xx/Kconfig index 2f3a21eee051750c99aaca707e7fda6b10c750bd..df494d1e346f9197b11864a13ad456384c516871 100644 --- a/sound/soc/s3c24xx/Kconfig +++ b/sound/soc/s3c24xx/Kconfig @@ -1,10 +1,10 @@ config SND_S3C24XX_SOC tristate "SoC Audio for the Samsung S3CXXXX chips" - depends on ARCH_S3C2410 || ARCH_S3C64XX + depends on ARCH_S3C2410 help Say Y or M if you want to add support for codecs attached to - the S3C24XX and S3C64XX AC97, I2S or SSP interface. You will - also need to select the audio interfaces to support below. + the S3C24XX AC97 or I2S interfaces. You will also need to + select the audio interfaces to support below. config SND_S3C24XX_SOC_I2S tristate diff --git a/sound/usb/caiaq/Makefile b/sound/usb/caiaq/Makefile index 23dadd5a11cd2d3e664ee96a12dbac4087ab2bfc..388999653aaad096f23a16c49514e90d054f34da 100644 --- a/sound/usb/caiaq/Makefile +++ b/sound/usb/caiaq/Makefile @@ -1,4 +1,4 @@ -snd-usb-caiaq-y := caiaq-device.o caiaq-audio.o caiaq-midi.o caiaq-control.o -snd-usb-caiaq-$(CONFIG_SND_USB_CAIAQ_INPUT) += caiaq-input.o +snd-usb-caiaq-y := device.o audio.o midi.o control.o +snd-usb-caiaq-$(CONFIG_SND_USB_CAIAQ_INPUT) += input.o obj-$(CONFIG_SND_USB_CAIAQ) += snd-usb-caiaq.o diff --git a/sound/usb/caiaq/caiaq-audio.c b/sound/usb/caiaq/audio.c similarity index 98% rename from sound/usb/caiaq/caiaq-audio.c rename to sound/usb/caiaq/audio.c index 08d51e0c9feae466175f87cb45fe87cebbcd13ec..3f45c0fe61ab9771cbfdcc952dcb7e33f1657c74 100644 --- a/sound/usb/caiaq/caiaq-audio.c +++ b/sound/usb/caiaq/audio.c @@ -16,20 +16,14 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include #include -#include -#include -#include #include -#include #include -#include #include -#include -#include -#include "caiaq-device.h" -#include "caiaq-audio.h" +#include "device.h" +#include "audio.h" #define N_URBS 32 #define CLOCK_DRIFT_TOLERANCE 5 diff --git a/sound/usb/caiaq/caiaq-audio.h b/sound/usb/caiaq/audio.h similarity index 100% rename from sound/usb/caiaq/caiaq-audio.h rename to sound/usb/caiaq/audio.h diff --git a/sound/usb/caiaq/caiaq-control.c b/sound/usb/caiaq/control.c similarity index 98% rename from sound/usb/caiaq/caiaq-control.c rename to sound/usb/caiaq/control.c index e92c2bbf4fe92742aa4f99a16d735d0996f7f8c9..537102ba6b9d8cc46356ee5a48f19f76642bfedd 100644 --- a/sound/usb/caiaq/caiaq-control.c +++ b/sound/usb/caiaq/control.c @@ -18,17 +18,13 @@ */ #include -#include #include +#include #include -#include #include -#include -#include -#include -#include "caiaq-device.h" -#include "caiaq-control.h" +#include "device.h" +#include "control.h" #define CNT_INTVAL 0x10000 diff --git a/sound/usb/caiaq/caiaq-control.h b/sound/usb/caiaq/control.h similarity index 100% rename from sound/usb/caiaq/caiaq-control.h rename to sound/usb/caiaq/control.h diff --git a/sound/usb/caiaq/caiaq-device.c b/sound/usb/caiaq/device.c similarity index 98% rename from sound/usb/caiaq/caiaq-device.c rename to sound/usb/caiaq/device.c index cf573a982fdc542b71e4fe6f3cd891f44f018ba2..6d517705da0e7705292f96e0f23d8626a4f9e015 100644 --- a/sound/usb/caiaq/caiaq-device.c +++ b/sound/usb/caiaq/device.c @@ -19,27 +19,20 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include #include #include +#include +#include #include -#include -#include -#include #include +#include #include -#include -#include - -#include "caiaq-device.h" -#include "caiaq-audio.h" -#include "caiaq-midi.h" -#include "caiaq-control.h" -#ifdef CONFIG_SND_USB_CAIAQ_INPUT -#include "caiaq-input.h" -#endif +#include "device.h" +#include "audio.h" +#include "midi.h" +#include "control.h" +#include "input.h" MODULE_AUTHOR("Daniel Mack "); MODULE_DESCRIPTION("caiaq USB audio, version 1.3.13"); diff --git a/sound/usb/caiaq/caiaq-device.h b/sound/usb/caiaq/device.h similarity index 100% rename from sound/usb/caiaq/caiaq-device.h rename to sound/usb/caiaq/device.h diff --git a/sound/usb/caiaq/caiaq-input.c b/sound/usb/caiaq/input.c similarity index 98% rename from sound/usb/caiaq/caiaq-input.c rename to sound/usb/caiaq/input.c index f743847a5e5a0a9e8aa7d1e8a67ccb204586821a..a48d309bd94cb15757c79408d42bbcdf298adbed 100644 --- a/sound/usb/caiaq/caiaq-input.c +++ b/sound/usb/caiaq/input.c @@ -17,17 +17,12 @@ */ #include -#include -#include -#include #include #include -#include -#include -#include #include -#include "caiaq-device.h" -#include "caiaq-input.h" + +#include "device.h" +#include "input.h" static unsigned short keycode_ak1[] = { KEY_C, KEY_B, KEY_A }; static unsigned short keycode_rk2[] = { KEY_1, KEY_2, KEY_3, KEY_4, diff --git a/sound/usb/caiaq/caiaq-input.h b/sound/usb/caiaq/input.h similarity index 100% rename from sound/usb/caiaq/caiaq-input.h rename to sound/usb/caiaq/input.h diff --git a/sound/usb/caiaq/caiaq-midi.c b/sound/usb/caiaq/midi.c similarity index 95% rename from sound/usb/caiaq/caiaq-midi.c rename to sound/usb/caiaq/midi.c index f19fd360c9367b76fdb4df440743fea019dc7d77..8fa8cd88d7634689592b7b512d85640a7128de5e 100644 --- a/sound/usb/caiaq/caiaq-midi.c +++ b/sound/usb/caiaq/midi.c @@ -16,20 +16,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include -#include -#include #include -#include -#include -#include #include +#include #include -#include "caiaq-device.h" -#include "caiaq-midi.h" - +#include "device.h" +#include "midi.h" static int snd_usb_caiaq_midi_input_open(struct snd_rawmidi_substream *substream) { diff --git a/sound/usb/caiaq/caiaq-midi.h b/sound/usb/caiaq/midi.h similarity index 100% rename from sound/usb/caiaq/caiaq-midi.h rename to sound/usb/caiaq/midi.h diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c index 98276aafefe605040d7c18cd367fa4aa8096bd5a..012ff1f6f8af50436d27ffeb28113aab72e16c1d 100644 --- a/sound/usb/usx2y/us122l.c +++ b/sound/usb/usx2y/us122l.c @@ -349,14 +349,10 @@ static int usb_stream_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, if (cmd != SNDRV_USB_STREAM_IOCTL_SET_PARAMS) return -ENOTTY; - cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); - if (!cfg) - return -ENOMEM; + cfg = memdup_user((void *)arg, sizeof(*cfg)); + if (IS_ERR(cfg)) + return PTR_ERR(cfg); - if (copy_from_user(cfg, (void *)arg, sizeof(*cfg))) { - err = -EFAULT; - goto free; - } if (cfg->version != USB_STREAM_INTERFACE_VERSION) { err = -ENXIO; goto free; diff --git a/sound/usb/usx2y/usX2Yhwdep.c b/sound/usb/usx2y/usX2Yhwdep.c index 4af8740db7170ea34734037d6544d49ffd8e8953..f3d8f71265dd3bfee1540442184ed226a5f88cf6 100644 --- a/sound/usb/usx2y/usX2Yhwdep.c +++ b/sound/usb/usx2y/usX2Yhwdep.c @@ -203,13 +203,12 @@ static int snd_usX2Y_hwdep_dsp_load(struct snd_hwdep *hw, if (access_ok(VERIFY_READ, dsp->image, dsp->length)) { struct usb_device* dev = priv->chip.dev; - char *buf = kmalloc(dsp->length, GFP_KERNEL); - if (!buf) - return -ENOMEM; - if (copy_from_user(buf, dsp->image, dsp->length)) { - kfree(buf); - return -EFAULT; - } + char *buf; + + buf = memdup_user(dsp->image, dsp->length); + if (IS_ERR(buf)) + return PTR_ERR(buf); + err = usb_set_interface(dev, 0, 1); if (err) snd_printk(KERN_ERR "usb_set_interface error \n");