linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / char / ppdev.c
index 520d2cf..306ee0f 100644 (file)
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/device.h>
+#include <linux/devfs_fs_kernel.h>
 #include <linux/ioctl.h>
 #include <linux/parport.h>
 #include <linux/ctype.h>
 #include <linux/poll.h>
-#include <linux/major.h>
+#include <asm/uaccess.h>
 #include <linux/ppdev.h>
 #include <linux/smp_lock.h>
 #include <linux/device.h>
-#include <asm/uaccess.h>
 
 #define PP_VERSION "ppdev: user-space parallel port driver"
 #define CHRDEV "ppdev"
@@ -739,7 +739,7 @@ static unsigned int pp_poll (struct file * file, poll_table * wait)
 
 static struct class *ppdev_class;
 
-static const struct file_operations pp_fops = {
+static struct file_operations pp_fops = {
        .owner          = THIS_MODULE,
        .llseek         = no_llseek,
        .read           = pp_read,
@@ -769,7 +769,7 @@ static struct parport_driver pp_driver = {
 
 static int __init ppdev_init (void)
 {
-       int err = 0;
+       int i, err = 0;
 
        if (register_chrdev (PP_MAJOR, CHRDEV, &pp_fops)) {
                printk (KERN_WARNING CHRDEV ": unable to get major %d\n",
@@ -781,6 +781,11 @@ static int __init ppdev_init (void)
                err = PTR_ERR(ppdev_class);
                goto out_chrdev;
        }
+       devfs_mk_dir("parports");
+       for (i = 0; i < PARPORT_MAX; i++) {
+               devfs_mk_cdev(MKDEV(PP_MAJOR, i),
+                               S_IFCHR | S_IRUGO | S_IWUGO, "parports/%d", i);
+       }
        if (parport_register_driver(&pp_driver)) {
                printk (KERN_WARNING CHRDEV ": unable to register with parport\n");
                goto out_class;
@@ -790,6 +795,9 @@ static int __init ppdev_init (void)
        goto out;
 
 out_class:
+       for (i = 0; i < PARPORT_MAX; i++)
+               devfs_remove("parports/%d", i);
+       devfs_remove("parports");
        class_destroy(ppdev_class);
 out_chrdev:
        unregister_chrdev(PP_MAJOR, CHRDEV);
@@ -799,8 +807,12 @@ out:
 
 static void __exit ppdev_cleanup (void)
 {
+       int i;
        /* Clean up all parport stuff */
+       for (i = 0; i < PARPORT_MAX; i++)
+               devfs_remove("parports/%d", i);
        parport_unregister_driver(&pp_driver);
+       devfs_remove("parports");
        class_destroy(ppdev_class);
        unregister_chrdev (PP_MAJOR, CHRDEV);
 }