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 / block / paride / pg.c
index d73e3ec..79b8682 100644 (file)
@@ -162,35 +162,18 @@ 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>
 
-#ifndef MODULE
-
-#include "setup.h"
-
-static STT pg_stt[5] = {
-       {"drive0", 6, drive0},
-       {"drive1", 6, drive1},
-       {"drive2", 6, drive2},
-       {"drive3", 6, drive3},
-       {"disable", 1, &disable}
-};
-
-void pg_setup(char *str, int *ints)
-{
-       generic_setup(pg_stt, 5, str);
-}
-
-#endif
-
-MODULE_PARM(verbose, "i");
-MODULE_PARM(major, "i");
-MODULE_PARM(name, "s");
-MODULE_PARM(drive0, "1-6i");
-MODULE_PARM(drive1, "1-6i");
-MODULE_PARM(drive2, "1-6i");
-MODULE_PARM(drive3, "1-6i");
+module_param(verbose, bool, 0644);
+module_param(major, int, 0);
+module_param(name, charp, 0);
+module_param_array(drive0, int, NULL, 0);
+module_param_array(drive1, int, NULL, 0);
+module_param_array(drive2, int, NULL, 0);
+module_param_array(drive3, int, NULL, 0);
 
 #include "paride.h"
 
@@ -235,13 +218,13 @@ struct pg {
        char name[PG_NAMELEN];  /* pg0, pg1, ... */
 };
 
-struct pg devices[PG_UNITS];
+static struct pg devices[PG_UNITS];
 
 static int pg_identify(struct pg *dev, int log);
 
 static char pg_scratch[512];   /* scratch block buffer */
 
-static struct class_simple *pg_class;
+static struct class *pg_class;
 
 /* kernel glue structures */
 
@@ -262,7 +245,7 @@ static void pg_init_units(void)
                int *parm = *drives[unit];
                struct pg *dev = &devices[unit];
                dev->pi = &dev->pia;
-               set_bit(0, &dev->access);
+               clear_bit(0, &dev->access);
                dev->busy = 0;
                dev->present = 0;
                dev->bufptr = NULL;
@@ -295,8 +278,7 @@ static inline u8 DRIVE(struct pg *dev)
 
 static void pg_sleep(int cs)
 {
-       current->state = TASK_INTERRUPTIBLE;
-       schedule_timeout(cs);
+       schedule_timeout_interruptible(cs);
 }
 
 static int pg_wait(struct pg *dev, int go, int stop, unsigned long tmo, char *msg)
@@ -661,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;
@@ -675,17 +658,18 @@ 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;
        }
-       pg_class = class_simple_create(THIS_MODULE, "pg");
+       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);
                goto out_chrdev;
@@ -694,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_simple_device_add(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",
@@ -707,8 +691,8 @@ static int __init pg_init(void)
        goto out;
 
 out_class:
-       class_simple_device_remove(MKDEV(major, unit));
-       class_simple_destroy(pg_class);
+       class_device_destroy(pg_class, MKDEV(major, unit));
+       class_destroy(pg_class);
 out_chrdev:
        unregister_chrdev(major, "pg");
 out:
@@ -722,11 +706,11 @@ static void __exit pg_exit(void)
        for (unit = 0; unit < PG_UNITS; unit++) {
                struct pg *dev = &devices[unit];
                if (dev->present) {
-                       class_simple_device_remove(MKDEV(major, unit));
+                       class_device_destroy(pg_class, MKDEV(major, unit));
                        devfs_remove("pg/%u", unit);
                }
        }
-       class_simple_destroy(pg_class);
+       class_destroy(pg_class);
        devfs_remove("pg");
        unregister_chrdev(major, name);