PERFORCE change 38917 for review
Warner Losh
imp at FreeBSD.org
Tue Sep 30 14:12:14 PDT 2003
http://perforce.freebsd.org/chv.cgi?CH=38917
Change 38917 by imp at imp_koguchi on 2003/09/30 14:11:19
phk's sc = dev->si_drv1;
Start on attach()
some whitespace for clarity.
Affected files ...
.. //depot/doc/strawman-driver.c#2 edit
Differences ...
==== //depot/doc/strawman-driver.c#2 (text+ko) ====
@@ -16,6 +16,9 @@
static int
foo_ctl_ioctl(dev_t dev, u_long cmd, caddr_t data, nit flag, struct thread *td)
{
+ foo_softc *sc;
+
+ sc = dev->si_drv1;
...
case FOO_GERBIL:
/* Wait for a weird GERBIL event in the device and return it */
@@ -37,25 +40,48 @@
}
static int
+foo_attach(device_t dev)
+{
+ int unit;
+ foo_softc *sc;
+
+ sc = device_get_softc(dev);
+ unit = device_get_unit(dev);
+
+ /* allocate resoureces, initailze thigns */
+ /* xXX show how we allocate mtx, cv, irq, ih */
+
+ /* Allocate device */
+ sc->d = make_dev(devsw, 1, 0, 0, 0755, "fooctl%d", unit);
+ sc->d->si_drv1 = sc;
+}
+
+static int
foo_detach(device_t dev)
{
sc = device_get_softc(dev);
foo_disable_intr(sc); /* disable hardware intr ??? */
+
/* Everybody active here */
callout_reset(&sc->stat_ch, hz, fxp_tick, sc);
+
/* Network, ISR and devsw active */
bus_teardown_intr(sc->dev, sc->irq, sc->ih);
+
/* Network and devsw active */
ether_ifdetach(&sc->arpcom.ac_if);
sc->ih = NULL;
foo_wakeup_my_sleepers(sc);
+
/* devsw active */
destroy_dev(sc->d);
+
/* only mutex alive */
mtx_destroy(&sc->mtx);
cv_destroy(&sc->cv);
- /* release the resources */
+
+ /* release the hardware resources */
bus_release_resource(sc->dev, SYS_RES_IRQ, 0, sc->irq);
// etc
}
More information about the p4-projects
mailing list