]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/isdn/i4l/isdn_common.c
Merge branch 'for-linus' of git://oss.sgi.com:8090/xfs/xfs-2.6
[linux-2.6-omap-h63xx.git] / drivers / isdn / i4l / isdn_common.c
index c97330b198772cb290ee768556949a5460cd36a6..d6952959d72afc643be51248cadd523e2a0ebcf7 100644 (file)
@@ -1135,7 +1135,7 @@ isdn_read(struct file *file, char __user *buf, size_t count, loff_t * off)
                        if (count > dev->drv[drvidx]->stavail)
                                count = dev->drv[drvidx]->stavail;
                        len = dev->drv[drvidx]->interface->readstat(buf, count,
-                                               drvidx, isdn_minor2chan(minor));
+                               drvidx, isdn_minor2chan(minor - ISDN_MINOR_CTRL));
                        if (len < 0) {
                                retval = len;
                                goto out;
@@ -1207,7 +1207,8 @@ isdn_write(struct file *file, const char __user *buf, size_t count, loff_t * off
                 */
                if (dev->drv[drvidx]->interface->writecmd)
                        retval = dev->drv[drvidx]->interface->
-                               writecmd(buf, count, drvidx, isdn_minor2chan(minor));
+                               writecmd(buf, count, drvidx,
+                               isdn_minor2chan(minor - ISDN_MINOR_CTRL));
                else
                        retval = count;
                goto out;
@@ -1364,7 +1365,7 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
                                } else {
                                        s = NULL;
                                }
-                               ret = down_interruptible(&dev->sem);
+                               ret = mutex_lock_interruptible(&dev->mtx);
                                if( ret ) return ret;
                                if ((s = isdn_net_new(s, NULL))) {
                                        if (copy_to_user(argp, s, strlen(s) + 1)){
@@ -1374,7 +1375,7 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
                                        }
                                } else
                                        ret = -ENODEV;
-                               up(&dev->sem);
+                               mutex_unlock(&dev->mtx);
                                return ret;
                        case IIOCNETASL:
                                /* Add a slave to a network-interface */
@@ -1383,7 +1384,7 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
                                                return -EFAULT;
                                } else
                                        return -EINVAL;
-                               ret = down_interruptible(&dev->sem);
+                               ret = mutex_lock_interruptible(&dev->mtx);
                                if( ret ) return ret;
                                if ((s = isdn_net_newslave(bname))) {
                                        if (copy_to_user(argp, s, strlen(s) + 1)){
@@ -1393,17 +1394,17 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
                                        }
                                } else
                                        ret = -ENODEV;
-                               up(&dev->sem);
+                               mutex_unlock(&dev->mtx);
                                return ret;
                        case IIOCNETDIF:
                                /* Delete a network-interface */
                                if (arg) {
                                        if (copy_from_user(name, argp, sizeof(name)))
                                                return -EFAULT;
-                                       ret = down_interruptible(&dev->sem);
+                                       ret = mutex_lock_interruptible(&dev->mtx);
                                        if( ret ) return ret;
                                        ret = isdn_net_rm(name);
-                                       up(&dev->sem);
+                                       mutex_unlock(&dev->mtx);
                                        return ret;
                                } else
                                        return -EINVAL;
@@ -1432,10 +1433,10 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
                                if (arg) {
                                        if (copy_from_user(&phone, argp, sizeof(phone)))
                                                return -EFAULT;
-                                       ret = down_interruptible(&dev->sem);
+                                       ret = mutex_lock_interruptible(&dev->mtx);
                                        if( ret ) return ret;
                                        ret = isdn_net_addphone(&phone);
-                                       up(&dev->sem);
+                                       mutex_unlock(&dev->mtx);
                                        return ret;
                                } else
                                        return -EINVAL;
@@ -1444,10 +1445,10 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
                                if (arg) {
                                        if (copy_from_user(&phone, argp, sizeof(phone)))
                                                return -EFAULT;
-                                       ret = down_interruptible(&dev->sem);
+                                       ret = mutex_lock_interruptible(&dev->mtx);
                                        if( ret ) return ret;
                                        ret = isdn_net_getphones(&phone, argp);
-                                       up(&dev->sem);
+                                       mutex_unlock(&dev->mtx);
                                        return ret;
                                } else
                                        return -EINVAL;
@@ -1456,10 +1457,10 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
                                if (arg) {
                                        if (copy_from_user(&phone, argp, sizeof(phone)))
                                                return -EFAULT;
-                                       ret = down_interruptible(&dev->sem);
+                                       ret = mutex_lock_interruptible(&dev->mtx);
                                        if( ret ) return ret;
                                        ret = isdn_net_delphone(&phone);
-                                       up(&dev->sem);
+                                       mutex_unlock(&dev->mtx);
                                        return ret;
                                } else
                                        return -EINVAL;
@@ -1514,6 +1515,7 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
                                        if (copy_from_user(&iocts, argp,
                                             sizeof(isdn_ioctl_struct)))
                                                return -EFAULT;
+                                       iocts.drvid[sizeof(iocts.drvid)-1] = 0;
                                        if (strlen(iocts.drvid)) {
                                                if ((p = strchr(iocts.drvid, ',')))
                                                        *p = 0;
@@ -1598,6 +1600,7 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
                                        if (copy_from_user(&iocts, argp,
                                             sizeof(isdn_ioctl_struct)))
                                                return -EFAULT;
+                                       iocts.drvid[sizeof(iocts.drvid)-1] = 0;
                                        if (strlen(iocts.drvid)) {
                                                drvidx = -1;
                                                for (i = 0; i < ISDN_MAX_DRIVERS; i++)
@@ -1642,7 +1645,7 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
                                        } else {
                                                p = (char __user *) iocts.arg;
                                                for (i = 0; i < 10; i++) {
-                                                       sprintf(bname, "%s%s",
+                                                       snprintf(bname, sizeof(bname), "%s%s",
                                                                strlen(dev->drv[drvidx]->msn2eaz[i]) ?
                                                                dev->drv[drvidx]->msn2eaz[i] : "_",
                                                                (i < 9) ? "," : "\0");
@@ -1672,6 +1675,7 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
                                        char *p;
                                        if (copy_from_user(&iocts, argp, sizeof(isdn_ioctl_struct)))
                                                return -EFAULT;
+                                       iocts.drvid[sizeof(iocts.drvid)-1] = 0;
                                        if (strlen(iocts.drvid)) {
                                                if ((p = strchr(iocts.drvid, ',')))
                                                        *p = 0;
@@ -2291,7 +2295,7 @@ static int __init isdn_init(void)
        int i;
        char tmprev[50];
 
-       if (!(dev = (isdn_dev *) vmalloc(sizeof(isdn_dev)))) {
+       if (!(dev = vmalloc(sizeof(isdn_dev)))) {
                printk(KERN_WARNING "isdn: Could not allocate device-struct.\n");
                return -EIO;
        }
@@ -2303,7 +2307,7 @@ static int __init isdn_init(void)
 #ifdef MODULE
        dev->owner = THIS_MODULE;
 #endif
-       init_MUTEX(&dev->sem);
+       mutex_init(&dev->mtx);
        init_waitqueue_head(&dev->info_waitq);
        for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
                dev->drvmap[i] = -1;