Merge tag 'armsoc-dt' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
[linux-2.6-block.git] / fs / char_dev.c
index a65e4a56318ca79d17c91e36c69c6aa3371728e4..a279c58fe3606224df4c7c441090ed07f98d15b9 100644 (file)
@@ -67,18 +67,18 @@ static int find_dynamic_major(void)
        int i;
        struct char_device_struct *cd;
 
-       for (i = ARRAY_SIZE(chrdevs)-1; i > CHRDEV_MAJOR_DYN_END; i--) {
+       for (i = ARRAY_SIZE(chrdevs)-1; i >= CHRDEV_MAJOR_DYN_END; i--) {
                if (chrdevs[i] == NULL)
                        return i;
        }
 
        for (i = CHRDEV_MAJOR_DYN_EXT_START;
-            i > CHRDEV_MAJOR_DYN_EXT_END; i--) {
+            i >= CHRDEV_MAJOR_DYN_EXT_END; i--) {
                for (cd = chrdevs[major_to_index(i)]; cd; cd = cd->next)
                        if (cd->major == i)
                                break;
 
-               if (cd == NULL || cd->major != i)
+               if (cd == NULL)
                        return i;
        }
 
@@ -121,8 +121,8 @@ __register_chrdev_region(unsigned int major, unsigned int baseminor,
        }
 
        if (major >= CHRDEV_MAJOR_MAX) {
-               pr_err("CHRDEV \"%s\" major requested (%d) is greater than the maximum (%d)\n",
-                      name, major, CHRDEV_MAJOR_MAX);
+               pr_err("CHRDEV \"%s\" major requested (%u) is greater than the maximum (%u)\n",
+                      name, major, CHRDEV_MAJOR_MAX-1);
                ret = -EINVAL;
                goto out;
        }