Module Name:    src
Committed By:   riastradh
Date:           Thu Apr  7 21:46:52 UTC 2022

Modified Files:
        src/sys/kern: tty.c
        src/sys/sys: tty.h

Log Message:
tty(9): New function tty_unit for struct cdevsw::d_devtounit.


To generate a diff of this commit:
cvs rdiff -u -r1.300 -r1.301 src/sys/kern/tty.c
cvs rdiff -u -r1.96 -r1.97 src/sys/sys/tty.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/kern/tty.c
diff -u src/sys/kern/tty.c:1.300 src/sys/kern/tty.c:1.301
--- src/sys/kern/tty.c:1.300	Mon Mar 28 12:39:28 2022
+++ src/sys/kern/tty.c	Thu Apr  7 21:46:51 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: tty.c,v 1.300 2022/03/28 12:39:28 riastradh Exp $	*/
+/*	$NetBSD: tty.c,v 1.301 2022/04/07 21:46:51 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2020 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.300 2022/03/28 12:39:28 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.301 2022/04/07 21:46:51 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -2901,6 +2901,18 @@ tty_free(struct tty *tp)
 }
 
 /*
+ * tty_unit: map dev_t to tty unit number, as with TTUNIT
+ *
+ * => defined as function for use with struct cdevsw::d_devtounit
+ * => not for drivers with different unit numbering, e.g. TTUNIT(d) >> 4
+ */
+int
+tty_unit(dev_t dev)
+{
+	return TTUNIT(dev);
+}
+
+/*
  * ttyprintf_nolock: send a message to a specific tty, without locking.
  *
  * => should be used only by tty driver or anything that knows the

Index: src/sys/sys/tty.h
diff -u src/sys/sys/tty.h:1.96 src/sys/sys/tty.h:1.97
--- src/sys/sys/tty.h:1.96	Mon Mar 28 12:39:28 2022
+++ src/sys/sys/tty.h	Thu Apr  7 21:46:51 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: tty.h,v 1.96 2022/03/28 12:39:28 riastradh Exp $	*/
+/*	$NetBSD: tty.h,v 1.97 2022/04/07 21:46:51 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -312,6 +312,7 @@ struct tty
 void	 tty_free(struct tty *);
 u_char	*firstc(struct clist *, int *);
 bool	 ttypull(struct tty *);
+int	 tty_unit(dev_t);
 
 int	clalloc(struct clist *, int, int);
 void	clfree(struct clist *);

Reply via email to