int lp_init(void) { int offset = 0; int count = 0; #ifdef MODULE int failed = 0; #endif if (register_chrdev(LP_MAJOR,"lp",&lp_fops)) { printk("lp: unable to get major %d\n", LP_MAJOR); return -EIO; } #ifdef MODULE /* When user feeds parameters, use them */ for (offset=0; offset < LP_NO; offset++) { int specified=0; if (io[offset] != 0) { LP_B(offset) = io[offset]; specified++; } if (irq[offset] != 0) { LP_IRQ(offset) = irq[offset]; specified++; } if (specified) { if (lp_probe(offset) <= 0) { printk(KERN_INFO "lp%d: Not found\n", offset); 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++) { int ret = lp_probe(offset); if (ret < 0) continue; count += ret; } if (count == 0) printk("lp: Driver configured but no interfaces found.\n"); return 0; }
void lp_init(void) { register struct lp_info *lp = &ports[0]; register char *ip; int count = 0; #ifdef BIOS_PORTS /* only ports 0, 1, 2 and 3 may exist according to RB's intlist */ for (ip = 0; ((int)ip) < LP_PORTS; ip++) { /* 8 is offset for LPT info, 2 bytes for each entry */ lp->io = (char *)peekw(0x40, (__u16) (2 * ((int)ip) + 8)); /* returns 0 if port wasn't detected by BIOS at bootup */ if (!lp->io) break; /* there can be no more ports */ printk("lp%d at 0x%x, using polling driver\n", (int)ip, lp->io); lp->flags = LP_EXIST; lp++; } count = (int)ip; #else /* probe for ports */ for (ip = 0; ((int)ip) < LP_PORTS; ip++) { if (!lp_probe(lp)) { printk("lp%d at 0x%x, using polling driver\n", (int)ip, lp->io); port_order[count] = (int)ip; count++; } lp++; } #endif if (count == 0) printk("lp: no ports found\n"); /* register device */ if (register_chrdev(LP_MAJOR, LP_DEVICE_NAME, &lp_fops)) printk("lp: unable to register\n"); }