Module Name: src
Committed By: thorpej
Date: Tue Mar 26 03:24:14 UTC 2024
Modified Files:
src/share/man/man4: ugen.4
src/sys/dev/usb: ugen.c
Log Message:
Define a "flags 1" config directive for ugenif, which is similar to ugen's,
but rather forces the ugenif to match at the *lowest* match priority rather
than the highest. This allows ugenif to claim only otherwise unclaimed
interfaces.
To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/share/man/man4/ugen.4
cvs rdiff -u -r1.175 -r1.176 src/sys/dev/usb/ugen.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/share/man/man4/ugen.4
diff -u src/share/man/man4/ugen.4:1.38 src/share/man/man4/ugen.4:1.39
--- src/share/man/man4/ugen.4:1.38 Fri Aug 28 16:07:49 2020
+++ src/share/man/man4/ugen.4 Tue Mar 26 03:24:14 2024
@@ -1,4 +1,4 @@
-.\" $NetBSD: ugen.4,v 1.38 2020/08/28 16:07:49 fcambus Exp $
+.\" $NetBSD: ugen.4,v 1.39 2024/03/26 03:24:14 thorpej Exp $
.\"
.\" Copyright (c) 1999 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd September 14, 2019
+.Dd March 25, 2024
.Dt UGEN 4
.Os
.Sh NAME
@@ -37,6 +37,7 @@
.Cd "ugen* at uhub? flags N"
.Cd "ugen* at uhub? vendor V product P flags 1"
.Cd "ugenif* at uhub? vendor V product P configuration C interface I"
+.Cd "ugenif* at uhub? vendor V product P configuration C interface I flags 1"
.Sh DESCRIPTION
The
.Nm
@@ -62,7 +63,9 @@ locators this can be used to force the
driver to be used for a certain
device.
.Pp
-The second form of attachment can be used to
+The
+.Sq ugenif
+form of attachment can be used to
.Dq steal
only one interface from some device for use by the
.Nm
@@ -74,6 +77,12 @@ as otherwise the
driver would capture all of your
.Nm usb
devices.
+If
+.Dq flags 1
+is specified, the
+.Sq ugenif
+form will match at the lowest priority, thus allowing it to match only
+otherwise unclaimed interfaces.
.Em NOTE :
You have to be extremely careful,
when using this form,
Index: src/sys/dev/usb/ugen.c
diff -u src/sys/dev/usb/ugen.c:1.175 src/sys/dev/usb/ugen.c:1.176
--- src/sys/dev/usb/ugen.c:1.175 Mon Nov 6 12:16:52 2023
+++ src/sys/dev/usb/ugen.c Tue Mar 26 03:24:14 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: ugen.c,v 1.175 2023/11/06 12:16:52 hannken Exp $ */
+/* $NetBSD: ugen.c,v 1.176 2024/03/26 03:24:14 thorpej Exp $ */
/*
* Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.175 2023/11/06 12:16:52 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.176 2024/03/26 03:24:14 thorpej Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -367,8 +367,12 @@ ugen_match(device_t parent, cfdata_t mat
static int
ugenif_match(device_t parent, cfdata_t match, void *aux)
{
- /* Assume that they knew what they configured! (see ugenif(4)) */
- return UMATCH_HIGHEST;
+ /*
+ * Like ugen(4), ugenif(4) also has an override flag. It has the
+ * opposite effect, however, causing us to match with GENERIC
+ * priority rather than HIGHEST.
+ */
+ return (match->cf_flags & 1) ? UMATCH_GENERIC : UMATCH_HIGHEST;
}
static void