Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6
[cascardo/linux.git] / drivers / block / paride / pg.c
index b398239..79b8682 100644 (file)
@@ -162,6 +162,8 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_SLV, D_DLY};
 #include <linux/mtio.h>
 #include <linux/pg.h>
 #include <linux/device.h>
+#include <linux/sched.h>       /* current, TASK_* */
+#include <linux/jiffies.h>
 
 #include <asm/uaccess.h>
 
@@ -641,7 +643,8 @@ static ssize_t pg_read(struct file *filp, char __user *buf, size_t count, loff_t
 
 static int __init pg_init(void)
 {
-       int unit, err = 0;
+       int unit;
+       int err;
 
        if (disable){
                err = -1;
@@ -655,16 +658,17 @@ static int __init pg_init(void)
                goto out;
        }
 
-       if (register_chrdev(major, name, &pg_fops)) {
+       err = register_chrdev(major, name, &pg_fops);
+       if (err < 0) {
                printk("pg_init: unable to get major number %d\n", major);
                for (unit = 0; unit < PG_UNITS; unit++) {
                        struct pg *dev = &devices[unit];
                        if (dev->present)
                                pi_release(dev->pi);
                }
-               err = -1;
                goto out;
        }
+       major = err;    /* In case the user specified `major=0' (dynamic) */
        pg_class = class_create(THIS_MODULE, "pg");
        if (IS_ERR(pg_class)) {
                err = PTR_ERR(pg_class);
@@ -674,7 +678,7 @@ static int __init pg_init(void)
        for (unit = 0; unit < PG_UNITS; unit++) {
                struct pg *dev = &devices[unit];
                if (dev->present) {
-                       class_device_create(pg_class, MKDEV(major, unit),
+                       class_device_create(pg_class, NULL, MKDEV(major, unit),
                                        NULL, "pg%u", unit);
                        err = devfs_mk_cdev(MKDEV(major, unit),
                                      S_IFCHR | S_IRUSR | S_IWUSR, "pg/%u",