Date: Tue, 30 Sep 2003 14:49:32 -0700 (PDT) From: Julian Elischer <julian@elischer.org> To: Warner Losh <imp@FreeBSD.org> Cc: Perforce Change Reviews <perforce@freebsd.org> Subject: Re: PERFORCE change 38917 for review Message-ID: <Pine.BSF.4.21.0309301448160.53279-100000@InterJet.elischer.org> In-Reply-To: <200309302112.h8ULCCLZ024391@repoman.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Someone who understands all this stuff should update /usr/share/examples/drivers/make_device_driver.sh On Tue, 30 Sep 2003, Warner Losh wrote: > 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?Pine.BSF.4.21.0309301448160.53279-100000>