Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / char / dsp56k.c
index b022aca..e233cf2 100644 (file)
 #define DSP56K_TRANSMIT                (dsp56k_host_interface.isr & DSP56K_ISR_TXDE)
 #define DSP56K_RECEIVE         (dsp56k_host_interface.isr & DSP56K_ISR_RXDF)
 
-#define wait_some(n) \
-{ \
-       set_current_state(TASK_INTERRUPTIBLE); \
-       schedule_timeout(n); \
-}
-
 #define handshake(count, maxio, timeout, ENABLE, f) \
 { \
        long i, t, m; \
                m = min_t(unsigned long, count, maxio); \
                for (i = 0; i < m; i++) { \
                        for (t = 0; t < timeout && !ENABLE; t++) \
-                               wait_some(HZ/50); \
+                               msleep(20); \
                        if(!ENABLE) \
                                return -EIO; \
                        f; \
                } \
                count -= m; \
-               if (m == maxio) wait_some(HZ/50); \
+               if (m == maxio) msleep(20); \
        } \
 }
 
@@ -85,7 +79,7 @@
 { \
        int t; \
        for(t = 0; t < n && !DSP56K_TRANSMIT; t++) \
-               wait_some(HZ/100); \
+               msleep(10); \
        if(!DSP56K_TRANSMIT) { \
                return -EIO; \
        } \
@@ -95,7 +89,7 @@
 { \
        int t; \
        for(t = 0; t < n && !DSP56K_RECEIVE; t++) \
-               wait_some(HZ/100); \
+               msleep(10); \
        if(!DSP56K_RECEIVE) { \
                return -EIO; \
        } \
@@ -150,7 +144,7 @@ static struct dsp56k_device {
        int tx_wsize, rx_wsize;
 } dsp56k;
 
-static struct class_simple *dsp56k_class;
+static struct class *dsp56k_class;
 
 static int dsp56k_reset(void)
 {
@@ -171,7 +165,7 @@ static int dsp56k_reset(void)
        return 0;
 }
 
-static int dsp56k_upload(u_char *bin, int len)
+static int dsp56k_upload(u_char __user *bin, int len)
 {
        int i;
        u_char *p;
@@ -205,7 +199,7 @@ static int dsp56k_upload(u_char *bin, int len)
        return 0;
 }
 
-static ssize_t dsp56k_read(struct file *file, char *buf, size_t count,
+static ssize_t dsp56k_read(struct file *file, char __user *buf, size_t count,
                           loff_t *ppos)
 {
        struct inode *inode = file->f_dentry->d_inode;
@@ -231,10 +225,10 @@ static ssize_t dsp56k_read(struct file *file, char *buf, size_t count,
                }
                case 2:  /* 16 bit */
                {
-                       short *data;
+                       short __user *data;
 
                        count /= 2;
-                       data = (short*) buf;
+                       data = (short __user *) buf;
                        handshake(count, dsp56k.maxio, dsp56k.timeout, DSP56K_RECEIVE,
                                  put_user(dsp56k_host_interface.data.w[1], data+n++));
                        return 2*n;
@@ -250,10 +244,10 @@ static ssize_t dsp56k_read(struct file *file, char *buf, size_t count,
                }
                case 4:  /* 32 bit */
                {
-                       long *data;
+                       long __user *data;
 
                        count /= 4;
-                       data = (long*) buf;
+                       data = (long __user *) buf;
                        handshake(count, dsp56k.maxio, dsp56k.timeout, DSP56K_RECEIVE,
                                  put_user(dsp56k_host_interface.data.l, data+n++));
                        return 4*n;
@@ -268,7 +262,7 @@ static ssize_t dsp56k_read(struct file *file, char *buf, size_t count,
        }
 }
 
-static ssize_t dsp56k_write(struct file *file, const char *buf, size_t count,
+static ssize_t dsp56k_write(struct file *file, const char __user *buf, size_t count,
                            loff_t *ppos)
 {
        struct inode *inode = file->f_dentry->d_inode;
@@ -293,10 +287,10 @@ static ssize_t dsp56k_write(struct file *file, const char *buf, size_t count,
                }
                case 2:  /* 16 bit */
                {
-                       const short *data;
+                       const short __user *data;
 
                        count /= 2;
-                       data = (const short *)buf;
+                       data = (const short __user *)buf;
                        handshake(count, dsp56k.maxio, dsp56k.timeout, DSP56K_TRANSMIT,
                                  get_user(dsp56k_host_interface.data.w[1], data+n++));
                        return 2*n;
@@ -312,10 +306,10 @@ static ssize_t dsp56k_write(struct file *file, const char *buf, size_t count,
                }
                case 4:  /* 32 bit */
                {
-                       const long *data;
+                       const long __user *data;
 
                        count /= 4;
-                       data = (const long *)buf;
+                       data = (const long __user *)buf;
                        handshake(count, dsp56k.maxio, dsp56k.timeout, DSP56K_TRANSMIT,
                                  get_user(dsp56k_host_interface.data.l, data+n++));
                        return 4*n;
@@ -334,6 +328,7 @@ static int dsp56k_ioctl(struct inode *inode, struct file *file,
                        unsigned int cmd, unsigned long arg)
 {
        int dev = iminor(inode) & 0x0f;
+       void __user *argp = (void __user *)arg;
 
        switch(dev)
        {
@@ -342,9 +337,9 @@ static int dsp56k_ioctl(struct inode *inode, struct file *file,
                switch(cmd) {
                case DSP56K_UPLOAD:
                {
-                       char *bin;
+                       char __user *bin;
                        int r, len;
-                       struct dsp56k_upload *binary = (struct dsp56k_upload *) arg;
+                       struct dsp56k_upload __user *binary = argp;
     
                        if(get_user(len, &binary->len) < 0)
                                return -EFAULT;
@@ -378,7 +373,7 @@ static int dsp56k_ioctl(struct inode *inode, struct file *file,
                case DSP56K_HOST_FLAGS:
                {
                        int dir, out, status;
-                       struct dsp56k_host_flags *hf = (struct dsp56k_host_flags*) arg;
+                       struct dsp56k_host_flags __user *hf = argp;
     
                        if(get_user(dir, &hf->dir) < 0)
                                return -EFAULT;
@@ -516,12 +511,12 @@ static int __init dsp56k_init_driver(void)
                printk("DSP56k driver: Unable to register driver\n");
                return -ENODEV;
        }
-       dsp56k_class = class_simple_create(THIS_MODULE, "dsp56k");
+       dsp56k_class = class_create(THIS_MODULE, "dsp56k");
        if (IS_ERR(dsp56k_class)) {
                err = PTR_ERR(dsp56k_class);
                goto out_chrdev;
        }
-       class_simple_device_add(dsp56k_class, MKDEV(DSP56K_MAJOR, 0), NULL, "dsp56k");
+       class_device_create(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), NULL, "dsp56k");
 
        err = devfs_mk_cdev(MKDEV(DSP56K_MAJOR, 0),
                      S_IFCHR | S_IRUSR | S_IWUSR, "dsp56k");
@@ -532,8 +527,8 @@ static int __init dsp56k_init_driver(void)
        goto out;
 
 out_class:
-       class_simple_device_remove(MKDEV(DSP56K_MAJOR, 0));
-       class_simple_destroy(dsp56k_class);
+       class_device_destroy(dsp56k_class, MKDEV(DSP56K_MAJOR, 0));
+       class_destroy(dsp56k_class);
 out_chrdev:
        unregister_chrdev(DSP56K_MAJOR, "dsp56k");
 out:
@@ -543,8 +538,8 @@ module_init(dsp56k_init_driver);
 
 static void __exit dsp56k_cleanup_driver(void)
 {
-       class_simple_device_remove(MKDEV(DSP56K_MAJOR, 0));
-       class_simple_destroy(dsp56k_class);
+       class_device_destroy(dsp56k_class, MKDEV(DSP56K_MAJOR, 0));
+       class_destroy(dsp56k_class);
        unregister_chrdev(DSP56K_MAJOR, "dsp56k");
        devfs_remove("dsp56k");
 }