Subject: MD hooks in zsopen()/zsclose()
To: NetBSD tech-kern mailing list <tech-kern@netbsd.org>
From: Julian Coleman <J.D.Coleman@newcastle.ac.uk>
List: tech-kern
Date: 03/03/2000 14:39:00
Background: the Tadpole Sparcbook has power on/off control for the serial
ports driven by a separate device (aux2 register).  In order to be able to
power on the ports when a serial port is opened (and power them off when the
serial ports are closed), I'd like to add some MD hooks to the zsopen() and
zsclose() functions in dev/ic/z8530tty.c (see diffs).

As I'm not sure what use might be made of this in the future, I wonder what
to pass to these functions (the power on/off code doesn't need any variables
- it just needs notification of open/close to modify its reference count).
Is there something I should pass instead of dev/as well as dev?

Comments/opinion welcomed.  (I tried doing this with function pointers so
that only the MI and the sparc code needed to be modified, but the result
was fairly horrible, which is why I'd like to put in the MD hooks).

Thanks,

J

-- 
                    My other computer also runs NetBSD
                          http://www.netbsd.org/

 ---8<---------------------------- Cut here ---------------------------->8---

--- /usr/src/sys/dev/ic/z8530tty.c	Thu Nov  4 12:20:53 1999
+++ dev/ic/z8530tty.c	Fri Mar  3 14:28:06 2000
@@ -113,6 +113,7 @@
 #include <sys/syslog.h>
 
 #include <dev/ic/z8530reg.h>
+#include <dev/ic/z8530tty.h>
 #include <machine/z8530var.h>
 
 #include <dev/cons.h>
@@ -472,6 +473,8 @@
 	    p->p_ucred->cr_uid != 0)
 		return (EBUSY);
 
+	zsopen_md(dev);
+
 	s = spltty();
 
 	/*
@@ -577,6 +580,8 @@
 		zs_shutdown(zst);
 	}
 
+	zsclose_md(dev);
+
 	return (error);
 }
 
@@ -608,6 +613,8 @@
 		 */
 		zs_shutdown(zst);
 	}
+
+	zsclose_md(dev);
 
 	return (0);
 }

 ---8<---------------------------- Cut here ---------------------------->8---

	dev/ic/z8530.h :

/*
 * MD hooks for zsopen() and zsclose()
 */
void zsopen_md __P((dev_t));
void zsclose_md __P((dev_t));