X-Git-Url: http://pilppa.org/gitweb/?a=blobdiff_plain;f=drivers%2Fchar%2Ftipar.c;h=9df0ca1be0e31a4e25310e58b370c10da4227c78;hb=5d347c8abaab1e8c24272a53099c22482855783e;hp=41a94bc79f67f4536f8ce164f9f3a3bae263da4e;hpb=8a212ab6b8a4ccc6f3c3d1beba5f92655c576404;p=linux-2.6-omap-h63xx.git diff --git a/drivers/char/tipar.c b/drivers/char/tipar.c index 41a94bc79f6..9df0ca1be0e 100644 --- a/drivers/char/tipar.c +++ b/drivers/char/tipar.c @@ -42,7 +42,6 @@ */ #undef DEBUG /* change to #define to get debugging * output - for pr_debug() */ -#include #include #include #include @@ -56,7 +55,6 @@ #include #include #include -#include /* DevFs support */ #include /* Our code depend on parport */ #include @@ -226,14 +224,16 @@ probe_ti_parallel(int minor) { int i; int seq[] = { 0x00, 0x20, 0x10, 0x30 }; + int data; for (i = 3; i >= 0; i--) { outbyte(3, minor); outbyte(i, minor); udelay(delay); + data = inbyte(minor) & 0x30; pr_debug("tipar: Probing -> %i: 0x%02x 0x%02x\n", i, - data & 0x30, seq[i]); - if ((inbyte(minor) & 0x30) != seq[i]) { + data, seq[i]); + if (data != seq[i]) { outbyte(3, minor); return -1; } @@ -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); @@ -378,7 +383,7 @@ tipar_ioctl(struct inode *inode, struct file *file, /* ----- kernel module registering ------------------------------------ */ -static struct file_operations tipar_fops = { +static const struct file_operations tipar_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .read = tipar_read, @@ -438,12 +443,6 @@ tipar_register(int nr, struct parport *port) 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), - S_IFCHR | S_IRUGO | S_IWUGO, - "ticables/par/%d", nr); - if (err) - goto out_class; /* Display informations */ pr_info("tipar%d: using %s (%s)\n", nr, port->name, (port->irq == @@ -455,11 +454,7 @@ tipar_register(int nr, struct parport *port) pr_info("tipar%d: link cable not found\n", nr); err = 0; - goto out; -out_class: - class_device_destroy(tipar_class, MKDEV(TIPAR_MAJOR, TIPAR_MINOR + nr)); - class_destroy(tipar_class); out: return err; } @@ -502,9 +497,6 @@ tipar_init_module(void) goto out; } - /* Use devfs with tree: /dev/ticables/par/[0..2] */ - devfs_mk_dir("ticables/par"); - tipar_class = class_create(THIS_MODULE, "ticables"); if (IS_ERR(tipar_class)) { err = PTR_ERR(tipar_class); @@ -513,12 +505,15 @@ 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: unregister_chrdev(TIPAR_MAJOR, "tipar"); out: @@ -540,10 +535,8 @@ tipar_cleanup_module(void) continue; parport_unregister_device(table[i].dev); class_device_destroy(tipar_class, MKDEV(TIPAR_MAJOR, i)); - devfs_remove("ticables/par/%d", i); } class_destroy(tipar_class); - devfs_remove("ticables/par"); pr_info("tipar: module unloaded\n"); }