Subject: Re: RICOH something cardbus adapter...
To: Ignatios Souvatzis <is@netbsd.org>
From: Jonathan Stone <jonathan@dsg.stanford.edu>
List: tech-kern
Date: 02/26/2005 16:40:50
In message <20050226163952.GB22330@beverly.kleinbus.org>,
Ignatios Souvatzis writes:

>
>I've managed to get it to work by limiting the tsleep() to hz/4, and=20
>incrementing sc->pwrcycle if it was the same. Patch at the end.

That worked for me too (though I had to apply it manually; I couldn't
get your quoted-printable patch into a form patch would accept).

But the patch isn't very clean. I can only find one call to
wakeup(sc->sc_pwrcycle), at the tail of pccbbintr(), inside
	if (sockevent & CB_SOCKET_EVENT_POWER) {

which always increments sc->sc_pwrcycle. Surely it'd be cleaner, and
simpler, to remove the

		while (pwrcycle == sc->sc_pwrcycle)

 loop altogether, and just do:

		microtime(&before);
		/*
		 * wait for powercycle to complete, but wait no more than  0.25 sec,
		 * due to bridges that that don't notify us (on which we'd otherwise
		 * wait forever).
		 */
		tsleep(&sc->sc_pwrcycle, PWAIT, "pccpwr", hz/4);
		if (pwrcycle == sc->sc_pwrcycle) {
			printf("%s: powerup timeout exceeded, assuming powered up\n",
					sc->sc_dev.dv_xname);
			++sc->sc_pwrcycle;	/* XXX */
		}

Or even check whether return value from tsleep() indicates it returned
due to wakeup() or a timeout. Or is there something I'm missing?