Date: Tue, 30 Sep 2003 14:12:12 -0700 (PDT) From: Warner Losh <imp@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 38917 for review Message-ID: <200309302112.h8ULCCLZ024391@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=38917 Change 38917 by imp@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 }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200309302112.h8ULCCLZ024391>