Commit 5851bd06 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] sparse: sound/core/pcm* annotation

The tricky part here was an iterator that used to take a callback and
argument for that callback as parameters.  Iterator itself didn't care
what type that argument had been; it's entirely up to callback.  The
thing is, two callbacks expect (and get) char __user * while other two
expect (and also get) char __user **.

Iterator used to use void * as "opaque data"; I've switched it to
unsigned long.  Note that there was nothing that said "it's a pointer" -
use of callback that would take e.g.  int is also perfectly legitimate. 

The rest is triviali annotation.
parent 52e441e4
...@@ -2049,12 +2049,12 @@ void snd_pcm_period_elapsed(snd_pcm_substream_t *substream) ...@@ -2049,12 +2049,12 @@ void snd_pcm_period_elapsed(snd_pcm_substream_t *substream)
static int snd_pcm_lib_write_transfer(snd_pcm_substream_t *substream, static int snd_pcm_lib_write_transfer(snd_pcm_substream_t *substream,
unsigned int hwoff, unsigned int hwoff,
void *data, unsigned int off, unsigned long data, unsigned int off,
snd_pcm_uframes_t frames) snd_pcm_uframes_t frames)
{ {
snd_pcm_runtime_t *runtime = substream->runtime; snd_pcm_runtime_t *runtime = substream->runtime;
int err; int err;
char *buf = (char *) data + frames_to_bytes(runtime, off); char __user *buf = (char __user *) data + frames_to_bytes(runtime, off);
if (substream->ops->copy) { if (substream->ops->copy) {
if ((err = substream->ops->copy(substream, -1, hwoff, buf, frames)) < 0) if ((err = substream->ops->copy(substream, -1, hwoff, buf, frames)) < 0)
return err; return err;
...@@ -2068,10 +2068,12 @@ static int snd_pcm_lib_write_transfer(snd_pcm_substream_t *substream, ...@@ -2068,10 +2068,12 @@ static int snd_pcm_lib_write_transfer(snd_pcm_substream_t *substream,
} }
typedef int (*transfer_f)(snd_pcm_substream_t *substream, unsigned int hwoff, typedef int (*transfer_f)(snd_pcm_substream_t *substream, unsigned int hwoff,
void *data, unsigned int off, snd_pcm_uframes_t size); unsigned long data, unsigned int off,
snd_pcm_uframes_t size);
static snd_pcm_sframes_t snd_pcm_lib_write1(snd_pcm_substream_t *substream, static snd_pcm_sframes_t snd_pcm_lib_write1(snd_pcm_substream_t *substream,
const void *data, snd_pcm_uframes_t size, unsigned long data,
snd_pcm_uframes_t size,
int nonblock, int nonblock,
transfer_f transfer) transfer_f transfer)
{ {
...@@ -2186,7 +2188,7 @@ static snd_pcm_sframes_t snd_pcm_lib_write1(snd_pcm_substream_t *substream, ...@@ -2186,7 +2188,7 @@ static snd_pcm_sframes_t snd_pcm_lib_write1(snd_pcm_substream_t *substream,
appl_ptr = runtime->control->appl_ptr; appl_ptr = runtime->control->appl_ptr;
appl_ofs = appl_ptr % runtime->buffer_size; appl_ofs = appl_ptr % runtime->buffer_size;
snd_pcm_stream_unlock_irq(substream); snd_pcm_stream_unlock_irq(substream);
if ((err = transfer(substream, appl_ofs, (void *)data, offset, frames)) < 0) if ((err = transfer(substream, appl_ofs, data, offset, frames)) < 0)
goto _end; goto _end;
snd_pcm_stream_lock_irq(substream); snd_pcm_stream_lock_irq(substream);
switch (runtime->status->state) { switch (runtime->status->state) {
...@@ -2227,7 +2229,7 @@ static snd_pcm_sframes_t snd_pcm_lib_write1(snd_pcm_substream_t *substream, ...@@ -2227,7 +2229,7 @@ static snd_pcm_sframes_t snd_pcm_lib_write1(snd_pcm_substream_t *substream,
return xfer > 0 ? (snd_pcm_sframes_t)xfer : err; return xfer > 0 ? (snd_pcm_sframes_t)xfer : err;
} }
snd_pcm_sframes_t snd_pcm_lib_write(snd_pcm_substream_t *substream, const void *buf, snd_pcm_uframes_t size) snd_pcm_sframes_t snd_pcm_lib_write(snd_pcm_substream_t *substream, const void __user *buf, snd_pcm_uframes_t size)
{ {
snd_pcm_runtime_t *runtime; snd_pcm_runtime_t *runtime;
int nonblock; int nonblock;
...@@ -2256,18 +2258,18 @@ snd_pcm_sframes_t snd_pcm_lib_write(snd_pcm_substream_t *substream, const void * ...@@ -2256,18 +2258,18 @@ snd_pcm_sframes_t snd_pcm_lib_write(snd_pcm_substream_t *substream, const void *
if (runtime->access != SNDRV_PCM_ACCESS_RW_INTERLEAVED && if (runtime->access != SNDRV_PCM_ACCESS_RW_INTERLEAVED &&
runtime->channels > 1) runtime->channels > 1)
return -EINVAL; return -EINVAL;
return snd_pcm_lib_write1(substream, buf, size, nonblock, return snd_pcm_lib_write1(substream, (unsigned long)buf, size, nonblock,
snd_pcm_lib_write_transfer); snd_pcm_lib_write_transfer);
} }
static int snd_pcm_lib_writev_transfer(snd_pcm_substream_t *substream, static int snd_pcm_lib_writev_transfer(snd_pcm_substream_t *substream,
unsigned int hwoff, unsigned int hwoff,
void *data, unsigned int off, unsigned long data, unsigned int off,
snd_pcm_uframes_t frames) snd_pcm_uframes_t frames)
{ {
snd_pcm_runtime_t *runtime = substream->runtime; snd_pcm_runtime_t *runtime = substream->runtime;
int err; int err;
void **bufs = data; void __user **bufs = (void __user **)data;
int channels = runtime->channels; int channels = runtime->channels;
int c; int c;
if (substream->ops->copy) { if (substream->ops->copy) {
...@@ -2277,7 +2279,7 @@ static int snd_pcm_lib_writev_transfer(snd_pcm_substream_t *substream, ...@@ -2277,7 +2279,7 @@ static int snd_pcm_lib_writev_transfer(snd_pcm_substream_t *substream,
if ((err = substream->ops->silence(substream, c, hwoff, frames)) < 0) if ((err = substream->ops->silence(substream, c, hwoff, frames)) < 0)
return err; return err;
} else { } else {
char *buf = *bufs + samples_to_bytes(runtime, off); char __user *buf = *bufs + samples_to_bytes(runtime, off);
if ((err = substream->ops->copy(substream, c, hwoff, buf, frames)) < 0) if ((err = substream->ops->copy(substream, c, hwoff, buf, frames)) < 0)
return err; return err;
} }
...@@ -2291,7 +2293,7 @@ static int snd_pcm_lib_writev_transfer(snd_pcm_substream_t *substream, ...@@ -2291,7 +2293,7 @@ static int snd_pcm_lib_writev_transfer(snd_pcm_substream_t *substream,
if (*bufs == NULL) { if (*bufs == NULL) {
snd_pcm_format_set_silence(runtime->format, hwbuf, frames); snd_pcm_format_set_silence(runtime->format, hwbuf, frames);
} else { } else {
char *buf = *bufs + samples_to_bytes(runtime, off); char __user *buf = *bufs + samples_to_bytes(runtime, off);
if (copy_from_user(hwbuf, buf, samples_to_bytes(runtime, frames))) if (copy_from_user(hwbuf, buf, samples_to_bytes(runtime, frames)))
return -EFAULT; return -EFAULT;
} }
...@@ -2300,7 +2302,8 @@ static int snd_pcm_lib_writev_transfer(snd_pcm_substream_t *substream, ...@@ -2300,7 +2302,8 @@ static int snd_pcm_lib_writev_transfer(snd_pcm_substream_t *substream,
return 0; return 0;
} }
snd_pcm_sframes_t snd_pcm_lib_writev(snd_pcm_substream_t *substream, void **bufs, snd_pcm_sframes_t snd_pcm_lib_writev(snd_pcm_substream_t *substream,
void __user **bufs,
snd_pcm_uframes_t frames) snd_pcm_uframes_t frames)
{ {
snd_pcm_runtime_t *runtime; snd_pcm_runtime_t *runtime;
...@@ -2329,18 +2332,18 @@ snd_pcm_sframes_t snd_pcm_lib_writev(snd_pcm_substream_t *substream, void **bufs ...@@ -2329,18 +2332,18 @@ snd_pcm_sframes_t snd_pcm_lib_writev(snd_pcm_substream_t *substream, void **bufs
if (runtime->access != SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) if (runtime->access != SNDRV_PCM_ACCESS_RW_NONINTERLEAVED)
return -EINVAL; return -EINVAL;
return snd_pcm_lib_write1(substream, bufs, frames, nonblock, return snd_pcm_lib_write1(substream, (unsigned long)bufs, frames,
snd_pcm_lib_writev_transfer); nonblock, snd_pcm_lib_writev_transfer);
} }
static int snd_pcm_lib_read_transfer(snd_pcm_substream_t *substream, static int snd_pcm_lib_read_transfer(snd_pcm_substream_t *substream,
unsigned int hwoff, unsigned int hwoff,
void *data, unsigned int off, unsigned long data, unsigned int off,
snd_pcm_uframes_t frames) snd_pcm_uframes_t frames)
{ {
snd_pcm_runtime_t *runtime = substream->runtime; snd_pcm_runtime_t *runtime = substream->runtime;
int err; int err;
char *buf = (char *) data + frames_to_bytes(runtime, off); char __user *buf = (char __user *) data + frames_to_bytes(runtime, off);
if (substream->ops->copy) { if (substream->ops->copy) {
if ((err = substream->ops->copy(substream, -1, hwoff, buf, frames)) < 0) if ((err = substream->ops->copy(substream, -1, hwoff, buf, frames)) < 0)
return err; return err;
...@@ -2353,7 +2356,10 @@ static int snd_pcm_lib_read_transfer(snd_pcm_substream_t *substream, ...@@ -2353,7 +2356,10 @@ static int snd_pcm_lib_read_transfer(snd_pcm_substream_t *substream,
return 0; return 0;
} }
static snd_pcm_sframes_t snd_pcm_lib_read1(snd_pcm_substream_t *substream, void *data, snd_pcm_uframes_t size, int nonblock, static snd_pcm_sframes_t snd_pcm_lib_read1(snd_pcm_substream_t *substream,
unsigned long data,
snd_pcm_uframes_t size,
int nonblock,
transfer_f transfer) transfer_f transfer)
{ {
snd_pcm_runtime_t *runtime = substream->runtime; snd_pcm_runtime_t *runtime = substream->runtime;
...@@ -2481,7 +2487,7 @@ static snd_pcm_sframes_t snd_pcm_lib_read1(snd_pcm_substream_t *substream, void ...@@ -2481,7 +2487,7 @@ static snd_pcm_sframes_t snd_pcm_lib_read1(snd_pcm_substream_t *substream, void
appl_ptr = runtime->control->appl_ptr; appl_ptr = runtime->control->appl_ptr;
appl_ofs = appl_ptr % runtime->buffer_size; appl_ofs = appl_ptr % runtime->buffer_size;
snd_pcm_stream_unlock_irq(substream); snd_pcm_stream_unlock_irq(substream);
if ((err = transfer(substream, appl_ofs, (void *)data, offset, frames)) < 0) if ((err = transfer(substream, appl_ofs, data, offset, frames)) < 0)
goto _end; goto _end;
snd_pcm_stream_lock_irq(substream); snd_pcm_stream_lock_irq(substream);
switch (runtime->status->state) { switch (runtime->status->state) {
...@@ -2516,7 +2522,7 @@ static snd_pcm_sframes_t snd_pcm_lib_read1(snd_pcm_substream_t *substream, void ...@@ -2516,7 +2522,7 @@ static snd_pcm_sframes_t snd_pcm_lib_read1(snd_pcm_substream_t *substream, void
return xfer > 0 ? (snd_pcm_sframes_t)xfer : err; return xfer > 0 ? (snd_pcm_sframes_t)xfer : err;
} }
snd_pcm_sframes_t snd_pcm_lib_read(snd_pcm_substream_t *substream, void *buf, snd_pcm_uframes_t size) snd_pcm_sframes_t snd_pcm_lib_read(snd_pcm_substream_t *substream, void __user *buf, snd_pcm_uframes_t size)
{ {
snd_pcm_runtime_t *runtime; snd_pcm_runtime_t *runtime;
int nonblock; int nonblock;
...@@ -2543,22 +2549,22 @@ snd_pcm_sframes_t snd_pcm_lib_read(snd_pcm_substream_t *substream, void *buf, sn ...@@ -2543,22 +2549,22 @@ snd_pcm_sframes_t snd_pcm_lib_read(snd_pcm_substream_t *substream, void *buf, sn
#endif #endif
if (runtime->access != SNDRV_PCM_ACCESS_RW_INTERLEAVED) if (runtime->access != SNDRV_PCM_ACCESS_RW_INTERLEAVED)
return -EINVAL; return -EINVAL;
return snd_pcm_lib_read1(substream, buf, size, nonblock, snd_pcm_lib_read_transfer); return snd_pcm_lib_read1(substream, (unsigned long)buf, size, nonblock, snd_pcm_lib_read_transfer);
} }
static int snd_pcm_lib_readv_transfer(snd_pcm_substream_t *substream, static int snd_pcm_lib_readv_transfer(snd_pcm_substream_t *substream,
unsigned int hwoff, unsigned int hwoff,
void *data, unsigned int off, unsigned long data, unsigned int off,
snd_pcm_uframes_t frames) snd_pcm_uframes_t frames)
{ {
snd_pcm_runtime_t *runtime = substream->runtime; snd_pcm_runtime_t *runtime = substream->runtime;
int err; int err;
void **bufs = data; void __user **bufs = (void __user **)data;
int channels = runtime->channels; int channels = runtime->channels;
int c; int c;
if (substream->ops->copy) { if (substream->ops->copy) {
for (c = 0; c < channels; ++c, ++bufs) { for (c = 0; c < channels; ++c, ++bufs) {
char *buf; char __user *buf;
if (*bufs == NULL) if (*bufs == NULL)
continue; continue;
buf = *bufs + samples_to_bytes(runtime, off); buf = *bufs + samples_to_bytes(runtime, off);
...@@ -2569,7 +2575,8 @@ static int snd_pcm_lib_readv_transfer(snd_pcm_substream_t *substream, ...@@ -2569,7 +2575,8 @@ static int snd_pcm_lib_readv_transfer(snd_pcm_substream_t *substream,
snd_pcm_uframes_t dma_csize = runtime->dma_bytes / channels; snd_pcm_uframes_t dma_csize = runtime->dma_bytes / channels;
snd_assert(runtime->dma_area, return -EFAULT); snd_assert(runtime->dma_area, return -EFAULT);
for (c = 0; c < channels; ++c, ++bufs) { for (c = 0; c < channels; ++c, ++bufs) {
char *hwbuf, *buf; char *hwbuf;
char __user *buf;
if (*bufs == NULL) if (*bufs == NULL)
continue; continue;
...@@ -2582,7 +2589,8 @@ static int snd_pcm_lib_readv_transfer(snd_pcm_substream_t *substream, ...@@ -2582,7 +2589,8 @@ static int snd_pcm_lib_readv_transfer(snd_pcm_substream_t *substream,
return 0; return 0;
} }
snd_pcm_sframes_t snd_pcm_lib_readv(snd_pcm_substream_t *substream, void **bufs, snd_pcm_sframes_t snd_pcm_lib_readv(snd_pcm_substream_t *substream,
void __user **bufs,
snd_pcm_uframes_t frames) snd_pcm_uframes_t frames)
{ {
snd_pcm_runtime_t *runtime; snd_pcm_runtime_t *runtime;
...@@ -2611,7 +2619,7 @@ snd_pcm_sframes_t snd_pcm_lib_readv(snd_pcm_substream_t *substream, void **bufs, ...@@ -2611,7 +2619,7 @@ snd_pcm_sframes_t snd_pcm_lib_readv(snd_pcm_substream_t *substream, void **bufs,
if (runtime->access != SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) if (runtime->access != SNDRV_PCM_ACCESS_RW_NONINTERLEAVED)
return -EINVAL; return -EINVAL;
return snd_pcm_lib_read1(substream, bufs, frames, nonblock, snd_pcm_lib_readv_transfer); return snd_pcm_lib_read1(substream, (unsigned long)bufs, frames, nonblock, snd_pcm_lib_readv_transfer);
} }
/* /*
......
...@@ -56,8 +56,8 @@ struct sndrv_pcm_hw_params_old { ...@@ -56,8 +56,8 @@ struct sndrv_pcm_hw_params_old {
#define SNDRV_PCM_IOCTL_HW_REFINE_OLD _IOWR('A', 0x10, struct sndrv_pcm_hw_params_old) #define SNDRV_PCM_IOCTL_HW_REFINE_OLD _IOWR('A', 0x10, struct sndrv_pcm_hw_params_old)
#define SNDRV_PCM_IOCTL_HW_PARAMS_OLD _IOWR('A', 0x11, struct sndrv_pcm_hw_params_old) #define SNDRV_PCM_IOCTL_HW_PARAMS_OLD _IOWR('A', 0x11, struct sndrv_pcm_hw_params_old)
static int snd_pcm_hw_refine_old_user(snd_pcm_substream_t * substream, struct sndrv_pcm_hw_params_old * _oparams); static int snd_pcm_hw_refine_old_user(snd_pcm_substream_t * substream, struct sndrv_pcm_hw_params_old __user * _oparams);
static int snd_pcm_hw_params_old_user(snd_pcm_substream_t * substream, struct sndrv_pcm_hw_params_old * _oparams); static int snd_pcm_hw_params_old_user(snd_pcm_substream_t * substream, struct sndrv_pcm_hw_params_old __user * _oparams);
/* /*
* *
...@@ -108,7 +108,7 @@ int snd_pcm_info(snd_pcm_substream_t * substream, snd_pcm_info_t *info) ...@@ -108,7 +108,7 @@ int snd_pcm_info(snd_pcm_substream_t * substream, snd_pcm_info_t *info)
return 0; return 0;
} }
int snd_pcm_info_user(snd_pcm_substream_t * substream, snd_pcm_info_t * _info) int snd_pcm_info_user(snd_pcm_substream_t * substream, snd_pcm_info_t __user * _info)
{ {
snd_pcm_info_t info; snd_pcm_info_t info;
int err = snd_pcm_info(substream, &info); int err = snd_pcm_info(substream, &info);
...@@ -302,7 +302,7 @@ int snd_pcm_hw_refine(snd_pcm_substream_t *substream, ...@@ -302,7 +302,7 @@ int snd_pcm_hw_refine(snd_pcm_substream_t *substream,
return 0; return 0;
} }
static int snd_pcm_hw_refine_user(snd_pcm_substream_t * substream, snd_pcm_hw_params_t * _params) static int snd_pcm_hw_refine_user(snd_pcm_substream_t * substream, snd_pcm_hw_params_t __user * _params)
{ {
snd_pcm_hw_params_t params; snd_pcm_hw_params_t params;
int err; int err;
...@@ -406,7 +406,7 @@ static int snd_pcm_hw_params(snd_pcm_substream_t *substream, ...@@ -406,7 +406,7 @@ static int snd_pcm_hw_params(snd_pcm_substream_t *substream,
return err; return err;
} }
static int snd_pcm_hw_params_user(snd_pcm_substream_t * substream, snd_pcm_hw_params_t * _params) static int snd_pcm_hw_params_user(snd_pcm_substream_t * substream, snd_pcm_hw_params_t __user * _params)
{ {
snd_pcm_hw_params_t params; snd_pcm_hw_params_t params;
int err; int err;
...@@ -494,7 +494,7 @@ static int snd_pcm_sw_params(snd_pcm_substream_t * substream, snd_pcm_sw_params_ ...@@ -494,7 +494,7 @@ static int snd_pcm_sw_params(snd_pcm_substream_t * substream, snd_pcm_sw_params_
return 0; return 0;
} }
static int snd_pcm_sw_params_user(snd_pcm_substream_t * substream, snd_pcm_sw_params_t * _params) static int snd_pcm_sw_params_user(snd_pcm_substream_t * substream, snd_pcm_sw_params_t __user * _params)
{ {
snd_pcm_sw_params_t params; snd_pcm_sw_params_t params;
int err; int err;
...@@ -550,7 +550,7 @@ int snd_pcm_status(snd_pcm_substream_t *substream, ...@@ -550,7 +550,7 @@ int snd_pcm_status(snd_pcm_substream_t *substream,
return 0; return 0;
} }
static int snd_pcm_status_user(snd_pcm_substream_t * substream, snd_pcm_status_t * _status) static int snd_pcm_status_user(snd_pcm_substream_t * substream, snd_pcm_status_t __user * _status)
{ {
snd_pcm_status_t status; snd_pcm_status_t status;
snd_pcm_runtime_t *runtime; snd_pcm_runtime_t *runtime;
...@@ -567,7 +567,7 @@ static int snd_pcm_status_user(snd_pcm_substream_t * substream, snd_pcm_status_t ...@@ -567,7 +567,7 @@ static int snd_pcm_status_user(snd_pcm_substream_t * substream, snd_pcm_status_t
return 0; return 0;
} }
static int snd_pcm_channel_info(snd_pcm_substream_t * substream, snd_pcm_channel_info_t * _info) static int snd_pcm_channel_info(snd_pcm_substream_t * substream, snd_pcm_channel_info_t __user * _info)
{ {
snd_pcm_channel_info_t info; snd_pcm_channel_info_t info;
snd_pcm_runtime_t *runtime; snd_pcm_runtime_t *runtime;
...@@ -2297,7 +2297,7 @@ static int snd_pcm_hwsync(snd_pcm_substream_t *substream) ...@@ -2297,7 +2297,7 @@ static int snd_pcm_hwsync(snd_pcm_substream_t *substream)
return err; return err;
} }
static int snd_pcm_delay(snd_pcm_substream_t *substream, snd_pcm_sframes_t *res) static int snd_pcm_delay(snd_pcm_substream_t *substream, snd_pcm_sframes_t __user *res)
{ {
snd_pcm_runtime_t *runtime = substream->runtime; snd_pcm_runtime_t *runtime = substream->runtime;
int err; int err;
...@@ -2335,7 +2335,7 @@ static int snd_pcm_delay(snd_pcm_substream_t *substream, snd_pcm_sframes_t *res) ...@@ -2335,7 +2335,7 @@ static int snd_pcm_delay(snd_pcm_substream_t *substream, snd_pcm_sframes_t *res)
return err; return err;
} }
static int snd_pcm_sync_ptr(snd_pcm_substream_t *substream, struct sndrv_pcm_sync_ptr *_sync_ptr) static int snd_pcm_sync_ptr(snd_pcm_substream_t *substream, struct sndrv_pcm_sync_ptr __user *_sync_ptr)
{ {
snd_pcm_runtime_t *runtime = substream->runtime; snd_pcm_runtime_t *runtime = substream->runtime;
struct sndrv_pcm_sync_ptr sync_ptr; struct sndrv_pcm_sync_ptr sync_ptr;
...@@ -2344,7 +2344,7 @@ static int snd_pcm_sync_ptr(snd_pcm_substream_t *substream, struct sndrv_pcm_syn ...@@ -2344,7 +2344,7 @@ static int snd_pcm_sync_ptr(snd_pcm_substream_t *substream, struct sndrv_pcm_syn
int err; int err;
memset(&sync_ptr, 0, sizeof(sync_ptr)); memset(&sync_ptr, 0, sizeof(sync_ptr));
if (get_user(sync_ptr.flags, (unsigned int *) &(_sync_ptr->flags))) if (get_user(sync_ptr.flags, (unsigned __user *)&(_sync_ptr->flags)))
return -EFAULT; return -EFAULT;
if (copy_from_user(&sync_ptr.c.control, &(_sync_ptr->c.control), sizeof(struct sndrv_pcm_mmap_control))) if (copy_from_user(&sync_ptr.c.control, &(_sync_ptr->c.control), sizeof(struct sndrv_pcm_mmap_control)))
return -EFAULT; return -EFAULT;
...@@ -2375,40 +2375,40 @@ static int snd_pcm_sync_ptr(snd_pcm_substream_t *substream, struct sndrv_pcm_syn ...@@ -2375,40 +2375,40 @@ static int snd_pcm_sync_ptr(snd_pcm_substream_t *substream, struct sndrv_pcm_syn
} }
static int snd_pcm_playback_ioctl1(snd_pcm_substream_t *substream, static int snd_pcm_playback_ioctl1(snd_pcm_substream_t *substream,
unsigned int cmd, void *arg); unsigned int cmd, void __user *arg);
static int snd_pcm_capture_ioctl1(snd_pcm_substream_t *substream, static int snd_pcm_capture_ioctl1(snd_pcm_substream_t *substream,
unsigned int cmd, void *arg); unsigned int cmd, void __user *arg);
static int snd_pcm_common_ioctl1(snd_pcm_substream_t *substream, static int snd_pcm_common_ioctl1(snd_pcm_substream_t *substream,
unsigned int cmd, void *arg) unsigned int cmd, void __user *arg)
{ {
snd_assert(substream != NULL, return -ENXIO); snd_assert(substream != NULL, return -ENXIO);
switch (cmd) { switch (cmd) {
case SNDRV_PCM_IOCTL_PVERSION: case SNDRV_PCM_IOCTL_PVERSION:
return put_user(SNDRV_PCM_VERSION, (int *)arg) ? -EFAULT : 0; return put_user(SNDRV_PCM_VERSION, (int __user *)arg) ? -EFAULT : 0;
case SNDRV_PCM_IOCTL_INFO: case SNDRV_PCM_IOCTL_INFO:
return snd_pcm_info_user(substream, (snd_pcm_info_t *) arg); return snd_pcm_info_user(substream, arg);
case SNDRV_PCM_IOCTL_TSTAMP: case SNDRV_PCM_IOCTL_TSTAMP:
{ {
int xarg; int xarg;
if (get_user(xarg, (int *) arg)) if (get_user(xarg, (int __user *)arg))
return -EFAULT; return -EFAULT;
substream->runtime->tstamp_timespec = xarg ? 1 : 0; substream->runtime->tstamp_timespec = xarg ? 1 : 0;
return 0; return 0;
} }
case SNDRV_PCM_IOCTL_HW_REFINE: case SNDRV_PCM_IOCTL_HW_REFINE:
return snd_pcm_hw_refine_user(substream, (snd_pcm_hw_params_t *) arg); return snd_pcm_hw_refine_user(substream, arg);
case SNDRV_PCM_IOCTL_HW_PARAMS: case SNDRV_PCM_IOCTL_HW_PARAMS:
return snd_pcm_hw_params_user(substream, (snd_pcm_hw_params_t *) arg); return snd_pcm_hw_params_user(substream, arg);
case SNDRV_PCM_IOCTL_HW_FREE: case SNDRV_PCM_IOCTL_HW_FREE:
return snd_pcm_hw_free(substream); return snd_pcm_hw_free(substream);
case SNDRV_PCM_IOCTL_SW_PARAMS: case SNDRV_PCM_IOCTL_SW_PARAMS:
return snd_pcm_sw_params_user(substream, (snd_pcm_sw_params_t *) arg); return snd_pcm_sw_params_user(substream, arg);
case SNDRV_PCM_IOCTL_STATUS: case SNDRV_PCM_IOCTL_STATUS:
return snd_pcm_status_user(substream, (snd_pcm_status_t *) arg); return snd_pcm_status_user(substream, arg);
case SNDRV_PCM_IOCTL_CHANNEL_INFO: case SNDRV_PCM_IOCTL_CHANNEL_INFO:
return snd_pcm_channel_info(substream, (snd_pcm_channel_info_t *) arg); return snd_pcm_channel_info(substream, arg);
case SNDRV_PCM_IOCTL_PREPARE: case SNDRV_PCM_IOCTL_PREPARE:
return snd_pcm_prepare(substream); return snd_pcm_prepare(substream);
case SNDRV_PCM_IOCTL_RESET: case SNDRV_PCM_IOCTL_RESET:
...@@ -2416,7 +2416,7 @@ static int snd_pcm_common_ioctl1(snd_pcm_substream_t *substream, ...@@ -2416,7 +2416,7 @@ static int snd_pcm_common_ioctl1(snd_pcm_substream_t *substream,
case SNDRV_PCM_IOCTL_START: case SNDRV_PCM_IOCTL_START:
return snd_pcm_action_lock_irq(&snd_pcm_action_start, substream, 0, 0); return snd_pcm_action_lock_irq(&snd_pcm_action_start, substream, 0, 0);
case SNDRV_PCM_IOCTL_LINK: case SNDRV_PCM_IOCTL_LINK:
return snd_pcm_link(substream, (long) arg); return snd_pcm_link(substream, (int)(unsigned long) arg);
case SNDRV_PCM_IOCTL_UNLINK: case SNDRV_PCM_IOCTL_UNLINK:
return snd_pcm_unlink(substream); return snd_pcm_unlink(substream);
case SNDRV_PCM_IOCTL_RESUME: case SNDRV_PCM_IOCTL_RESUME:
...@@ -2426,27 +2426,28 @@ static int snd_pcm_common_ioctl1(snd_pcm_substream_t *substream, ...@@ -2426,27 +2426,28 @@ static int snd_pcm_common_ioctl1(snd_pcm_substream_t *substream,
case SNDRV_PCM_IOCTL_HWSYNC: case SNDRV_PCM_IOCTL_HWSYNC:
return snd_pcm_hwsync(substream); return snd_pcm_hwsync(substream);
case SNDRV_PCM_IOCTL_DELAY: case SNDRV_PCM_IOCTL_DELAY:
return snd_pcm_delay(substream, (snd_pcm_sframes_t *) arg); return snd_pcm_delay(substream, arg);
case SNDRV_PCM_IOCTL_SYNC_PTR: case SNDRV_PCM_IOCTL_SYNC_PTR:
return snd_pcm_sync_ptr(substream, (struct sndrv_pcm_sync_ptr *) arg); return snd_pcm_sync_ptr(substream, arg);
case SNDRV_PCM_IOCTL_HW_REFINE_OLD: case SNDRV_PCM_IOCTL_HW_REFINE_OLD:
return snd_pcm_hw_refine_old_user(substream, (struct sndrv_pcm_hw_params_old *) arg); return snd_pcm_hw_refine_old_user(substream, arg);
case SNDRV_PCM_IOCTL_HW_PARAMS_OLD: case SNDRV_PCM_IOCTL_HW_PARAMS_OLD:
return snd_pcm_hw_params_old_user(substream, (struct sndrv_pcm_hw_params_old *) arg); return snd_pcm_hw_params_old_user(substream, arg);
} }
snd_printd("unknown ioctl = 0x%x\n", cmd); snd_printd("unknown ioctl = 0x%x\n", cmd);
return -ENOTTY; return -ENOTTY;
} }
static int snd_pcm_playback_ioctl1(snd_pcm_substream_t *substream, static int snd_pcm_playback_ioctl1(snd_pcm_substream_t *substream,
unsigned int cmd, void *arg) unsigned int cmd, void __user *arg)
{ {
snd_assert(substream != NULL, return -ENXIO); snd_assert(substream != NULL, return -ENXIO);
snd_assert(substream->stream == SNDRV_PCM_STREAM_PLAYBACK, return -EINVAL); snd_assert(substream->stream == SNDRV_PCM_STREAM_PLAYBACK, return -EINVAL);
switch (cmd) { switch (cmd) {
case SNDRV_PCM_IOCTL_WRITEI_FRAMES: case SNDRV_PCM_IOCTL_WRITEI_FRAMES:
{ {
snd_xferi_t xferi, *_xferi = arg; snd_xferi_t xferi;
snd_xferi_t __user *_xferi = arg;
snd_pcm_runtime_t *runtime = substream->runtime; snd_pcm_runtime_t *runtime = substream->runtime;
snd_pcm_sframes_t result; snd_pcm_sframes_t result;
if (runtime->status->state == SNDRV_PCM_STATE_OPEN) if (runtime->status->state == SNDRV_PCM_STATE_OPEN)
...@@ -2461,9 +2462,10 @@ static int snd_pcm_playback_ioctl1(snd_pcm_substream_t *substream, ...@@ -2461,9 +2462,10 @@ static int snd_pcm_playback_ioctl1(snd_pcm_substream_t *substream,
} }
case SNDRV_PCM_IOCTL_WRITEN_FRAMES: case SNDRV_PCM_IOCTL_WRITEN_FRAMES:
{ {
snd_xfern_t xfern, *_xfern = arg; snd_xfern_t xfern;
snd_xfern_t __user *_xfern = arg;
snd_pcm_runtime_t *runtime = substream->runtime; snd_pcm_runtime_t *runtime = substream->runtime;
void *bufs; void __user **bufs;
snd_pcm_sframes_t result; snd_pcm_sframes_t result;
if (runtime->status->state == SNDRV_PCM_STATE_OPEN) if (runtime->status->state == SNDRV_PCM_STATE_OPEN)
return -EBADFD; return -EBADFD;
...@@ -2487,7 +2489,8 @@ static int snd_pcm_playback_ioctl1(snd_pcm_substream_t *substream, ...@@ -2487,7 +2489,8 @@ static int snd_pcm_playback_ioctl1(snd_pcm_substream_t *substream,
} }
case SNDRV_PCM_IOCTL_REWIND: case SNDRV_PCM_IOCTL_REWIND:
{ {
snd_pcm_uframes_t frames, *_frames = arg; snd_pcm_uframes_t frames;
snd_pcm_uframes_t __user *_frames = arg;
snd_pcm_sframes_t result; snd_pcm_sframes_t result;
if (get_user(frames, _frames)) if (get_user(frames, _frames))
return -EFAULT; return -EFAULT;
...@@ -2499,7 +2502,8 @@ static int snd_pcm_playback_ioctl1(snd_pcm_substream_t *substream, ...@@ -2499,7 +2502,8 @@ static int snd_pcm_playback_ioctl1(snd_pcm_substream_t *substream,
} }
case SNDRV_PCM_IOCTL_FORWARD: case SNDRV_PCM_IOCTL_FORWARD:
{ {
snd_pcm_uframes_t frames, *_frames = arg; snd_pcm_uframes_t frames;
snd_pcm_uframes_t __user *_frames = arg;
snd_pcm_sframes_t result; snd_pcm_sframes_t result;
if (get_user(frames, _frames)) if (get_user(frames, _frames))
return -EFAULT; return -EFAULT;
...@@ -2513,7 +2517,7 @@ static int snd_pcm_playback_ioctl1(snd_pcm_substream_t *substream, ...@@ -2513,7 +2517,7 @@ static int snd_pcm_playback_ioctl1(snd_pcm_substream_t *substream,
{ {
int res; int res;
snd_pcm_stream_lock_irq(substream); snd_pcm_stream_lock_irq(substream);
res = snd_pcm_pause(substream, (long) arg); res = snd_pcm_pause(substream, (int)(unsigned long)arg);
snd_pcm_stream_unlock_irq(substream); snd_pcm_stream_unlock_irq(substream);
return res; return res;
} }
...@@ -2526,14 +2530,15 @@ static int snd_pcm_playback_ioctl1(snd_pcm_substream_t *substream, ...@@ -2526,14 +2530,15 @@ static int snd_pcm_playback_ioctl1(snd_pcm_substream_t *substream,
} }
static int snd_pcm_capture_ioctl1(snd_pcm_substream_t *substream, static int snd_pcm_capture_ioctl1(snd_pcm_substream_t *substream,
unsigned int cmd, void *arg) unsigned int cmd, void __user *arg)
{ {
snd_assert(substream != NULL, return -ENXIO); snd_assert(substream != NULL, return -ENXIO);
snd_assert(substream->stream == SNDRV_PCM_STREAM_CAPTURE, return -EINVAL); snd_assert(substream->stream == SNDRV_PCM_STREAM_CAPTURE, return -EINVAL);
switch (cmd) { switch (cmd) {
case SNDRV_PCM_IOCTL_READI_FRAMES: case SNDRV_PCM_IOCTL_READI_FRAMES:
{ {
snd_xferi_t xferi, *_xferi = arg; snd_xferi_t xferi;
snd_xferi_t __user *_xferi = arg;
snd_pcm_runtime_t *runtime = substream->runtime; snd_pcm_runtime_t *runtime = substream->runtime;
snd_pcm_sframes_t result; snd_pcm_sframes_t result;
if (runtime->status->state == SNDRV_PCM_STATE_OPEN) if (runtime->status->state == SNDRV_PCM_STATE_OPEN)
...@@ -2548,7 +2553,8 @@ static int snd_pcm_capture_ioctl1(snd_pcm_substream_t *substream, ...@@ -2548,7 +2553,8 @@ static int snd_pcm_capture_ioctl1(snd_pcm_substream_t *substream,
} }
case SNDRV_PCM_IOCTL_READN_FRAMES: case SNDRV_PCM_IOCTL_READN_FRAMES:
{ {
snd_xfern_t xfern, *_xfern = arg; snd_xfern_t xfern;
snd_xfern_t __user *_xfern = arg;
snd_pcm_runtime_t *runtime = substream->runtime; snd_pcm_runtime_t *runtime = substream->runtime;
void *bufs; void *bufs;
snd_pcm_sframes_t result; snd_pcm_sframes_t result;
...@@ -2574,7 +2580,8 @@ static int snd_pcm_capture_ioctl1(snd_pcm_substream_t *substream, ...@@ -2574,7 +2580,8 @@ static int snd_pcm_capture_ioctl1(snd_pcm_substream_t *substream,
} }
case SNDRV_PCM_IOCTL_REWIND: case SNDRV_PCM_IOCTL_REWIND:
{ {
snd_pcm_uframes_t frames, *_frames = arg; snd_pcm_uframes_t frames;
snd_pcm_uframes_t __user *_frames = arg;
snd_pcm_sframes_t result; snd_pcm_sframes_t result;
if (get_user(frames, _frames)) if (get_user(frames, _frames))
return -EFAULT; return -EFAULT;
...@@ -2586,7 +2593,8 @@ static int snd_pcm_capture_ioctl1(snd_pcm_substream_t *substream, ...@@ -2586,7 +2593,8 @@ static int snd_pcm_capture_ioctl1(snd_pcm_substream_t *substream,
} }
case SNDRV_PCM_IOCTL_FORWARD: case SNDRV_PCM_IOCTL_FORWARD:
{ {
snd_pcm_uframes_t frames, *_frames = arg; snd_pcm_uframes_t frames;
snd_pcm_uframes_t __user *_frames = arg;
snd_pcm_sframes_t result; snd_pcm_sframes_t result;
if (get_user(frames, _frames)) if (get_user(frames, _frames))
return -EFAULT; return -EFAULT;
...@@ -2614,7 +2622,7 @@ static int snd_pcm_playback_ioctl(struct inode *inode, struct file *file, ...@@ -2614,7 +2622,7 @@ static int snd_pcm_playback_ioctl(struct inode *inode, struct file *file,
if (((cmd >> 8) & 0xff) != 'A') if (((cmd >> 8) & 0xff) != 'A')
return -ENOTTY; return -ENOTTY;
return snd_pcm_playback_ioctl1(pcm_file->substream, cmd, (void *) arg); return snd_pcm_playback_ioctl1(pcm_file->substream, cmd, (void __user *)arg);
} }
static int snd_pcm_capture_ioctl(struct inode *inode, struct file *file, static int snd_pcm_capture_ioctl(struct inode *inode, struct file *file,
...@@ -2627,7 +2635,7 @@ static int snd_pcm_capture_ioctl(struct inode *inode, struct file *file, ...@@ -2627,7 +2635,7 @@ static int snd_pcm_capture_ioctl(struct inode *inode, struct file *file,
if (((cmd >> 8) & 0xff) != 'A') if (((cmd >> 8) & 0xff) != 'A')
return -ENOTTY; return -ENOTTY;
return snd_pcm_capture_ioctl1(pcm_file->substream, cmd, (void *) arg); return snd_pcm_capture_ioctl1(pcm_file->substream, cmd, (void __user *)arg);
} }
int snd_pcm_kernel_playback_ioctl(snd_pcm_substream_t *substream, int snd_pcm_kernel_playback_ioctl(snd_pcm_substream_t *substream,
...@@ -2667,7 +2675,7 @@ int snd_pcm_kernel_ioctl(snd_pcm_substream_t *substream, ...@@ -2667,7 +2675,7 @@ int snd_pcm_kernel_ioctl(snd_pcm_substream_t *substream,
} }
} }
static ssize_t snd_pcm_read(struct file *file, char *buf, size_t count, loff_t * offset) static ssize_t snd_pcm_read(struct file *file, char __user *buf, size_t count, loff_t * offset)
{ {
snd_pcm_file_t *pcm_file; snd_pcm_file_t *pcm_file;
snd_pcm_substream_t *substream; snd_pcm_substream_t *substream;
...@@ -2689,7 +2697,7 @@ static ssize_t snd_pcm_read(struct file *file, char *buf, size_t count, loff_t * ...@@ -2689,7 +2697,7 @@ static ssize_t snd_pcm_read(struct file *file, char *buf, size_t count, loff_t *
return result; return result;
} }
static ssize_t snd_pcm_write(struct file *file, const char *buf, size_t count, loff_t * offset) static ssize_t snd_pcm_write(struct file *file, const char __user *buf, size_t count, loff_t * offset)
{ {
snd_pcm_file_t *pcm_file; snd_pcm_file_t *pcm_file;
snd_pcm_substream_t *substream; snd_pcm_substream_t *substream;
...@@ -2725,7 +2733,7 @@ static ssize_t snd_pcm_readv(struct file *file, const struct iovec *_vector, ...@@ -2725,7 +2733,7 @@ static ssize_t snd_pcm_readv(struct file *file, const struct iovec *_vector,
snd_pcm_runtime_t *runtime; snd_pcm_runtime_t *runtime;
snd_pcm_sframes_t result; snd_pcm_sframes_t result;
unsigned long i; unsigned long i;
void **bufs; void __user **bufs;
snd_pcm_uframes_t frames; snd_pcm_uframes_t frames;
pcm_file = snd_magic_cast(snd_pcm_file_t, file->private_data, return -ENXIO); pcm_file = snd_magic_cast(snd_pcm_file_t, file->private_data, return -ENXIO);
...@@ -2759,7 +2767,7 @@ static ssize_t snd_pcm_writev(struct file *file, const struct iovec *_vector, ...@@ -2759,7 +2767,7 @@ static ssize_t snd_pcm_writev(struct file *file, const struct iovec *_vector,
snd_pcm_runtime_t *runtime; snd_pcm_runtime_t *runtime;
snd_pcm_sframes_t result; snd_pcm_sframes_t result;
unsigned long i; unsigned long i;
void **bufs; void __user **bufs;
snd_pcm_uframes_t frames; snd_pcm_uframes_t frames;
pcm_file = snd_magic_cast(snd_pcm_file_t, file->private_data, result = -ENXIO; goto end); pcm_file = snd_magic_cast(snd_pcm_file_t, file->private_data, result = -ENXIO; goto end);
...@@ -3123,7 +3131,7 @@ static void snd_pcm_hw_convert_to_old_params(struct sndrv_pcm_hw_params_old *opa ...@@ -3123,7 +3131,7 @@ static void snd_pcm_hw_convert_to_old_params(struct sndrv_pcm_hw_params_old *opa
oparams->fifo_size = params->fifo_size; oparams->fifo_size = params->fifo_size;
} }
static int snd_pcm_hw_refine_old_user(snd_pcm_substream_t * substream, struct sndrv_pcm_hw_params_old * _oparams) static int snd_pcm_hw_refine_old_user(snd_pcm_substream_t * substream, struct sndrv_pcm_hw_params_old __user * _oparams)
{ {
snd_pcm_hw_params_t params; snd_pcm_hw_params_t params;
struct sndrv_pcm_hw_params_old oparams; struct sndrv_pcm_hw_params_old oparams;
...@@ -3138,7 +3146,7 @@ static int snd_pcm_hw_refine_old_user(snd_pcm_substream_t * substream, struct sn ...@@ -3138,7 +3146,7 @@ static int snd_pcm_hw_refine_old_user(snd_pcm_substream_t * substream, struct sn
return err; return err;
} }
static int snd_pcm_hw_params_old_user(snd_pcm_substream_t * substream, struct sndrv_pcm_hw_params_old * _oparams) static int snd_pcm_hw_params_old_user(snd_pcm_substream_t * substream, struct sndrv_pcm_hw_params_old __user * _oparams)
{ {
snd_pcm_hw_params_t params; snd_pcm_hw_params_t params;
struct sndrv_pcm_hw_params_old oparams; struct sndrv_pcm_hw_params_old oparams;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment