Module Name:    src
Committed By:   riastradh
Date:           Fri Jun 27 22:27:16 UTC 2014

Modified Files:
        src/sys/dev/pci: agp_i810.c

Log Message:
Collect `#ifdef AGP_DEBUG printf(...)' into local DPRINTF macro.


To generate a diff of this commit:
cvs rdiff -u -r1.105 -r1.106 src/sys/dev/pci/agp_i810.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/agp_i810.c
diff -u src/sys/dev/pci/agp_i810.c:1.105 src/sys/dev/pci/agp_i810.c:1.106
--- src/sys/dev/pci/agp_i810.c:1.105	Wed Jun 25 15:04:53 2014
+++ src/sys/dev/pci/agp_i810.c	Fri Jun 27 22:27:16 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: agp_i810.c,v 1.105 2014/06/25 15:04:53 riastradh Exp $	*/
+/*	$NetBSD: agp_i810.c,v 1.106 2014/06/27 22:27:16 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2000 Doug Rabson
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: agp_i810.c,v 1.105 2014/06/25 15:04:53 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: agp_i810.c,v 1.106 2014/06/27 22:27:16 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -54,6 +54,13 @@ __KERNEL_RCSID(0, "$NetBSD: agp_i810.c,v
 
 #include "agp_intel.h"
 
+#ifdef AGP_DEBUG
+#define	DPRINTF(sc, fmt, ...)						      \
+	device_printf((sc)->as_dev, "%s: " fmt, __func__, ##__VA_ARGS__)
+#else
+#define	DPRINTF(sc, fmt, ...)	do {} while (0)
+#endif
+
 struct agp_softc *agp_i810_sc = NULL;
 
 #define READ1(off)	bus_space_read_1(isc->bst, isc->bsh, off)
@@ -1092,21 +1099,16 @@ agp_i810_bind_page(struct agp_softc *sc,
 	struct agp_i810_softc *isc = sc->as_chipc;
 
 	if (offset < 0 || offset >= ((isc->gtt_size/4) << AGP_PAGE_SHIFT)) {
-#ifdef AGP_DEBUG
-		printf("%s: failed"
+		DPRINTF(sc, "failed"
 		    ": offset 0x%08x, shift %d, entries %"PRIuMAX"\n",
-		    device_xname(sc->as_dev), (int)offset, AGP_PAGE_SHIFT,
+		    (int)offset, AGP_PAGE_SHIFT,
 		    (uintmax_t)isc->gtt_size/4);
-#endif
 		return EINVAL;
 	}
 
 	if (isc->chiptype != CHIP_I810) {
 		if ((offset >> AGP_PAGE_SHIFT) < isc->stolen) {
-#ifdef AGP_DEBUG
-			printf("%s: trying to bind into stolen memory\n",
-			    device_xname(sc->as_dev));
-#endif
+			DPRINTF(sc, "trying to bind into stolen memory\n");
 			return EINVAL;
 		}
 	}
@@ -1124,10 +1126,7 @@ agp_i810_unbind_page(struct agp_softc *s
 
 	if (isc->chiptype != CHIP_I810 ) {
 		if ((offset >> AGP_PAGE_SHIFT) < isc->stolen) {
-#ifdef AGP_DEBUG
-			printf("%s: trying to unbind from stolen memory\n",
-			    device_xname(sc->as_dev));
-#endif
+			DPRINTF(sc, "trying to unbind from stolen memory\n");
 			return EINVAL;
 		}
 	}
@@ -1161,9 +1160,7 @@ agp_i810_alloc_memory(struct agp_softc *
 	struct agp_memory *mem;
 	int error;
 
-#ifdef AGP_DEBUG
-	printf("AGP: alloc(%d, 0x%x)\n", type, (int) size);
-#endif
+	DPRINTF(sc, "AGP: alloc(%d, 0x%x)\n", type, (int)size);
 
 	if (size <= 0)
 		return NULL;

Reply via email to