Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Dec 2002 15:30:45 -0800 (PST)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 22956 for review
Message-ID:  <200212302330.gBUNUjVn009139@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=22956

Change 22956 by marcel@marcel_nfs on 2002/12/30 15:30:22

	Replace the debug printf() calls with calls to siodebug()
	and have the definition of siodebug() depend on whether
	SIO_DEBUG is defined. If SIO_DEBUG is not defined, we
	define siodebug() as an empty inline so that it gets
	optimized away.
	SIO_DEBUG is undefined by default, so the verbosity is now
	gone.

Affected files ...

.. //depot/projects/ia64/sys/dev/sio/sio.c#33 edit

Differences ...

==== //depot/projects/ia64/sys/dev/sio/sio.c#33 (text+ko) ====

@@ -73,6 +73,7 @@
 
 #include <machine/limits.h>
 #include <machine/resource.h>
+#include <machine/stdarg.h>
 
 #include <dev/sio/sioreg.h>
 #include <dev/sio/siovar.h>
@@ -264,6 +265,25 @@
 	    0, 0, sysctl_machdep_comdefaultrate, "I", "");
 /* TUNABLE_INT("machdep.conspeed", &comdefaultrate); */
 
+#ifdef SIO_DEBUG
+static void
+siodebug(struct com_s *com, const char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
+	if (com != NULL)
+		device_print_prettyname(com->dev);
+	vprintf(fmt, ap);
+	va_end(ap);
+}
+#else
+static __inline void
+siodebug(struct com_s *com, const char *fmt, ...)
+{
+}
+#endif
+
 /*
  * Flush the UART. Flush the transmitter FIFO and shift register first, then
  * flush the receiver FIFO. In this order flushing works correctly even when
@@ -285,7 +305,7 @@
 	while ((sio_getreg(com, com_lsr) & LSR_TEMT) == 0 && --limit)
 		DELAY(delay);
 	if (limit == 0) {
-		printf("transmitter appears stuck... ");
+		siodebug(NULL, "transmitter appears stuck... ");
 		return (EIO);
 	}
 
@@ -303,7 +323,7 @@
 		DELAY(5*delay);
 	}
 	if (limit == 0) {
-		printf("receiver appears broken... ");
+		siodebug(NULL, "receiver appears broken... ");
 		return (EIO);
 	}
 
@@ -342,7 +362,7 @@
 			DELAY(delay);
 	}
 	if (limit == 0) {
-		printf("transmitter appears stuck");
+		siodebug(NULL, "transmitter appears stuck");
 		return (EIO);
 	}
 
@@ -369,7 +389,7 @@
 	if (!com->hasfifo) {
 		sio_setreg(com, com_mcr, com->reg_mcr);
 		/* XXX barrier */
-		printf("no FIFOs... ");
+		siodebug(NULL, "no FIFOs... ");
 		return (0);
 	}
 
@@ -406,7 +426,7 @@
 			/* XXX barrier */
 			sio_setreg(com, com_mcr, com->reg_mcr);
 			/* XXX barrier */
-			printf("can't determine FIFO size... ");
+			siodebug(NULL, "can't determine FIFO size... ");
 			goto fallback;
 		}
 	}
@@ -433,11 +453,11 @@
 	else
 		com->fifosize = 1;		/* XXX */
 
-	printf("count=%d; FIFO=%d... ", count, com->fifosize);
+	siodebug(NULL, "count=%d; FIFO=%d... ", count, com->fifosize);
 	return (0);
 
 fallback:
-	printf("disabling FIFOs... ");
+	siodebug(NULL, "disabling FIFOs... ");
 	com->hasfifo = 0;
 	return (0);
 }
@@ -607,8 +627,6 @@
 	int		error;
 	u_int		flags;
 
-	device_printf(dev, "probing... ");
-
 	while (sio_inited != 2)
 		if (atomic_cmpset_int(&sio_inited, 0, 1)) {
 			mtx_init(&sio_lock, sio_driver_name, NULL,
@@ -638,6 +656,8 @@
 
 	com->dev = dev;
 
+	siodebug(com, "probing... ");
+
 	/*
 	 * Perform rudimentary sanity checking and specific initialization
 	 * for non-console devices. We expect that the console device has
@@ -647,7 +667,7 @@
 	if (com->consdev == NULL) {
 		error = sioprobe1(com);
 		if (error) {
-			printf("sanity check failed\n");
+			siodebug(NULL, "sanity check failed\n");
 			bus_release_resource(dev, com->addr_type,
 			    com->addr_rid, com->addr_res);
 			return (error);
@@ -673,13 +693,13 @@
 	/* Initialize the FIFOs. */
 	error = sioinitfifo(com);
 	if (error) {
-		printf("failed\n");
+		siodebug(NULL, "failed\n");
 		bus_release_resource(dev, com->addr_type, com->addr_rid,
 		    com->addr_res);
 		return (error);
 	}
 
-	printf("ok\n");
+	siodebug(NULL, "ok\n");
 
 	if (device_get_desc(dev) == NULL)
 		siodescribe(com);

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe p4-projects" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200212302330.gBUNUjVn009139>