summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>1999-02-08 13:55:43 +0000
committerdes <des@FreeBSD.org>1999-02-08 13:55:43 +0000
commite96a20a328e66d47d7df867d1ec17071d1bde3ec (patch)
treeb99a55a7427e90e54af679800cd0694fbcd4fecf /sys
parentec671918f4c46144854340b7fe387f145a7f3776 (diff)
downloadFreeBSD-src-e96a20a328e66d47d7df867d1ec17071d1bde3ec.zip
FreeBSD-src-e96a20a328e66d47d7df867d1ec17071d1bde3ec.tar.gz
Bring in the simplified port probe from src/sys/i386/isa/lpt.c
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/ppbus/nlpt.c46
1 files changed, 20 insertions, 26 deletions
diff --git a/sys/dev/ppbus/nlpt.c b/sys/dev/ppbus/nlpt.c
index 4a4e0ff..b28c21f 100644
--- a/sys/dev/ppbus/nlpt.c
+++ b/sys/dev/ppbus/nlpt.c
@@ -47,7 +47,7 @@
*
* from: unknown origin, 386BSD 0.1
* From Id: lpt.c,v 1.55.2.1 1996/11/12 09:08:38 phk Exp
- * $Id: nlpt.c,v 1.12 1999/01/10 12:04:54 nsouch Exp $
+ * $Id: nlpt.c,v 1.13 1999/01/27 20:09:19 dillon Exp $
*/
/*
@@ -221,6 +221,9 @@ nlpt_port_test(struct lpt_data *sc, u_char data, u_char mask)
}
/*
+ * Probe simplified by replacing multiple loops with a hardcoded
+ * test pattern - 1999/02/08 des@freebsd.org
+ *
* New lpt port probe Geoff Rehmet - Rhodes University - 14/2/94
* Based partially on Rod Grimes' printer probe
*
@@ -267,38 +270,29 @@ nlpt_port_test(struct lpt_data *sc, u_char data, u_char mask)
static int
nlpt_detect(struct lpt_data *sc)
{
- int status;
- u_char data;
- u_char mask;
- int i, error;
+ static u_char testbyte[18] = {
+ 0x55, /* alternating zeros */
+ 0xaa, /* alternating ones */
+ 0xfe, 0xfd, 0xfb, 0xf7,
+ 0xef, 0xdf, 0xbf, 0x7f, /* walking zero */
+ 0x01, 0x02, 0x04, 0x08,
+ 0x10, 0x20, 0x40, 0x80 /* walking one */
+ };
+ int i, error, status;
status = 1; /* assume success */
if ((error = lpt_request_ppbus(sc, PPB_DONTWAIT))) {
printf(LPT_NAME ": cannot alloc ppbus (%d)!\n", error);
- status = 0 ; goto end_probe ;
+ status = 0;
+ goto end_probe;
}
- mask = 0xff;
- data = 0x55; /* Alternating zeros */
- if (!nlpt_port_test(sc, data, mask))
- { status = 0 ; goto end_probe ; }
-
- data = 0xaa; /* Alternating ones */
- if (!nlpt_port_test(sc, data, mask))
- { status = 0 ; goto end_probe ; }
-
- for (i = 0; i < 8; i++) { /* Walking zero */
- data = ~(1 << i);
- if (!nlpt_port_test(sc, data, mask))
- { status = 0 ; goto end_probe ; }
- }
-
- for (i = 0; i < 8; i++) { /* Walking one */
- data = (1 << i);
- if (!nlpt_port_test(sc, data, mask))
- { status = 0 ; goto end_probe ; }
- }
+ for (i = 0; i < 18 && status; i++)
+ if (!nlpt_port_test(sc, testbyte[i], 0xff)) {
+ status = 0;
+ goto end_probe;
+ }
end_probe:
/* write 0's to control and data ports */
OpenPOWER on IntegriCloud