From owner-p4-projects@FreeBSD.ORG Tue Sep 30 14:12:14 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 51F3416A4E0; Tue, 30 Sep 2003 14:12:14 -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 2929816A4C0 for ; Tue, 30 Sep 2003 14:12:14 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6884D43FB1 for ; Tue, 30 Sep 2003 14:12:13 -0700 (PDT) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id h8ULCDXJ024394 for ; Tue, 30 Sep 2003 14:12:13 -0700 (PDT) (envelope-from imp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id h8ULCCLZ024391 for perforce@freebsd.org; Tue, 30 Sep 2003 14:12:12 -0700 (PDT) (envelope-from imp@freebsd.org) Date: Tue, 30 Sep 2003 14:12:12 -0700 (PDT) Message-Id: <200309302112.h8ULCCLZ024391@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to imp@freebsd.org using -f From: Warner Losh To: Perforce Change Reviews Subject: PERFORCE change 38917 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Sep 2003 21:12:14 -0000 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 }