aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorAlexander Viro <viro@parcelfarce.linux.theplanet.co.uk>2004-07-13 19:38:57 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-07-13 19:38:57 -0700
commit02e1bc896f324645e367883bc473ab0fb7f54a0a (patch)
treec3ceae787b38ff0a94de8455bfcc9eae3e7de88f /sound
parent1a3d772725a616cd3eb54c7cea31ad475bccc696 (diff)
downloadhistory-02e1bc896f324645e367883bc473ab0fb7f54a0a.tar.gz
[PATCH] sparse: sound compat ioctls annotations
Trivial annotations + typo fix in _snd_ioctl32_hwdep_dsp_image() (we want to copy 32bit structure from userland, convert it to native one and do normal ioctl on it; see the first changed line below for what's really happening...)
Diffstat (limited to 'sound')
-rw-r--r--sound/core/ioctl32/hwdep32.c6
-rw-r--r--sound/core/ioctl32/ioctl32.c16
-rw-r--r--sound/core/ioctl32/ioctl32.h21
-rw-r--r--sound/core/ioctl32/pcm32.c21
-rw-r--r--sound/core/seq/seq_clientmgr.c2
5 files changed, 29 insertions, 37 deletions
diff --git a/sound/core/ioctl32/hwdep32.c b/sound/core/ioctl32/hwdep32.c
index 3b67346e0d55fe..8682e8cabcb8ce 100644
--- a/sound/core/ioctl32/hwdep32.c
+++ b/sound/core/ioctl32/hwdep32.c
@@ -37,16 +37,16 @@ struct sndrv_hwdep_dsp_image32 {
static int _snd_ioctl32_hwdep_dsp_image(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file, unsigned int native_ctl)
{
struct sndrv_hwdep_dsp_image data;
- struct sndrv_hwdep_dsp_image data32;
+ struct sndrv_hwdep_dsp_image32 data32;
mm_segment_t oldseg;
int err;
- if (copy_from_user(&data32, (void*)arg, sizeof(data32)))
+ if (copy_from_user(&data32, (void __user *)arg, sizeof(data32)))
return -EFAULT;
memset(&data, 0, sizeof(data));
data.index = data32.index;
memcpy(data.name, data32.name, sizeof(data.name));
- data.image = A(data32.image);
+ data.image = compat_ptr(data32.image);
data.length = data32.length;
data.driver_data = data32.driver_data;
oldseg = get_fs();
diff --git a/sound/core/ioctl32/ioctl32.c b/sound/core/ioctl32/ioctl32.c
index b9e8a97c0f3069..5c0d30c777bd0d 100644
--- a/sound/core/ioctl32/ioctl32.c
+++ b/sound/core/ioctl32/ioctl32.c
@@ -109,14 +109,14 @@ static int _snd_ioctl32_ctl_elem_list(unsigned int fd, unsigned int cmd, unsigne
mm_segment_t oldseg;
int err;
- if (copy_from_user(&data32, (void*)arg, sizeof(data32)))
+ if (copy_from_user(&data32, (void __user *)arg, sizeof(data32)))
return -EFAULT;
memset(&data, 0, sizeof(data));
data.offset = data32.offset;
data.space = data32.space;
data.used = data32.used;
data.count = data32.count;
- data.pids = A(data32.pids);
+ data.pids = compat_ptr(data32.pids);
oldseg = get_fs();
set_fs(KERNEL_DS);
err = file->f_op->ioctl(file->f_dentry->d_inode, file, native_ctl, (unsigned long)&data);
@@ -129,7 +129,7 @@ static int _snd_ioctl32_ctl_elem_list(unsigned int fd, unsigned int cmd, unsigne
data32.used = data.used;
data32.count = data.count;
//data.pids = data.pids;
- if (copy_to_user((void*)arg, &data32, sizeof(data32)))
+ if (copy_to_user((void __user *)arg, &data32, sizeof(data32)))
return -EFAULT;
return 0;
}
@@ -175,7 +175,7 @@ static int _snd_ioctl32_ctl_elem_info(unsigned int fd, unsigned int cmd, unsigne
int err;
mm_segment_t oldseg;
- if (copy_from_user(&data32, (void*)arg, sizeof(data32)))
+ if (copy_from_user(&data32, (void __user *)arg, sizeof(data32)))
return -EFAULT;
memset(&data, 0, sizeof(data));
data.id = data32.id;
@@ -216,7 +216,7 @@ static int _snd_ioctl32_ctl_elem_info(unsigned int fd, unsigned int cmd, unsigne
default:
break;
}
- if (copy_to_user((void*)arg, &data32, sizeof(data32)))
+ if (copy_to_user((void __user *)arg, &data32, sizeof(data32)))
return -EFAULT;
return 0;
}
@@ -291,7 +291,7 @@ static int _snd_ioctl32_ctl_elem_value(unsigned int fd, unsigned int cmd, unsign
goto __end;
}
- if (copy_from_user(data32, (void*)arg, sizeof(*data32))) {
+ if (copy_from_user(data32, (void __user *)arg, sizeof(*data32))) {
err = -EFAULT;
goto __end;
}
@@ -299,7 +299,7 @@ static int _snd_ioctl32_ctl_elem_value(unsigned int fd, unsigned int cmd, unsign
data->id = data32->id;
data->indirect = data32->indirect;
if (data->indirect) /* FIXME: this is not correct for long arrays */
- data->value.integer.value_ptr = (void*)TO_PTR(data32->value.integer.value_ptr);
+ data->value.integer.value_ptr = compat_ptr(data32->value.integer.value_ptr);
type = get_ctl_type(file, &data->id);
if (type < 0) {
err = type;
@@ -367,7 +367,7 @@ static int _snd_ioctl32_ctl_elem_value(unsigned int fd, unsigned int cmd, unsign
}
}
err = 0;
- if (copy_to_user((void*)arg, data32, sizeof(*data32)))
+ if (copy_to_user((void __user *)arg, data32, sizeof(*data32)))
err = -EFAULT;
__end:
if (data32)
diff --git a/sound/core/ioctl32/ioctl32.h b/sound/core/ioctl32/ioctl32.h
index e59d382102fff8..39887cc3b04b8b 100644
--- a/sound/core/ioctl32/ioctl32.h
+++ b/sound/core/ioctl32/ioctl32.h
@@ -26,19 +26,10 @@
#ifndef __ALSA_IOCTL32_H
#define __ALSA_IOCTL32_H
-#ifndef A
-#ifdef CONFIG_PPC64
-#include <asm/ppc32.h>
-#else
-/* x86-64, sparc64 */
-#define A(__x) ((void *)(unsigned long)(__x))
-#endif
-#endif
-
-#define TO_PTR(x) A(x)
+#include <linux/compat.h>
#define COPY(x) (dst->x = src->x)
-#define CPTR(x) (dst->x = (typeof(dst->x))A(src->x))
+#define CPTR(x) (dst->x = compat_ptr(src->x))
#define convert_from_32(type, dstp, srcp)\
{\
@@ -62,7 +53,7 @@ static int _snd_ioctl32_##type(unsigned int fd, unsigned int cmd, unsigned long
struct sndrv_##type data;\
mm_segment_t oldseg;\
int err;\
- if (copy_from_user(&data32, (void*)arg, sizeof(data32)))\
+ if (copy_from_user(&data32, (void __user *)arg, sizeof(data32)))\
return -EFAULT;\
memset(&data, 0, sizeof(data));\
convert_from_32(type, &data, &data32);\
@@ -74,7 +65,7 @@ static int _snd_ioctl32_##type(unsigned int fd, unsigned int cmd, unsigned long
return err;\
if (native_ctl & (_IOC_READ << _IOC_DIRSHIFT)) {\
convert_to_32(type, &data32, &data);\
- if (copy_to_user((void*)arg, &data32, sizeof(data32)))\
+ if (copy_to_user((void __user *)arg, &data32, sizeof(data32)))\
return -EFAULT;\
}\
return 0;\
@@ -93,7 +84,7 @@ static int _snd_ioctl32_##type(unsigned int fd, unsigned int cmd, unsigned long
err = -ENOMEM; \
goto __end; \
}\
- if (copy_from_user(data32, (void*)arg, sizeof(*data32))) { \
+ if (copy_from_user(data32, (void __user *)arg, sizeof(*data32))) { \
err = -EFAULT; \
goto __end; \
}\
@@ -108,7 +99,7 @@ static int _snd_ioctl32_##type(unsigned int fd, unsigned int cmd, unsigned long
err = 0;\
if (native_ctl & (_IOC_READ << _IOC_DIRSHIFT)) {\
convert_to_32(type, data32, data);\
- if (copy_to_user((void*)arg, data32, sizeof(*data32)))\
+ if (copy_to_user((void __user *)arg, data32, sizeof(*data32)))\
err = -EFAULT;\
}\
__end:\
diff --git a/sound/core/ioctl32/pcm32.c b/sound/core/ioctl32/pcm32.c
index e259f49cc04b5f..41ea1dabeb1e52 100644
--- a/sound/core/ioctl32/pcm32.c
+++ b/sound/core/ioctl32/pcm32.c
@@ -189,11 +189,11 @@ static int _snd_ioctl32_xferi(unsigned int fd, unsigned int cmd, unsigned long a
mm_segment_t oldseg;
int err;
- if (copy_from_user(&data32, (void*)arg, sizeof(data32)))
+ if (copy_from_user(&data32, (void __user *)arg, sizeof(data32)))
return -EFAULT;
memset(&data, 0, sizeof(data));
data.result = data32.result;
- data.buf = A(data32.buf);
+ data.buf = compat_ptr(data32.buf);
data.frames = data32.frames;
oldseg = get_fs();
set_fs(KERNEL_DS);
@@ -203,7 +203,7 @@ static int _snd_ioctl32_xferi(unsigned int fd, unsigned int cmd, unsigned long a
return err;
/* copy the result */
data32.result = data.result;
- if (copy_to_user((void*)arg, &data32, sizeof(data32)))
+ if (copy_to_user((void __user *)arg, &data32, sizeof(data32)))
return -EFAULT;
return 0;
}
@@ -226,10 +226,11 @@ static int _snd_ioctl32_xfern(unsigned int fd, unsigned int cmd, unsigned long a
{
snd_pcm_file_t *pcm_file;
snd_pcm_substream_t *substream;
- struct sndrv_xfern32 data32, *srcptr = (struct sndrv_xfern32*)arg;
- void **bufs = NULL;
+ struct sndrv_xfern32 data32;
+ struct sndrv_xfern32 __user *srcptr = (void __user *)arg;
+ void __user **bufs = NULL;
int err = 0, ch, i;
- u32 *bufptr;
+ u32 __user *bufptr;
mm_segment_t oldseg;
/* FIXME: need to check whether fop->ioctl is sane */
@@ -256,7 +257,7 @@ static int _snd_ioctl32_xfern(unsigned int fd, unsigned int cmd, unsigned long a
if (get_user(data32.frames, &srcptr->frames))
return -EFAULT;
__get_user(data32.bufs, &srcptr->bufs);
- bufptr = (u32*)TO_PTR(data32.bufs);
+ bufptr = compat_ptr(data32.bufs);
bufs = kmalloc(sizeof(void *) * 128, GFP_KERNEL);
if (bufs == NULL)
return -ENOMEM;
@@ -264,7 +265,7 @@ static int _snd_ioctl32_xfern(unsigned int fd, unsigned int cmd, unsigned long a
u32 ptr;
if (get_user(ptr, bufptr))
return -EFAULT;
- bufs[ch] = (void*)TO_PTR(ptr);
+ bufs[ch] = compat_ptr(ptr);
bufptr++;
}
oldseg = get_fs();
@@ -355,7 +356,7 @@ static int _snd_ioctl32_pcm_hw_params_old(unsigned int fd, unsigned int cmd, uns
err = -ENOMEM;
goto __end;
}
- if (copy_from_user(data32, (void*)arg, sizeof(*data32))) {
+ if (copy_from_user(data32, (void __user *)arg, sizeof(*data32))) {
err = -EFAULT;
goto __end;
}
@@ -368,7 +369,7 @@ static int _snd_ioctl32_pcm_hw_params_old(unsigned int fd, unsigned int cmd, uns
goto __end;
snd_pcm_hw_convert_to_old_params(data32, data);
err = 0;
- if (copy_to_user((void*)arg, data32, sizeof(*data32)))
+ if (copy_to_user((void __user *)arg, data32, sizeof(*data32)))
err = -EFAULT;
__end:
if (data)
diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
index 9e67d06da3c2c2..eff36938ff8fae 100644
--- a/sound/core/seq/seq_clientmgr.c
+++ b/sound/core/seq/seq_clientmgr.c
@@ -1055,7 +1055,7 @@ static ssize_t snd_seq_write(struct file *file, const char __user *buf, size_t c
} else {
#if defined(CONFIG_SND_BIT32_EMUL) || defined(CONFIG_SND_BIT32_EMUL_MODULE)
if (client->convert32 && snd_seq_ev_is_varusr(&event)) {
- void *ptr = (void*)A(event.data.raw32.d[1]);
+ void *ptr = compat_ptr(event.data.raw32.d[1]);
event.data.ext.ptr = ptr;
}
#endif