]> git.hungrycats.org Git - linux/commitdiff
[PATCH] sparse: sound compat ioctls annotations
authorAlexander Viro <viro@parcelfarce.linux.theplanet.co.uk>
Wed, 14 Jul 2004 02:38:57 +0000 (19:38 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Wed, 14 Jul 2004 02:38:57 +0000 (19:38 -0700)
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...)

sound/core/ioctl32/hwdep32.c
sound/core/ioctl32/ioctl32.c
sound/core/ioctl32/ioctl32.h
sound/core/ioctl32/pcm32.c
sound/core/seq/seq_clientmgr.c

index 3b67346e0d55fe21b4f4e700f7000d8ce5c8be0c..8682e8cabcb8ce46782b0972baacfeb7ab914eb9 100644 (file)
@@ -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();
index b9e8a97c0f30695d3daa5ecd44f8fa79634abecd..5c0d30c777bd0d8b7340829de47072177f738b2a 100644 (file)
@@ -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)
index e59d382102fff8306a413a4091c10caef8f4a11e..39887cc3b04b8b1a01b9630f5fe03f6c71e3c055 100644 (file)
 #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:\
index e259f49cc04b5f9425becffb12d309b6e1f62163..41ea1dabeb1e52ec14f69b6d8efb48dff67fc7f4 100644 (file)
@@ -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)
index 9e67d06da3c2c244543a12e84c1063661ff70764..eff36938ff8fae2a01297840af7cd239a5221237 100644 (file)
@@ -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