CVS commit: src/usr.bin/make

2021-07-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jul 31 00:17:05 UTC 2021

Modified Files:
src/usr.bin/make: var.c

Log Message:
make: clean up ApplyModifier_Order

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.943 -r1.944 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.943 src/usr.bin/make/var.c:1.944
--- src/usr.bin/make/var.c:1.943	Fri Jul 30 23:35:38 2021
+++ src/usr.bin/make/var.c	Sat Jul 31 00:17:04 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.943 2021/07/30 23:35:38 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.944 2021/07/31 00:17:04 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.943 2021/07/30 23:35:38 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.944 2021/07/31 00:17:04 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -3355,32 +3355,26 @@ ApplyModifier_Order(const char **pp, Mod
 {
 	const char *mod = *pp;
 	Words words;
-	enum SortMode {
-		STR, NUM, SHUFFLE
-	} mode = STR;
-	enum SortDir {
-		ASC, DESC
-	} dir = ASC;
+	int (*cmp)(const void *, const void *) = NULL;
 
 	if (IsDelimiter(mod[1], ch) || mod[1] == '\0') {
-		mode = STR;
+		cmp = str_cmp_asc;
 		(*pp)++;
 	} else if (IsDelimiter(mod[2], ch) || mod[2] == '\0') {
 		if (mod[1] == 'n')
-			mode = NUM;
+			cmp = num_cmp_asc;
 		else if (mod[1] == 'r')
-			dir = DESC;
+			cmp = str_cmp_desc;
 		else if (mod[1] == 'x')
-			mode = SHUFFLE;
+			cmp = NULL;
 		else
 			goto bad;
 		*pp += 2;
 	} else if (IsDelimiter(mod[3], ch) || mod[3] == '\0') {
 		if ((mod[1] == 'n' && mod[2] == 'r') ||
-		(mod[1] == 'r' && mod[2] == 'n')) {
-			mode = NUM;
-			dir = DESC;
-		} else
+		(mod[1] == 'r' && mod[2] == 'n'))
+			cmp = num_cmp_desc;
+		else
 			goto bad;
 		*pp += 3;
 	} else {
@@ -3391,14 +3385,10 @@ ApplyModifier_Order(const char **pp, Mod
 		return AMR_OK;
 
 	words = Str_Words(ch->expr->value.str, false);
-	if (mode == SHUFFLE)
+	if (cmp == NULL)
 		ShuffleStrings(words.words, words.len);
-	else if (mode == NUM)
-		qsort(words.words, words.len, sizeof words.words[0],
-		dir == ASC ? num_cmp_asc : num_cmp_desc);
 	else
-		qsort(words.words, words.len, sizeof words.words[0],
-		dir == ASC ? str_cmp_asc : str_cmp_desc);
+		qsort(words.words, words.len, sizeof(words.words[0]), cmp);
 	Expr_SetValueOwn(ch->expr, Words_JoinFree(words));
 
 	return AMR_OK;



CVS commit: src/usr.bin/make

2021-07-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jul 30 23:35:38 UTC 2021

Modified Files:
src/usr.bin/make: var.c

Log Message:
make: reword comment for ApplyModifier_Order


To generate a diff of this commit:
cvs rdiff -u -r1.942 -r1.943 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.942 src/usr.bin/make/var.c:1.943
--- src/usr.bin/make/var.c:1.942	Fri Jul 30 23:28:04 2021
+++ src/usr.bin/make/var.c	Fri Jul 30 23:35:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.942 2021/07/30 23:28:04 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.943 2021/07/30 23:35:38 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.942 2021/07/30 23:28:04 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.943 2021/07/30 23:35:38 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -3343,8 +3343,12 @@ ShuffleStrings(char **strs, size_t n)
 	}
 }
 
-/* :O (order ascending) or :Or (order descending) or :Ox (shuffle) or
- * :On (numeric ascending) or :Onr or :Orn (numeric descending)
+/*
+ * :O		order ascending
+ * :Or		order descending
+ * :Ox		shuffle
+ * :On		numeric ascending
+ * :Onr, :Orn	numeric descending
  */
 static ApplyModifierResult
 ApplyModifier_Order(const char **pp, ModChain *ch)



CVS commit: src/usr.bin/make

2021-07-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jul 30 23:28:04 UTC 2021

Modified Files:
src/usr.bin/make: var.c
src/usr.bin/make/unit-tests: varmod-order-numeric.exp
varmod-order-numeric.mk

Log Message:
make: handle parse errors in ':O' uniformly

Previously, the error handling for the variable modifier ':O' differed
depending on the exact variant and in some cases led to misleading
or missing diagnostics.


To generate a diff of this commit:
cvs rdiff -u -r1.941 -r1.942 src/usr.bin/make/var.c
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-order-numeric.exp \
src/usr.bin/make/unit-tests/varmod-order-numeric.mk

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.941 src/usr.bin/make/var.c:1.942
--- src/usr.bin/make/var.c:1.941	Fri Jul 30 22:19:51 2021
+++ src/usr.bin/make/var.c	Fri Jul 30 23:28:04 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.941 2021/07/30 22:19:51 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.942 2021/07/30 23:28:04 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.941 2021/07/30 22:19:51 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.942 2021/07/30 23:28:04 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -2045,7 +2045,7 @@ typedef struct Expr {
  *	  Chain 2 ends at the ':' between ${IND1} and ${IND2}.
  *	  Chain 3 starts with all modifiers from ${IND2}.
  *	  Chain 3 ends at the ':' after ${IND2}.
- *	Chain 1 continues with the the 2 modifiers ':O' and ':u'.
+ *	Chain 1 continues with the 2 modifiers ':O' and ':u'.
  *	Chain 1 ends at the final '}' of the expression.
  *
  * After such a chain ends, its properties no longer have any effect.
@@ -3349,31 +3349,39 @@ ShuffleStrings(char **strs, size_t n)
 static ApplyModifierResult
 ApplyModifier_Order(const char **pp, ModChain *ch)
 {
-	const char *mod = (*pp)++;	/* skip past the 'O' in any case */
+	const char *mod = *pp;
 	Words words;
 	enum SortMode {
-		ASC, DESC, NUM_ASC, NUM_DESC, SHUFFLE
-	} mode;
+		STR, NUM, SHUFFLE
+	} mode = STR;
+	enum SortDir {
+		ASC, DESC
+	} dir = ASC;
 
-	if (IsDelimiter(mod[1], ch)) {
-		mode = ASC;
-	} else if (mod[1] == 'n') {
-		mode = NUM_ASC;
-		(*pp)++;
-		if (!IsDelimiter(mod[2], ch)) {
-			(*pp)++;
-			if (mod[2] == 'r')
-mode = NUM_DESC;
-		}
-	} else if ((mod[1] == 'r' || mod[1] == 'x') &&
-	IsDelimiter(mod[2], ch)) {
+	if (IsDelimiter(mod[1], ch) || mod[1] == '\0') {
+		mode = STR;
 		(*pp)++;
-		mode = mod[1] == 'r' ? DESC : SHUFFLE;
-	} else if (mod[1] == 'r' && mod[2] == 'n') {
-		(*pp) += 2;
-		mode = NUM_DESC;
-	} else
-		return AMR_BAD;
+	} else if (IsDelimiter(mod[2], ch) || mod[2] == '\0') {
+		if (mod[1] == 'n')
+			mode = NUM;
+		else if (mod[1] == 'r')
+			dir = DESC;
+		else if (mod[1] == 'x')
+			mode = SHUFFLE;
+		else
+			goto bad;
+		*pp += 2;
+	} else if (IsDelimiter(mod[3], ch) || mod[3] == '\0') {
+		if ((mod[1] == 'n' && mod[2] == 'r') ||
+		(mod[1] == 'r' && mod[2] == 'n')) {
+			mode = NUM;
+			dir = DESC;
+		} else
+			goto bad;
+		*pp += 3;
+	} else {
+		goto bad;
+	}
 
 	if (!ModChain_ShouldEval(ch))
 		return AMR_OK;
@@ -3381,15 +3389,19 @@ ApplyModifier_Order(const char **pp, Mod
 	words = Str_Words(ch->expr->value.str, false);
 	if (mode == SHUFFLE)
 		ShuffleStrings(words.words, words.len);
-	else if (mode == NUM_ASC || mode == NUM_DESC)
+	else if (mode == NUM)
 		qsort(words.words, words.len, sizeof words.words[0],
-		mode == NUM_ASC ? num_cmp_asc : num_cmp_desc);
+		dir == ASC ? num_cmp_asc : num_cmp_desc);
 	else
 		qsort(words.words, words.len, sizeof words.words[0],
-		mode == ASC ? str_cmp_asc : str_cmp_desc);
+		dir == ASC ? str_cmp_asc : str_cmp_desc);
 	Expr_SetValueOwn(ch->expr, Words_JoinFree(words));
 
 	return AMR_OK;
+
+bad:
+	(*pp)++;
+	return AMR_BAD;
 }
 
 /* :? then : else */

Index: src/usr.bin/make/unit-tests/varmod-order-numeric.exp
diff -u src/usr.bin/make/unit-tests/varmod-order-numeric.exp:1.2 src/usr.bin/make/unit-tests/varmod-order-numeric.exp:1.3
--- src/usr.bin/make/unit-tests/varmod-order-numeric.exp:1.2	Fri Jul 30 22:16:09 2021
+++ src/usr.bin/make/unit-tests/varmod-order-numeric.exp	Fri Jul 30 23:28:04 2021
@@ -1,16 +1,20 @@
 make: Bad modifier ":Oxn" for variable "NUMBERS"
 make: "varmod-order-numeric.mk" line 32: Malformed conditional (${NUMBERS:Oxn})
-make: Bad modifier ":typo" for variable "NUMBERS"
-make: "varmod-order-numeric.mk" line 45: Malformed conditional (${NUMBERS:On_typo})
-make: "varmod-order-numeric.mk" line 54: Unknown modifier "_typo"
-make: "varmod-order-numeric.mk" line 54: Malformed conditional (${NUMBERS:Onr_typo})
-make: "varmod-order-numeric.mk" line 63: Unknown modifier "_typo"
-make: "varmod-order-numeric.mk"

CVS commit: src/usr.bin/make

2021-07-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jul 30 22:19:51 UTC 2021

Modified Files:
src/usr.bin/make: var.c

Log Message:
make: merge duplicate code for sorting strings and numbers

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.940 -r1.941 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.940 src/usr.bin/make/var.c:1.941
--- src/usr.bin/make/var.c:1.940	Fri Jul 30 22:16:09 2021
+++ src/usr.bin/make/var.c	Fri Jul 30 22:19:51 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.940 2021/07/30 22:16:09 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.941 2021/07/30 22:19:51 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.940 2021/07/30 22:16:09 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.941 2021/07/30 22:19:51 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -3315,11 +3315,7 @@ num_cmp_asc(const void *sa, const void *
 static int
 num_cmp_desc(const void *sa, const void *sb)
 {
-	NUM_TYPE a, b;
-
-	a = num_val(*(const char *const *)sa);
-	b = num_val(*(const char *const *)sb);
-	return (a > b) ? -1 : (b > a) ? 1 : 0;
+	return num_cmp_asc(sb, sa);
 }
 
 static int
@@ -3331,7 +3327,7 @@ str_cmp_asc(const void *a, const void *b
 static int
 str_cmp_desc(const void *a, const void *b)
 {
-	return strcmp(*(const char *const *)b, *(const char *const *)a);
+	return str_cmp_asc(b, a);
 }
 
 static void



CVS commit: src/usr.bin/make

2021-07-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jul 30 22:16:09 UTC 2021

Modified Files:
src/usr.bin/make: make.1 var.c
src/usr.bin/make/unit-tests: varmod-order-numeric.exp
varmod-order-numeric.mk

Log Message:
make: fix typo in manual page, add more tests for the new ':On'


To generate a diff of this commit:
cvs rdiff -u -r1.297 -r1.298 src/usr.bin/make/make.1
cvs rdiff -u -r1.939 -r1.940 src/usr.bin/make/var.c
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/varmod-order-numeric.exp \
src/usr.bin/make/unit-tests/varmod-order-numeric.mk

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

Modified files:

Index: src/usr.bin/make/make.1
diff -u src/usr.bin/make/make.1:1.297 src/usr.bin/make/make.1:1.298
--- src/usr.bin/make/make.1:1.297	Fri Jul 30 19:55:22 2021
+++ src/usr.bin/make/make.1	Fri Jul 30 22:16:09 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: make.1,v 1.297 2021/07/30 19:55:22 sjg Exp $
+.\"	$NetBSD: make.1,v 1.298 2021/07/30 22:16:09 rillig Exp $
 .\"
 .\" Copyright (c) 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"	from: @(#)make.1	8.4 (Berkeley) 3/19/94
 .\"
-.Dd July 30, 2020
+.Dd July 30, 2021
 .Dt MAKE 1
 .Os
 .Sh NAME

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.939 src/usr.bin/make/var.c:1.940
--- src/usr.bin/make/var.c:1.939	Fri Jul 30 19:55:22 2021
+++ src/usr.bin/make/var.c	Fri Jul 30 22:16:09 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.939 2021/07/30 19:55:22 sjg Exp $	*/
+/*	$NetBSD: var.c,v 1.940 2021/07/30 22:16:09 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.939 2021/07/30 19:55:22 sjg Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.940 2021/07/30 22:16:09 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -3311,7 +3311,7 @@ num_cmp_asc(const void *sa, const void *
 	b = num_val(*(const char *const *)sb);
 	return (a > b) ? 1 : (b > a) ? -1 : 0;
 }
-
+
 static int
 num_cmp_desc(const void *sa, const void *sb)
 {
@@ -3321,7 +3321,7 @@ num_cmp_desc(const void *sa, const void 
 	b = num_val(*(const char *const *)sb);
 	return (a > b) ? -1 : (b > a) ? 1 : 0;
 }
-
+
 static int
 str_cmp_asc(const void *a, const void *b)
 {

Index: src/usr.bin/make/unit-tests/varmod-order-numeric.exp
diff -u src/usr.bin/make/unit-tests/varmod-order-numeric.exp:1.1 src/usr.bin/make/unit-tests/varmod-order-numeric.exp:1.2
--- src/usr.bin/make/unit-tests/varmod-order-numeric.exp:1.1	Fri Jul 30 19:55:22 2021
+++ src/usr.bin/make/unit-tests/varmod-order-numeric.exp	Fri Jul 30 22:16:09 2021
@@ -1 +1,16 @@
-exit status 0
+make: Bad modifier ":Oxn" for variable "NUMBERS"
+make: "varmod-order-numeric.mk" line 32: Malformed conditional (${NUMBERS:Oxn})
+make: Bad modifier ":typo" for variable "NUMBERS"
+make: "varmod-order-numeric.mk" line 45: Malformed conditional (${NUMBERS:On_typo})
+make: "varmod-order-numeric.mk" line 54: Unknown modifier "_typo"
+make: "varmod-order-numeric.mk" line 54: Malformed conditional (${NUMBERS:Onr_typo})
+make: "varmod-order-numeric.mk" line 63: Unknown modifier "_typo"
+make: "varmod-order-numeric.mk" line 63: Malformed conditional (${NUMBERS:Orn_typo})
+make: "varmod-order-numeric.mk" line 75: Missing argument for ".error"
+make: "varmod-order-numeric.mk" line 83: Unknown modifier "r"
+make: "varmod-order-numeric.mk" line 83: Malformed conditional (${NUMBERS:Onrr})
+make: Bad modifier ":Orrn" for variable "NUMBERS"
+make: "varmod-order-numeric.mk" line 94: Malformed conditional (${NUMBERS:Orrn})
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1
Index: src/usr.bin/make/unit-tests/varmod-order-numeric.mk
diff -u src/usr.bin/make/unit-tests/varmod-order-numeric.mk:1.1 src/usr.bin/make/unit-tests/varmod-order-numeric.mk:1.2
--- src/usr.bin/make/unit-tests/varmod-order-numeric.mk:1.1	Fri Jul 30 19:55:22 2021
+++ src/usr.bin/make/unit-tests/varmod-order-numeric.mk	Fri Jul 30 22:16:09 2021
@@ -1,18 +1,100 @@
-# $NetBSD: varmod-order-numeric.mk,v 1.1 2021/07/30 19:55:22 sjg Exp $
+# $NetBSD: varmod-order-numeric.mk,v 1.2 2021/07/30 22:16:09 rillig Exp $
 #
 # Tests for the :On variable modifier, which returns the words, sorted in
 # ascending numeric order.
 
-NUMBERS=	3 5 7 1 42 -42 1M 1k
+# This list contains only 32-bit numbers since the make code needs to conform
+# to C90, which does not provide integer types larger than 32 bit.  It uses
+# 'long long' by default, but that type is overridable if necessary.
+# To get 53-bit integers even in C90, it would be possible to switch to
+# 'double' instead, but that would allow floating-point numbers as well, which
+# is out of scope for this variable modifier.
+NUMBERS=	3 5 7 1 42 -42 5K -3m 1M 1k -2G
 
-.if ${NUMBERS:On} != "-42 1

CVS commit: src/sys/arch/macppc/dev

2021-07-30 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Jul 30 22:07:14 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: fancontrol.c fancontrolvar.h fcu.c

Log Message:
make thermal zone parameters configurable by sysctl


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/macppc/dev/fancontrol.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/macppc/dev/fancontrolvar.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/macppc/dev/fcu.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/arch/macppc/dev/fancontrol.c
diff -u src/sys/arch/macppc/dev/fancontrol.c:1.2 src/sys/arch/macppc/dev/fancontrol.c:1.3
--- src/sys/arch/macppc/dev/fancontrol.c:1.2	Wed Jul 28 00:36:00 2021
+++ src/sys/arch/macppc/dev/fancontrol.c	Fri Jul 30 22:07:14 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: fancontrol.c,v 1.2 2021/07/28 00:36:00 macallan Exp $ */
+/* $NetBSD: fancontrol.c,v 1.3 2021/07/30 22:07:14 macallan Exp $ */
 
 /*-
  * Copyright (c) 2021 Michael Lorenz
@@ -27,13 +27,14 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fancontrol.c,v 1.2 2021/07/28 00:36:00 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fancontrol.c,v 1.3 2021/07/30 22:07:14 macallan Exp $");
 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -60,6 +61,10 @@ fancontrol_adjust_zone(fancontrol_zone_t
 		return -1;
 	}
 
+	if (z->Tmin < 30) z->Tmin = 30;
+	if (z->Tmin > 60) z->Tmin = 60;
+	if (z->Tmax > 95) z->Tmax = 95;
+	if (z->Tmax < (z->Tmin + 10)) z->Tmax = z->Tmin + 10;
 	temp = (temp - 27315) / 100;
 	diff = temp - z->Tmin;
 	DPRINTF("%s %d %d\n", z->name, temp, z->Tmin);
@@ -76,3 +81,39 @@ fancontrol_adjust_zone(fancontrol_zone_t
 	}
 	return 0;
 }
+
+int
+fancontrol_init_zone(fancontrol_zone_t *z, struct sysctlnode *me)
+{
+	struct sysctlnode *zone_node, *node;
+
+	if (z->nfans <= 0) return 0;
+
+	sysctl_createv(NULL, 0, NULL, (void *) &zone_node,
+	CTLFLAG_READWRITE | CTLFLAG_OWNDESC,
+	CTLTYPE_NODE, z->name, NULL,
+	NULL, 0, NULL, 0,
+	CTL_MACHDEP,
+	me->sysctl_num,
+	CTL_CREATE, CTL_EOL);
+
+	sysctl_createv(NULL, 0, NULL, (void *) &node,
+	CTLFLAG_READWRITE | CTLFLAG_OWNDESC,
+	CTLTYPE_INT, "Tmin", "minimum temperature",
+	NULL, 0, (void *)&z->Tmin, 0,
+	CTL_MACHDEP,
+	me->sysctl_num,
+	zone_node->sysctl_num,
+	CTL_CREATE, CTL_EOL);
+
+	sysctl_createv(NULL, 0, NULL, (void *) &node,
+	CTLFLAG_READWRITE | CTLFLAG_OWNDESC,
+	CTLTYPE_INT, "Tmax", "maximum temperature",
+	NULL, 0, (void *)&z->Tmax, 0,
+	CTL_MACHDEP,
+	me->sysctl_num,
+	zone_node->sysctl_num,
+	CTL_CREATE, CTL_EOL);
+
+	return 0;
+}

Index: src/sys/arch/macppc/dev/fancontrolvar.h
diff -u src/sys/arch/macppc/dev/fancontrolvar.h:1.1 src/sys/arch/macppc/dev/fancontrolvar.h:1.2
--- src/sys/arch/macppc/dev/fancontrolvar.h:1.1	Tue Jul 27 23:38:42 2021
+++ src/sys/arch/macppc/dev/fancontrolvar.h	Fri Jul 30 22:07:14 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: fancontrolvar.h,v 1.1 2021/07/27 23:38:42 macallan Exp $ */
+/* $NetBSD: fancontrolvar.h,v 1.2 2021/07/30 22:07:14 macallan Exp $ */
 
 /*-
  * Copyright (c) 2021 Michael Lorenz
@@ -48,5 +48,6 @@ typedef struct _fancontrol_zone {
 } fancontrol_zone_t; 
 
 int fancontrol_adjust_zone(fancontrol_zone_t *);
+int fancontrol_init_zone(fancontrol_zone_t *, struct sysctlnode *);
 
 #endif /* FANCONTROLVAR_H */

Index: src/sys/arch/macppc/dev/fcu.c
diff -u src/sys/arch/macppc/dev/fcu.c:1.3 src/sys/arch/macppc/dev/fcu.c:1.4
--- src/sys/arch/macppc/dev/fcu.c:1.3	Wed Jul 28 00:59:10 2021
+++ src/sys/arch/macppc/dev/fcu.c	Fri Jul 30 22:07:14 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: fcu.c,v 1.3 2021/07/28 00:59:10 macallan Exp $ */
+/* $NetBSD: fcu.c,v 1.4 2021/07/30 22:07:14 macallan Exp $ */
 
 /*-
  * Copyright (c) 2018 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.3 2021/07/28 00:59:10 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.4 2021/07/30 22:07:14 macallan Exp $");
 
 #include 
 #include 
@@ -35,6 +35,7 @@ __KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.3 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -78,8 +79,8 @@ struct fcu_softc {
 	device_t	sc_dev;
 	i2c_tag_t	sc_i2c;
 	i2c_addr_t	sc_addr;
-
-	struct sysmon_envsys *sc_sme;
+	struct sysctlnode 	*sc_sysctl_me;
+	struct sysmon_envsys	*sc_sme;
 	envsys_data_t		sc_sensors[32];
 	int			sc_nsensors;
 	fancontrol_zone_t	sc_zones[FCU_ZONE_COUNT];
@@ -132,7 +133,7 @@ fcu_attach(device_t parent, device_t sel
 {
 	struct fcu_softc *sc = device_private(self);
 	struct i2c_attach_args *ia = aux;
-	int have_eeprom1 = 1;
+	int have_eeprom1 = 1, i;
 
 	sc->sc_dev = self;
 	sc->sc_i2c = ia->ia_tag;
@@ -141,6 +142,12 @@ fcu_attach(device_t parent, device_t sel
 	aprint_naive("\n");
 	aprint_normal(": Fan Control Unit\n");
 
+	sysctl_createv(NULL, 0, NULL, (void *) &sc->sc_sysctl_me,
+	CTLFLAG_READWRITE,
+	CTLTYPE_NODE, 

CVS commit: src/distrib/sets/lists/tests

2021-07-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jul 30 21:29:01 UTC 2021

Modified Files:
src/distrib/sets/lists/tests: mi

Log Message:
tests/make: register test varmod-order-numeric


To generate a diff of this commit:
cvs rdiff -u -r1.1096 -r1.1097 src/distrib/sets/lists/tests/mi

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1096 src/distrib/sets/lists/tests/mi:1.1097
--- src/distrib/sets/lists/tests/mi:1.1096	Sun Jul 25 22:03:42 2021
+++ src/distrib/sets/lists/tests/mi	Fri Jul 30 21:29:00 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1096 2021/07/25 22:03:42 rillig Exp $
+# $NetBSD: mi,v 1.1097 2021/07/30 21:29:00 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -5809,6 +5809,8 @@
 ./usr/tests/usr.bin/make/unit-tests/varmod-match.mktests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varmod-no-match.exptests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varmod-no-match.mktests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/varmod-order-numeric.exp			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/varmod-order-numeric.mk			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varmod-order-reverse.exp			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varmod-order-reverse.mk			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varmod-order-shuffle.exp			tests-usr.bin-tests	compattestfile,atf



CVS commit: src/usr.bin/make

2021-07-30 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Fri Jul 30 19:55:22 UTC 2021

Modified Files:
src/usr.bin/make: make.1 var.c
src/usr.bin/make/unit-tests: Makefile
Added Files:
src/usr.bin/make/unit-tests: varmod-order-numeric.exp
varmod-order-numeric.mk

Log Message:
Add :On for numeric sort

Reviewed by: christos rillig


To generate a diff of this commit:
cvs rdiff -u -r1.296 -r1.297 src/usr.bin/make/make.1
cvs rdiff -u -r1.938 -r1.939 src/usr.bin/make/var.c
cvs rdiff -u -r1.280 -r1.281 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/varmod-order-numeric.exp \
src/usr.bin/make/unit-tests/varmod-order-numeric.mk

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

Modified files:

Index: src/usr.bin/make/make.1
diff -u src/usr.bin/make/make.1:1.296 src/usr.bin/make/make.1:1.297
--- src/usr.bin/make/make.1:1.296	Thu Feb  4 21:42:46 2021
+++ src/usr.bin/make/make.1	Fri Jul 30 19:55:22 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: make.1,v 1.296 2021/02/04 21:42:46 rillig Exp $
+.\"	$NetBSD: make.1,v 1.297 2021/07/30 19:55:22 sjg Exp $
 .\"
 .\" Copyright (c) 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"	from: @(#)make.1	8.4 (Berkeley) 3/19/94
 .\"
-.Dd December 22, 2020
+.Dd July 30, 2020
 .Dt MAKE 1
 .Os
 .Sh NAME
@@ -1232,8 +1232,18 @@ but selects all words which do not match
 .Ar pattern .
 .It Cm \&:O
 Orders every word in variable alphabetically.
+.It Cm \&:On
+Orders every word in variable numerically.
+A number followed by one of
+.Ql K ,
+.Ql M
+or
+.Ql G
+is multiplied by the appropriate factor.
 .It Cm \&:Or
 Orders every word in variable in reverse alphabetical order.
+.It Cm \&:Orn
+Orders every word in variable in reverse numerical order.
 .It Cm \&:Ox
 Shuffles the words in variable.
 The results will be different each time you are referring to the

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.938 src/usr.bin/make/var.c:1.939
--- src/usr.bin/make/var.c:1.938	Mon Jun 21 18:25:20 2021
+++ src/usr.bin/make/var.c	Fri Jul 30 19:55:22 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.938 2021/06/21 18:25:20 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.939 2021/07/30 19:55:22 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.938 2021/06/21 18:25:20 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.939 2021/07/30 19:55:22 sjg Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -3272,6 +3272,56 @@ bad_modifier:
 	return AMR_BAD;
 }
 
+#ifndef NUM_TYPE
+# define NUM_TYPE long long
+#endif
+
+static NUM_TYPE
+num_val(const char *s)
+{
+	NUM_TYPE val;
+	char *ep;
+
+	val = strtoll(s, &ep, 0);
+	if (ep != s) {
+		switch (*ep) {
+		case 'K':
+		case 'k':
+			val <<= 10;
+			break;
+		case 'M':
+		case 'm':
+			val <<= 20;
+			break;
+		case 'G':
+		case 'g':
+			val <<= 30;
+			break;
+		}
+	}
+	return val;
+}
+
+static int
+num_cmp_asc(const void *sa, const void *sb)
+{
+	NUM_TYPE a, b;
+
+	a = num_val(*(const char *const *)sa);
+	b = num_val(*(const char *const *)sb);
+	return (a > b) ? 1 : (b > a) ? -1 : 0;
+}
+
+static int
+num_cmp_desc(const void *sa, const void *sb)
+{
+	NUM_TYPE a, b;
+
+	a = num_val(*(const char *const *)sa);
+	b = num_val(*(const char *const *)sb);
+	return (a > b) ? -1 : (b > a) ? 1 : 0;
+}
+
 static int
 str_cmp_asc(const void *a, const void *b)
 {
@@ -3297,22 +3347,35 @@ ShuffleStrings(char **strs, size_t n)
 	}
 }
 
-/* :O (order ascending) or :Or (order descending) or :Ox (shuffle) */
+/* :O (order ascending) or :Or (order descending) or :Ox (shuffle) or
+ * :On (numeric ascending) or :Onr or :Orn (numeric descending)
+ */
 static ApplyModifierResult
 ApplyModifier_Order(const char **pp, ModChain *ch)
 {
 	const char *mod = (*pp)++;	/* skip past the 'O' in any case */
 	Words words;
 	enum SortMode {
-		ASC, DESC, SHUFFLE
+		ASC, DESC, NUM_ASC, NUM_DESC, SHUFFLE
 	} mode;
 
 	if (IsDelimiter(mod[1], ch)) {
 		mode = ASC;
+	} else if (mod[1] == 'n') {
+		mode = NUM_ASC;
+		(*pp)++;
+		if (!IsDelimiter(mod[2], ch)) {
+			(*pp)++;
+			if (mod[2] == 'r')
+mode = NUM_DESC;
+		}
 	} else if ((mod[1] == 'r' || mod[1] == 'x') &&
 	IsDelimiter(mod[2], ch)) {
 		(*pp)++;
 		mode = mod[1] == 'r' ? DESC : SHUFFLE;
+	} else if (mod[1] == 'r' && mod[2] == 'n') {
+		(*pp) += 2;
+		mode = NUM_DESC;
 	} else
 		return AMR_BAD;
 
@@ -3322,6 +3385,9 @@ ApplyModifier_Order(const char **pp, Mod
 	words = Str_Words(ch->expr->value.str, false);
 	if (mode == SHUFFLE)
 		ShuffleStrings(words.words, words.len);
+	else if (mode == NUM_ASC || mode == NUM_DESC)
+		qsort(words.words, words.len, sizeof words.words[0],
+		mode == NUM_ASC ? num_cmp_asc : num_cmp_desc);
 	else
 		qsort(words.words, words.len, sizeof words.

CVS commit: src/sys/dev

2021-07-30 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Fri Jul 30 13:44:09 UTC 2021

Modified Files:
src/sys/dev/i2c: ssdfb_i2c.c
src/sys/dev/ic: ssdfb.c ssdfbvar.h

Log Message:
ssdfb(4): remove code for dealing with non-MPSAFE attachment

spi(4) was marked MPSAFE some time ago, so we're always on an
MPSAFE parent device.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/i2c/ssdfb_i2c.c
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/ic/ssdfb.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/ic/ssdfbvar.h

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/i2c/ssdfb_i2c.c
diff -u src/sys/dev/i2c/ssdfb_i2c.c:1.9 src/sys/dev/i2c/ssdfb_i2c.c:1.10
--- src/sys/dev/i2c/ssdfb_i2c.c:1.9	Thu Jan 28 14:42:45 2021
+++ src/sys/dev/i2c/ssdfb_i2c.c	Fri Jul 30 13:44:09 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ssdfb_i2c.c,v 1.9 2021/01/28 14:42:45 thorpej Exp $ */
+/* $NetBSD: ssdfb_i2c.c,v 1.10 2021/07/30 13:44:09 tnn Exp $ */
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ssdfb_i2c.c,v 1.9 2021/01/28 14:42:45 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ssdfb_i2c.c,v 1.10 2021/07/30 13:44:09 tnn Exp $");
 
 #include 
 #include 
@@ -112,7 +112,6 @@ ssdfb_i2c_attach(device_t parent, device
 	if ((flags & SSDFB_ATTACH_FLAG_PRODUCT_MASK) == SSDFB_PRODUCT_UNKNOWN)
 		flags |= SSDFB_PRODUCT_SSD1306_GENERIC;
 
-	flags |= SSDFB_ATTACH_FLAG_MPSAFE;
 	sc->sc.sc_dev = self;
 	sc->sc_i2c_tag = ia->ia_tag;
 	sc->sc_i2c_addr = ia->ia_addr;

Index: src/sys/dev/ic/ssdfb.c
diff -u src/sys/dev/ic/ssdfb.c:1.13 src/sys/dev/ic/ssdfb.c:1.14
--- src/sys/dev/ic/ssdfb.c:1.13	Sat Apr 24 23:36:55 2021
+++ src/sys/dev/ic/ssdfb.c	Fri Jul 30 13:44:09 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ssdfb.c,v 1.13 2021/04/24 23:36:55 thorpej Exp $ */
+/* $NetBSD: ssdfb.c,v 1.14 2021/07/30 13:44:09 tnn Exp $ */
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ssdfb.c,v 1.13 2021/04/24 23:36:55 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ssdfb.c,v 1.14 2021/07/30 13:44:09 tnn Exp $");
 
 #include "opt_ddb.h"
 
@@ -227,7 +227,6 @@ ssdfb_attach(struct ssdfb_softc *sc, int
 	int error = 0;
 	long defattr;
 	const struct ssdfb_product *p;
-	int kt_flags;
 
 	p = ssdfb_lookup_product(flags & SSDFB_ATTACH_FLAG_PRODUCT_MASK);
 	if (p == NULL) {
@@ -332,15 +331,11 @@ ssdfb_attach(struct ssdfb_softc *sc, int
 	if (sc->sc_is_console)
 		ssdfb_set_usepoll(sc, true);
 
-	mutex_init(&sc->sc_cond_mtx, MUTEX_DEFAULT,
-	ISSET(flags, SSDFB_ATTACH_FLAG_MPSAFE) ? IPL_SCHED : IPL_BIO);
+	mutex_init(&sc->sc_cond_mtx, MUTEX_DEFAULT, IPL_SCHED);
 	cv_init(&sc->sc_cond, "ssdfb");
-	kt_flags = KTHREAD_MUSTJOIN;
-	/* XXX spi(4) is not MPSAFE yet. */
-	if (ISSET(flags, SSDFB_ATTACH_FLAG_MPSAFE))
-		kt_flags |= KTHREAD_MPSAFE;
-	error = kthread_create(PRI_SOFTCLOCK, kt_flags, NULL, ssdfb_thread, sc,
-	&sc->sc_thread, "%s", device_xname(sc->sc_dev));
+	error = kthread_create(PRI_SOFTCLOCK, KTHREAD_MUSTJOIN | KTHREAD_MPSAFE,
+	NULL, ssdfb_thread, sc,  &sc->sc_thread, "%s",
+	device_xname(sc->sc_dev));
 	if (error) {
 		cv_destroy(&sc->sc_cond);
 		mutex_destroy(&sc->sc_cond_mtx);

Index: src/sys/dev/ic/ssdfbvar.h
diff -u src/sys/dev/ic/ssdfbvar.h:1.5 src/sys/dev/ic/ssdfbvar.h:1.6
--- src/sys/dev/ic/ssdfbvar.h:1.5	Sat Nov  2 14:18:36 2019
+++ src/sys/dev/ic/ssdfbvar.h	Fri Jul 30 13:44:09 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ssdfbvar.h,v 1.5 2019/11/02 14:18:36 tnn Exp $ */
+/* $NetBSD: ssdfbvar.h,v 1.6 2021/07/30 13:44:09 tnn Exp $ */
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -36,7 +36,6 @@
 #define SSDFB_ATTACH_FLAG_UPSIDEDOWN		0x0100
 #define SSDFB_ATTACH_FLAG_INVERSE		0x0200
 #define SSDFB_ATTACH_FLAG_CONSOLE		0x0400
-#define SSDFB_ATTACH_FLAG_MPSAFE		0x0800
 
 /*
  * Fundamental commands



CVS commit: src/sys

2021-07-30 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Fri Jul 30 12:46:46 UTC 2021

Modified Files:
src/sys/arch/arm/sunxi: sunxi_platform.c
src/sys/dev/ic: com.c

Log Message:
com(4): fix FIFO for DW_APB on Allwinner A20 (got broken by com.c 1.360)

Older DesignWare UARTs do not advertise their FIFO length so we must
provide it via device properties.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/arm/sunxi/sunxi_platform.c
cvs rdiff -u -r1.363 -r1.364 src/sys/dev/ic/com.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/arch/arm/sunxi/sunxi_platform.c
diff -u src/sys/arch/arm/sunxi/sunxi_platform.c:1.43 src/sys/arch/arm/sunxi/sunxi_platform.c:1.44
--- src/sys/arch/arm/sunxi/sunxi_platform.c:1.43	Sat Apr 24 23:36:28 2021
+++ src/sys/arch/arm/sunxi/sunxi_platform.c	Fri Jul 30 12:46:46 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_platform.c,v 1.43 2021/04/24 23:36:28 thorpej Exp $ */
+/* $NetBSD: sunxi_platform.c,v 1.44 2021/07/30 12:46:46 tnn Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -31,7 +31,7 @@
 #include "opt_console.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_platform.c,v 1.43 2021/04/24 23:36:28 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_platform.c,v 1.44 2021/07/30 12:46:46 tnn Exp $");
 
 #include 
 #include 
@@ -238,6 +238,15 @@ sunxi_platform_device_register(device_t 
 			if (val)
 prop_dictionary_set_bool(prop, "nomodeset", true);
 	}
+
+	if (device_is_a(self, "com")) {
+		static const struct device_compatible_entry compat_data[] = {
+			{ .compat = "allwinner,sun7i-a20" },
+			DEVICE_COMPAT_EOL
+		};
+		if (of_compatible_match(OF_finddevice("/"), compat_data))
+			prop_dictionary_set_uint(prop, "fifolen", 64);
+	}
 }
 
 static u_int

Index: src/sys/dev/ic/com.c
diff -u src/sys/dev/ic/com.c:1.363 src/sys/dev/ic/com.c:1.364
--- src/sys/dev/ic/com.c:1.363	Thu Mar 25 05:34:49 2021
+++ src/sys/dev/ic/com.c	Fri Jul 30 12:46:46 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: com.c,v 1.363 2021/03/25 05:34:49 rin Exp $ */
+/* $NetBSD: com.c,v 1.364 2021/07/30 12:46:46 tnn Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2004, 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.363 2021/03/25 05:34:49 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.364 2021/07/30 12:46:46 tnn Exp $");
 
 #include "opt_com.h"
 #include "opt_ddb.h"
@@ -541,7 +541,8 @@ com_attach_subr(struct com_softc *sc)
 	case COM_TYPE_DW_APB:
 		cpr = bus_space_read_4(sc->sc_regs.cr_iot, sc->sc_regs.cr_ioh,
 		DW_APB_UART_CPR);
-		sc->sc_fifolen = __SHIFTOUT(cpr, UART_CPR_FIFO_MODE) * 16;
+		if (!prop_dictionary_get_uint(dict, "fifolen", &sc->sc_fifolen))
+			sc->sc_fifolen = __SHIFTOUT(cpr, UART_CPR_FIFO_MODE) * 16;
 		if (sc->sc_fifolen == 0) {
 			sc->sc_fifolen = 1;
 			fifo_msg = "DesignWare APB UART, no fifo";