patch-1.3.77 linux/drivers/char/lp.c

Next file: linux/drivers/scsi/NCR5380.c
Previous file: linux/drivers/char/ftape/Makefile
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.76/linux/drivers/char/lp.c linux/drivers/char/lp.c
@@ -602,6 +602,7 @@
 {
 	int offset = 0;
 	int count = 0;
+	int failed = 0;
 
 	if (register_chrdev(LP_MAJOR,"lp",&lp_fops)) {
 		printk("lp: unable to get major %d\n", LP_MAJOR);
@@ -623,13 +624,25 @@
 		if (specified) {
 			if (lp_probe(offset) <= 0) {
 				printk(KERN_INFO "lp%d: Not found\n", offset);
-				return -EIO;
+				failed++;
 			} else
 				count++;
 		}
 	}
+	/* Successful specified devices increase count
+	 * Unsuccessful specified devices increase failed
+	 */
 	if (count)
 		return 0;
+	if (failed) {
+		printk(KERN_INFO "lp: No override devices found.\n");
+		unregister_chrdev(LP_MAJOR,"lp");
+		return -EIO;
+	}
+	/* Only get here if there were no specified devices. To continue 
+	 * would be silly since the above code has scribbled all over the
+	 * probe list.
+	 */
 #endif
 	/* take on all known port values */
 	for (offset = 0; offset < LP_NO; offset++) {

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this