Subject: Re: DVACT_ACTIVATE/DVACT_DEACTIVATE: proper use of EOPNOTSUPP
To: None <tech-kern@netbsd.org>
From: Iain Hibbert <plunky@rya-online.net>
List: tech-kern
Date: 10/16/2007 11:05:12
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, 1 Oct 2007, Iain Hibbert wrote:

> On Mon, 24 Sep 2007, Blair Sadewitz wrote:
> > While reading the OpenBSD commit log for
> > sys/dev/pci/azalia.c, I noticed this:
> >
> >  In a drivers activate() entry point, if on
> >  DVACT_DEACTIVATE it does something, then it MUST
> >  return zero on DVACT_ACTIVATE, not EOPNOTSUPP;
> >  this very popular bug has been cut and pasted a
> >  lot of times...
> >
> > Does NetBSD follow the same convention?
>
> looking at subr_autoconf.c, it would seem that we do since the deactivate
> call is not made unless the device is marked active, which it is not when
> DVACT_ACTIVATE returns an error.
>
> seems that this bug is popular here too..

following on from this, it appears that most of the DVACT_DEACTIVATE code
we have in our tree will never be run. I was inclined to fix this as Blair
is busy on other tasks, but he says that he was advised that perhaps
foo_activate() is the wrong way to go about this and it should be
redesigned.  I agree but I'm not going to go that far, is anybody else
working on this?  (I'm thinking jmcneill-pm branch?)

If nobody is working on that I'm happy to fix it in the meantime (as per
example below), but I don't want to duplicate effort or cause more work,
so please speak up if you have opinions..

regards,
iain

- --- /usr/src/sys/dev/pcmcia/if_cnw.c	2007-09-05 22:23:37.000000000 +0100
+++ if_cnw.c	2007-10-16 11:01:26.000000000 +0100
@@ -1203,12 +1203,15 @@
 	s = splnet();
 	switch (act) {
 	case DVACT_ACTIVATE:
- -		rv = EOPNOTSUPP;
 		break;

 	case DVACT_DEACTIVATE:
 		if_deactivate(&sc->sc_ethercom.ec_if);
 		break;
+
+	default:
+		rv = EOPNOTSUPP;
+		break;
 	}
 	splx(s);
 	return (rv);
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (NetBSD)

iQEVAwUBRxSM2PFJxoMWDXVDAQJ84gf/d/SN5bK/En7nv/Yb+LvrlE4UZx8Uqg2V
sWCaLcZptGtY/SxCYGAgIgRGl/eHkxT8BMZ+OmVejuwZCPQELSm6jrD4Gi7zjUdG
ix/J3/HwHaGvAroizbOvtqMxtQhK5CCRbl9IUA7T41PErqslQIKY80+6jpmLImJI
10EsX39pV6XFdOUFEFdhbA99bb+fzhxXTk3W7Zci7QMFYI4TSQCeDvXUc/2pVXL2
wUiqSWBKFK5LMTsywBd+nDe0XogYoZVspujH+etltBeI2O8tF9hJJCTS1p1Ohzwa
8Uhk3H+3ZF1/a/+mJkVxtDCJNZ3s+86rHHxq2AcWycvzWAcNKRNUfQ==
=AjlF
-----END PGP SIGNATURE-----