Module Name:    src
Committed By:   riastradh
Date:           Sun Jul 17 11:20:04 UTC 2022

Modified Files:
        src/sys/dev/wscons: wsdisplay_vcons.c

Log Message:
wsdisplay(4): Factor out use_intr tests.

Nix a lot of #ifdefs this way.  Compiler can take care of dead code
if appropriate.  No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/dev/wscons/wsdisplay_vcons.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/wscons/wsdisplay_vcons.c
diff -u src/sys/dev/wscons/wsdisplay_vcons.c:1.56 src/sys/dev/wscons/wsdisplay_vcons.c:1.57
--- src/sys/dev/wscons/wsdisplay_vcons.c:1.56	Sun Jul 17 10:28:09 2022
+++ src/sys/dev/wscons/wsdisplay_vcons.c	Sun Jul 17 11:20:04 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: wsdisplay_vcons.c,v 1.56 2022/07/17 10:28:09 riastradh Exp $ */
+/*	$NetBSD: wsdisplay_vcons.c,v 1.57 2022/07/17 11:20:04 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2005, 2006 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wsdisplay_vcons.c,v 1.56 2022/07/17 10:28:09 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsdisplay_vcons.c,v 1.57 2022/07/17 11:20:04 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -125,6 +125,16 @@ static void vcons_softintr(void *);
 static void vcons_init_thread(void *);
 #endif
 
+static inline bool
+vcons_use_intr(const struct vcons_screen *scr)
+{
+#ifdef VCONS_DRAW_INTR
+	return scr->scr_vd->use_intr;
+#else
+	return false;
+#endif
+}
+
 static int
 vcons_init_common(struct vcons_data *vd, void *cookie,
     struct wsscreen_descr *def, struct wsdisplay_accessops *ao,
@@ -898,10 +908,8 @@ vcons_copycols(void *cookie, int row, in
 
 	vcons_copycols_buffer(cookie, row, srccol, dstcol, ncols);
 
-#if defined(VCONS_DRAW_INTR)
-	if (scr->scr_vd->use_intr)
+	if (vcons_use_intr(scr))
 		return;
-#endif
 
 	vcons_lock(scr);
 	if (SCREEN_IS_VISIBLE(scr) && SCREEN_CAN_DRAW(scr)) {
@@ -1001,10 +1009,8 @@ vcons_erasecols(void *cookie, int row, i
 
 	vcons_erasecols_buffer(cookie, row, startcol, ncols, fillattr);
 
-#if defined(VCONS_DRAW_INTR)
-	if (scr->scr_vd->use_intr)
+	if (vcons_use_intr(scr))
 		return;
-#endif
 
 	vcons_lock(scr);
 	if (SCREEN_IS_VISIBLE(scr) && SCREEN_CAN_DRAW(scr)) {
@@ -1058,10 +1064,8 @@ vcons_copyrows(void *cookie, int srcrow,
 
 	vcons_copyrows_buffer(cookie, srcrow, dstrow, nrows);
 
-#if defined(VCONS_DRAW_INTR)
-	if (scr->scr_vd->use_intr)
+	if (vcons_use_intr(scr))
 		return;
-#endif
 
 	vcons_lock(scr);
 	if (SCREEN_IS_VISIBLE(scr) && SCREEN_CAN_DRAW(scr)) {
@@ -1163,10 +1167,8 @@ vcons_eraserows(void *cookie, int row, i
 
 	vcons_eraserows_buffer(cookie, row, nrows, fillattr);
 
-#if defined(VCONS_DRAW_INTR)
-	if (scr->scr_vd->use_intr)
+	if (vcons_use_intr(scr))
 		return;
-#endif
 
 	vcons_lock(scr);
 	if (SCREEN_IS_VISIBLE(scr) && SCREEN_CAN_DRAW(scr)) {
@@ -1228,10 +1230,8 @@ vcons_putchar(void *cookie, int row, int
 
 	vcons_putchar_buffer(cookie, row, col, c, attr);
 
-#if defined(VCONS_DRAW_INTR)
-	if (scr->scr_vd->use_intr)
+	if (vcons_use_intr(scr))
 		return;
-#endif
 
 	vcons_lock(scr);
 	if (SCREEN_IS_VISIBLE(scr) && SCREEN_CAN_DRAW(scr)) {
@@ -1253,19 +1253,18 @@ vcons_cursor(void *cookie, int on, int r
 	struct rasops_info *ri = cookie;
 	struct vcons_screen *scr = ri->ri_hw;
 
-
-#if defined(VCONS_DRAW_INTR)
-	if (scr->scr_vd->use_intr) {
+	if (vcons_use_intr(scr)) {
 		vcons_lock(scr);
 		if (scr->scr_ri.ri_crow != row || scr->scr_ri.ri_ccol != col) {
 			scr->scr_ri.ri_crow = row;
 			scr->scr_ri.ri_ccol = col;
+#if defined(VCONS_DRAW_INTR)
 			atomic_inc_uint(&scr->scr_dirty);
+#endif
 		}
 		vcons_unlock(scr);
 		return;
 	}
-#endif
 
 	vcons_lock(scr);
 

Reply via email to