]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/char/tipar.c
Pull video into release branch
[linux-2.6-omap-h63xx.git] / drivers / char / tipar.c
index ec78d2f161f75363b5d971e7ba1713ef3aa4899f..079db5a935a1210520d332071d6a47611182dfa4 100644 (file)
@@ -250,12 +250,17 @@ tipar_open(struct inode *inode, struct file *file)
 {
        unsigned int minor = iminor(inode) - TIPAR_MINOR;
 
-       if (minor > tp_count - 1)
+       if (tp_count == 0 || minor > tp_count - 1)
                return -ENXIO;
 
        if (test_and_set_bit(minor, &opened))
                return -EBUSY;
 
+       if (!table[minor].dev) {
+               printk(KERN_ERR "%s: NULL device for minor %u\n",
+                               __FUNCTION__, minor);
+               return -ENXIO;
+       }
        parport_claim_or_block(table[minor].dev);
        init_ti_parallel(minor);
        parport_release(table[minor].dev);
@@ -436,7 +441,7 @@ tipar_register(int nr, struct parport *port)
                goto out;
        }
 
-       class_device_create(tipar_class, MKDEV(TIPAR_MAJOR,
+       class_device_create(tipar_class, NULL, MKDEV(TIPAR_MAJOR,
                        TIPAR_MINOR + nr), NULL, "par%d", nr);
        /* Use devfs, tree: /dev/ticables/par/[0..2] */
        err = devfs_mk_cdev(MKDEV(TIPAR_MAJOR, TIPAR_MINOR + nr),
@@ -513,13 +518,17 @@ tipar_init_module(void)
        if (parport_register_driver(&tipar_driver)) {
                printk(KERN_ERR "tipar: unable to register with parport\n");
                err = -EIO;
-               goto out;
+               goto out_class;
        }
 
        err = 0;
        goto out;
 
+out_class:
+       class_destroy(tipar_class);
+
 out_chrdev:
+       devfs_remove("ticables/par");
        unregister_chrdev(TIPAR_MAJOR, "tipar");
 out:
        return err;