lp.c in 2.0.x

Wolfgang Walter (wolfgang.walter@stusta.mhn.de)
Sat, 25 Apr 1998 02:13:07 +0200


Hi !

I have a problem with lp in 2.0.x when printing with plp spooler system on
faster machines to a FS-600 using IRQ's (normal and epp/ecp modes). I don't
have this problems when I use a pentium 120 or when I use polling mode. The
problem is that only parts get printed. The following patch fixes the problem,
so I'm not shure why it exactly works. My real intention for this patch was to
observe the interrupts more easily. Can it be that on faster machines plp
can close the line bevor all is printed?

If anyone has similar problems, does this help, too?

Wolfgang Walter

Here's the patch:

--- lp.c.orig1 Fri Apr 24 19:27:20 1998
+++ lp.c Fri Apr 24 19:45:35 1998
@@ -320,8 +320,10 @@
static int lp_open(struct inode * inode, struct file * file)
{
unsigned int minor = MINOR(inode->i_rdev);
+#if 0
int ret;
unsigned int irq;
+#endif

if (minor >= LP_NO)
return -ENXIO;
@@ -354,6 +356,7 @@
}
}

+#if 0
if ((irq = LP_IRQ(minor))) {
lp_table[minor].lp_buffer = (char *) kmalloc(LP_BUFFER_SIZE, GFP_KERNEL);
if (!lp_table[minor].lp_buffer) {
@@ -370,6 +373,7 @@
return ret;
}
}
+#endif

LP_F(minor) |= LP_BUSY;
return 0;
@@ -378,13 +382,17 @@
static void lp_release(struct inode * inode, struct file * file)
{
unsigned int minor = MINOR(inode->i_rdev);
+#if 0
unsigned int irq;
+#endif

+#if 0
if ((irq = LP_IRQ(minor))) {
free_irq(irq, NULL);
kfree_s(lp_table[minor].lp_buffer, LP_BUFFER_SIZE);
lp_table[minor].lp_buffer = NULL;
}
+#endif

LP_F(minor) &= ~LP_BUSY;
MOD_DEC_USE_COUNT;
@@ -539,6 +547,9 @@
{
int base, size;
unsigned int testvalue;
+#if 1
+ unsigned int irq;
+#endif

base = LP_B(offset);
if (base == 0)
@@ -557,9 +568,27 @@
lp_reset(offset);
printk(KERN_INFO "lp%d at 0x%04x, ", offset, base);
request_region(base, size, "lp");
- if (LP_IRQ(offset))
+ if (LP_IRQ(offset)) {
printk("(irq = %d)\n", LP_IRQ(offset));
- else
+#if 1
+ if ((irq = LP_IRQ(offset))) {
+ int ret = 0;
+
+ lp_table[offset].lp_buffer = (char *) kmalloc(LP_BUFFER_SIZE, GFP_KERNEL);
+ if (!lp_table[offset].lp_buffer) {
+ return 0;
+ }
+
+ ret = request_irq(irq, lp_interrupt, SA_INTERRUPT, "printer", NULL);
+ if (ret) {
+ kfree_s(lp_table[offset].lp_buffer, LP_BUFFER_SIZE);
+ lp_table[offset].lp_buffer = NULL;
+ printk("lp%d unable to use interrupt %d, error %d\n", offset, irq, ret);
+ return 0;
+ }
+ }
+#endif
+ } else
printk("(polling)\n");
return 1;
} else
@@ -665,6 +694,9 @@
void cleanup_module(void)
{
int offset;
+#if 1
+ unsigend int irq;
+#endif

unregister_chrdev(LP_MAJOR,"lp");
for (offset = 0; offset < LP_NO; offset++) {
@@ -674,5 +706,14 @@
if (LP_F(offset) & LP_EXIST)
release_region(LP_B(offset),size);
}
+
+#if 1
+ if ((irq = LP_IRQ(minor))) {
+ free_irq(irq, NULL);
+ kfree_s(lp_table[minor].lp_buffer, LP_BUFFER_SIZE);
+ lp_table[minor].lp_buffer = NULL;
+ }
+#endif
+
}
#endif

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu