[PATCH] plip.c in 2.1.125

Ely Wilson (plexus@ionet.net)
Sat, 10 Oct 1998 12:53:34 -0500 (CDT)


below is a diff for plip.c in 2.1.125 (see subject):

It removes a few redundant calles to synchronize_irq(), which is called by
disable_irq() *always* before return.

Removed a check from the irq handler for a plip devices, this was
basically a 'gripe if irq raised and being handled for a device not
currently in existance' which IMHO was a redundant check as well since 1)
that handler i snever assigned if teh device is non-existant and 2) when
the device goes out of existance there is nothing that *might* stop the
removal of teh irq handler. lastly teh check did NOTHIGN except print out
a message that the handler was trying to handle a device that was not
there, it providing no 'error handling mechanism' just a message. (if it
is *really*necessar i think it shoudl be moved back in as a debug check.

Oh yes, also, I changed NET_DEBUG to PLIP_DEBUG and removed the runtime
checks making them preprocesor checks. (surprise! surprise!) so that there
isn't any extra overhead (mainly in the irq handler, so i just changed it
everywhere else) in checking if PLIP_DEBUG was set to a value.

Hmm, beyond all obvious, i added 1500 usecs to the timout delay to reduce
the number of timout messages, also, I modified teh timeout printk()'s to
that they only print during a PLIP-DEBUG of 1 or greater (they are a
nuisance you know, and they don't serve any purpose other than to notify
you of timeouts, so i figured that they wer best left as a debug option.

*sigh* lastly the PLIP_DEBUG defaults to 0 instead of 1 now. The way I see
it is that if you want DEBUG checks on you should be turning them on
yourself as needed(1 or 2), otehrwise it's production code (0) and there
were many checks for a NET_DEBUG > 2 where NET_DEBUG shoudlnever be > 2
(but those check fit NICELY with > 1 :) and so they were changed to > 1.

Hmm, i recall form feed characters as well, so if they don't save
correclty from this message (i.e you mailr converts teh ^L to an actual ^L
you'll have to remove thos elines yourself.

%--* ely % hmm, did you hear that? blah, blah blah blah.

--- plip.c.old Mon Sep 14 12:50:54 1998
+++ plip.c Sat Oct 10 09:01:11 1998
@@ -115,10 +115,9 @@
#define PLIP_MAX 8

/* Use 0 for production, 1 for verification, >2 for debug */
-#ifndef NET_DEBUG
-#define NET_DEBUG 1
+#ifndef PLIP_DEBUG
+#define PLIP_DEBUG 0
#endif
-static unsigned int net_debug = NET_DEBUG;

/* In micro second */
#define PLIP_DELAY_UNIT 1
@@ -127,7 +126,7 @@
#define PLIP_TRIGGER_WAIT 500

/* Nibble time out = PLIP_NIBBLE_WAIT * PLIP_DELAY_UNIT usec */
-#define PLIP_NIBBLE_WAIT 3000
+#define PLIP_NIBBLE_WAIT 4500

#define PAR_INTR_ON (LP_PINITP|LP_PSELECP|LP_PINTEN)
#define PAR_INTR_OFF (LP_PINITP|LP_PSELECP)
@@ -152,7 +151,7 @@
static int plip_ioctl(struct device *dev, struct ifreq *ifr, int cmd);
static int plip_preempt(void *handle);
static void plip_wakeup(void *handle);
-
+
enum plip_connection_state {
PLIP_CN_NONE=0,
PLIP_CN_RECEIVE,
@@ -216,7 +215,7 @@
int (*orig_rebuild_header)(struct sk_buff *skb);
spinlock_t lock;
};
-
+
/* Entry point of PLIP driver.
Probe the hardware, and register/initialize the driver.

@@ -296,7 +295,7 @@

return 0;
}
-
+
/* Bottom half handler for the delayed request.
This routine is kicked by do_timer().
Request `plip_bh' to be invoked. */
@@ -382,8 +381,10 @@
return TIMEOUT;
}
c0 = inb(PAR_STATUS(dev));
+#if (PLIP_DEBUG > 0)
printk(KERN_WARNING "%s: transmit timeout(%d,%02x)\n",
dev->name, snd->state, c0);
+#endif
}
nl->enet_stats.tx_errors++;
nl->enet_stats.tx_aborted_errors++;
@@ -400,8 +401,10 @@
return TIMEOUT;
}
c0 = inb(PAR_STATUS(dev));
+#if (PLIP_DEBUG > 0)
printk(KERN_WARNING "%s: receive timeout(%d,%02x)\n",
dev->name, rcv->state, c0);
+#endif
}
nl->enet_stats.rx_dropped++;
}
@@ -417,7 +420,7 @@
}
spin_unlock_irq(&nl->lock);
disable_irq(dev->irq);
- synchronize_irq();
+ /* synchronize_irq() is called before return in disable_irq() */
outb(PAR_INTR_OFF, PAR_CONTROL(dev));
dev->tbusy = 1;
nl->connection = PLIP_CN_ERROR;
@@ -425,7 +428,7 @@

return TIMEOUT;
}
-
+
static int
plip_none(struct device *dev, struct net_local *nl,
struct plip_local *snd, struct plip_local *rcv)
@@ -496,12 +499,12 @@
switch (rcv->state) {
case PLIP_PK_TRIGGER:
disable_irq(dev->irq);
- /* Don't need to synchronize irq, as we can safely ignore it */
outb(PAR_INTR_OFF, PAR_CONTROL(dev));
dev->interrupt = 0;
outb(0x01, PAR_DATA(dev)); /* send ACK */
- if (net_debug > 2)
- printk(KERN_DEBUG "%s: receive start\n", dev->name);
+#if (PLIP_DEBUG > 1)
+ printk(KERN_DEBUG "%s: receive start\n", dev->name);
+#endif
rcv->state = PLIP_PK_LENGTH_LSB;
rcv->nibble = PLIP_NB_BEGIN;

@@ -564,8 +567,9 @@
return TIMEOUT;
if (rcv->data != rcv->checksum) {
nl->enet_stats.rx_crc_errors++;
- if (net_debug)
- printk(KERN_DEBUG "%s: checksum error\n", dev->name);
+#if (PLIP_DEBUG > 0)
+ printk(KERN_DEBUG "%s: checksum error\n", dev->name);
+#endif
return ERROR;
}
rcv->state = PLIP_PK_DONE;
@@ -577,8 +581,9 @@
nl->enet_stats.rx_bytes += rcv->length.h;
nl->enet_stats.rx_packets++;
rcv->skb = NULL;
- if (net_debug > 2)
- printk(KERN_DEBUG "%s: receive end\n", dev->name);
+#if (PLIP_DEBUG > 1)
+ printk(KERN_DEBUG "%s: receive end\n", dev->name);
+#endif

/* Close the connection. */
outb (0x00, PAR_DATA(dev));
@@ -689,7 +694,6 @@
if (c0 & 0x08) {
spin_unlock_irq(&nl->lock);
disable_irq(dev->irq);
- synchronize_irq();
if (nl->connection == PLIP_CN_RECEIVE) {
/* Interrupted.
We don't need to enable irq,
@@ -698,8 +702,9 @@
return OK;
}
outb(PAR_INTR_OFF, PAR_CONTROL(dev));
- if (net_debug > 2)
- printk(KERN_DEBUG "%s: send start\n", dev->name);
+#if (PLIP_DEBUG > 1)
+ printk(KERN_DEBUG "%s: send start\n", dev->name);
+#endif
snd->state = PLIP_PK_LENGTH_LSB;
snd->nibble = PLIP_NB_BEGIN;
nl->timeout_count = 0;
@@ -751,8 +756,9 @@
/* Close the connection */
outb (0x00, data_addr);
snd->skb = NULL;
- if (net_debug > 2)
- printk(KERN_DEBUG "%s: send end\n", dev->name);
+#if (PLIP_DEBUG > 1)
+ printk(KERN_DEBUG "%s: send end\n", dev->name);
+#endif
nl->connection = PLIP_CN_CLOSING;
nl->is_deferred = 1;
queue_task(&nl->deferred, &tq_timer);
@@ -790,8 +796,9 @@

status = inb(PAR_STATUS(dev));
if ((status & 0xf8) == 0x80) {
- if (net_debug > 2)
- printk(KERN_DEBUG "%s: reset interface.\n", dev->name);
+#if (PLIP_DEBUG > 1)
+ printk(KERN_DEBUG "%s: reset interface.\n", dev->name);
+#endif
nl->connection = PLIP_CN_NONE;
nl->should_relinquish = 0;
dev->tbusy = 0;
@@ -806,7 +813,7 @@

return OK;
}
-
+
/* Handle the parallel port interrupts. */
static void
plip_interrupt(int irq, void *dev_id, struct pt_regs * regs)
@@ -816,11 +823,6 @@
struct plip_local *rcv;
unsigned char c0;

- if (dev == NULL) {
- printk(KERN_DEBUG "plip_interrupt: irq %d for unknown device.\n", irq);
- return;
- }
-
nl = (struct net_local *)dev->priv;
rcv = &nl->rcv_data;

@@ -829,13 +831,15 @@

c0 = inb(PAR_STATUS(dev));
if ((c0 & 0xf8) != 0xc0) {
- if (net_debug > 1)
- printk(KERN_DEBUG "%s: spurious interrupt\n", dev->name);
+#if (PLIP_DEBUG > 1)
+ printk(KERN_DEBUG "%s: spurious interrupt\n", dev->name);
+#endif
return;
}
dev->interrupt = 1;
- if (net_debug > 3)
- printk(KERN_DEBUG "%s: interrupt.\n", dev->name);
+#if (PLIP_DEBUG > 1)
+ printk(KERN_DEBUG "%s: interrupt.\n", dev->name);
+#endif

spin_lock_irq(&nl->lock);
switch (nl->connection) {
@@ -865,7 +869,7 @@
break;
}
}
-
+
/* We don't need to send arp, for plip is point-to-point. */
static int
plip_rebuild_header(struct sk_buff *skb)
@@ -909,9 +913,9 @@
return 0;
}

- if (net_debug > 2)
- printk(KERN_DEBUG "%s: send request\n", dev->name);
-
+#if (PLIP_DEBUG > 1)
+ printk(KERN_DEBUG "%s: send request\n", dev->name);
+#endif
spin_lock_irq(&nl->lock);
dev->trans_start = jiffies;
snd->skb = skb;
@@ -998,7 +1002,6 @@
dev->tbusy = 1;
dev->start = 0;
disable_irq(dev->irq);
- synchronize_irq();

#ifdef NOTDEF
outb(0x00, PAR_DATA(dev));
@@ -1124,7 +1127,7 @@
}
return 0;
}
-
+
static int parport[PLIP_MAX] = { [0 ... PLIP_MAX-1] = -1 };
static int timid = 0;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/