From owner-p4-releng@FreeBSD.ORG Tue Sep 30 18:13:34 2003 Return-Path: Delivered-To: p4-releng@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id B924716A4C0; Tue, 30 Sep 2003 18:13:33 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8E00B16A4B3; Tue, 30 Sep 2003 18:13:33 -0700 (PDT) Received: from sccrmhc11.comcast.net (sccrmhc11.comcast.net [204.127.202.55]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8C4DB43FE5; Tue, 30 Sep 2003 18:13:32 -0700 (PDT) (envelope-from julian@elischer.org) Received: from interjet.elischer.org ([12.233.125.100]) by comcast.net (sccrmhc11) with ESMTP id <2003100101133001100m0e03e>; Wed, 1 Oct 2003 01:13:31 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id OAA53443; Tue, 30 Sep 2003 14:49:33 -0700 (PDT) Date: Tue, 30 Sep 2003 14:49:32 -0700 (PDT) From: Julian Elischer To: Warner Losh In-Reply-To: <200309302112.h8ULCCLZ024391@repoman.freebsd.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: Perforce Change Reviews Subject: Re: PERFORCE change 38917 for review X-BeenThere: p4-releng@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 releng tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Oct 2003 01:13:34 -0000 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 > } >