summaryrefslogtreecommitdiff
path: root/sound/core/rawmidi.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-01-31 23:16:28 (GMT)
committerLinus Torvalds <torvalds@linux-foundation.org>2008-01-31 23:16:28 (GMT)
commite1a9c9872dd004617555dff079b357a6ffd945e9 (patch)
treec34779e59712ff345f8e4ee97e74086a85b34974 /sound/core/rawmidi.c
parentfcc3ff4f9d695a80dc6e6058e0d631a3026ed4c3 (diff)
parent2ecba4ffbbc6c85fce8c3878514be415edace413 (diff)
downloadlinux-fsl-qoriq-e1a9c9872dd004617555dff079b357a6ffd945e9.tar.xz
Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/perex/alsa
* 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/perex/alsa: (299 commits) [ALSA] version 1.0.16rc2 [ALSA] hda: fix Mic in as output [ALSA] emu10k1 - Another EMU0404 Board ID [ALSA] emu10k1 - Fix kthread handling at resume [ALSA] emu10k1: General cleanup, add new locks, fix alsa bug#3501, kernel bug#9304. [ALSA] emu10k1 - Use enum for emu_model types [ALSA] emu10k1 - Don't create emu1010 controls for non-emu boards [ALSA] emu10k1 - 1616(M) cardbus improvements [ALSA] snd:emu10k1: E-Mu updates. Fixes to firmware loading and support for 0404. [ALSA] emu10k1: Add comments regarding E-Mu ins and outs. [ALSA] oxygen: revert SPI clock frequency change for AK4396/WM8785 [ALSA] es1938 - improve capture hw pointer reads [ALSA] HDA-Intel - Add support for Intel SCH [ALSA] hda: Add GPIO mute support to STAC9205 [ALSA] hda-codec - Add Dell T3400 support [ALSA] hda-codec - Add model for HP DV9553EG laptop [ALSA] hda-codec - Control SPDIF as slave [ALSA] hda_intel: ALSA HD Audio patch for Intel ICH10 DeviceID's [ALSA] Fix Oops with PCM OSS sync [ALSA] hda-codec - Add speaker automute to ALC262 HP models ...
Diffstat (limited to 'sound/core/rawmidi.c')
-rw-r--r--sound/core/rawmidi.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
index b8e700b..f7ea728 100644
--- a/sound/core/rawmidi.c
+++ b/sound/core/rawmidi.c
@@ -19,7 +19,6 @@
*
*/
-#include <sound/driver.h>
#include <sound/core.h>
#include <linux/major.h>
#include <linux/init.h>
@@ -912,7 +911,8 @@ int snd_rawmidi_receive(struct snd_rawmidi_substream *substream,
}
static long snd_rawmidi_kernel_read1(struct snd_rawmidi_substream *substream,
- unsigned char *buf, long count, int kernel)
+ unsigned char __user *userbuf,
+ unsigned char *kernelbuf, long count)
{
unsigned long flags;
long result = 0, count1;
@@ -925,11 +925,11 @@ static long snd_rawmidi_kernel_read1(struct snd_rawmidi_substream *substream,
spin_lock_irqsave(&runtime->lock, flags);
if (count1 > (int)runtime->avail)
count1 = runtime->avail;
- if (kernel) {
- memcpy(buf + result, runtime->buffer + runtime->appl_ptr, count1);
- } else {
+ if (kernelbuf)
+ memcpy(kernelbuf + result, runtime->buffer + runtime->appl_ptr, count1);
+ if (userbuf) {
spin_unlock_irqrestore(&runtime->lock, flags);
- if (copy_to_user((char __user *)buf + result,
+ if (copy_to_user(userbuf + result,
runtime->buffer + runtime->appl_ptr, count1)) {
return result > 0 ? result : -EFAULT;
}
@@ -949,7 +949,7 @@ long snd_rawmidi_kernel_read(struct snd_rawmidi_substream *substream,
unsigned char *buf, long count)
{
snd_rawmidi_input_trigger(substream, 1);
- return snd_rawmidi_kernel_read1(substream, buf, count, 1);
+ return snd_rawmidi_kernel_read1(substream, NULL/*userbuf*/, buf, count);
}
static ssize_t snd_rawmidi_read(struct file *file, char __user *buf, size_t count,
@@ -990,8 +990,9 @@ static ssize_t snd_rawmidi_read(struct file *file, char __user *buf, size_t coun
}
spin_unlock_irq(&runtime->lock);
count1 = snd_rawmidi_kernel_read1(substream,
- (unsigned char __force *)buf,
- count, 0);
+ (unsigned char __user *)buf,
+ NULL/*kernelbuf*/,
+ count);
if (count1 < 0)
return result > 0 ? result : count1;
result += count1;
@@ -1132,13 +1133,15 @@ int snd_rawmidi_transmit(struct snd_rawmidi_substream *substream,
}
static long snd_rawmidi_kernel_write1(struct snd_rawmidi_substream *substream,
- const unsigned char *buf, long count, int kernel)
+ const unsigned char __user *userbuf,
+ const unsigned char *kernelbuf,
+ long count)
{
unsigned long flags;
long count1, result;
struct snd_rawmidi_runtime *runtime = substream->runtime;
- snd_assert(buf != NULL, return -EINVAL);
+ snd_assert(kernelbuf != NULL || userbuf != NULL, return -EINVAL);
snd_assert(runtime->buffer != NULL, return -EINVAL);
result = 0;
@@ -1155,12 +1158,13 @@ static long snd_rawmidi_kernel_write1(struct snd_rawmidi_substream *substream,
count1 = count;
if (count1 > (long)runtime->avail)
count1 = runtime->avail;
- if (kernel) {
- memcpy(runtime->buffer + runtime->appl_ptr, buf, count1);
- } else {
+ if (kernelbuf)
+ memcpy(runtime->buffer + runtime->appl_ptr,
+ kernelbuf + result, count1);
+ else if (userbuf) {
spin_unlock_irqrestore(&runtime->lock, flags);
if (copy_from_user(runtime->buffer + runtime->appl_ptr,
- (char __user *)buf, count1)) {
+ userbuf + result, count1)) {
spin_lock_irqsave(&runtime->lock, flags);
result = result > 0 ? result : -EFAULT;
goto __end;
@@ -1171,7 +1175,6 @@ static long snd_rawmidi_kernel_write1(struct snd_rawmidi_substream *substream,
runtime->appl_ptr %= runtime->buffer_size;
runtime->avail -= count1;
result += count1;
- buf += count1;
count -= count1;
}
__end:
@@ -1185,7 +1188,7 @@ static long snd_rawmidi_kernel_write1(struct snd_rawmidi_substream *substream,
long snd_rawmidi_kernel_write(struct snd_rawmidi_substream *substream,
const unsigned char *buf, long count)
{
- return snd_rawmidi_kernel_write1(substream, buf, count, 1);
+ return snd_rawmidi_kernel_write1(substream, NULL, buf, count);
}
static ssize_t snd_rawmidi_write(struct file *file, const char __user *buf,
@@ -1225,9 +1228,7 @@ static ssize_t snd_rawmidi_write(struct file *file, const char __user *buf,
spin_lock_irq(&runtime->lock);
}
spin_unlock_irq(&runtime->lock);
- count1 = snd_rawmidi_kernel_write1(substream,
- (unsigned char __force *)buf,
- count, 0);
+ count1 = snd_rawmidi_kernel_write1(substream, buf, NULL, count);
if (count1 < 0)
return result > 0 ? result : count1;
result += count1;