On Fri, 3 Mar 2000, Julian Coleman wrote:
> 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).
Adding power-on and power-off hooks is good..
> 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?
Since the routine you're calling is in the MD part of the zs code, struct
zs_chanstate *cs is a good thing. Much better than the dev (which only has
meaning to the zs device driver). What you're wanting to do is have the
power turned on on this particular channel, not on a particular device
number. Also, it would make sense to be able to turn on and off the power
on the zs mouse and zs keyboard hooks, if you're using the ports that way
and the hardware supports it. But the main thing is that you're calling a
level where it makes sense to not be tty-centric. :-)
Oh, don't do reference counting here. The open() routine gets called each
time someone opens the device, but the close only gets called after the
last close. So if there's open open open close close close in userland,
the driver only sees open open open close.
> 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).
What happened with function pointers? They are a much cleaner way to go..
If not, I'd vote for names other than zsopen() and zsclose(). You are
really asking for power to come on or go off. :-)
Note: both mac68k and macppc can use this too. There are portables with
power control on the serial ports. :-)
Take care,
Bill