From owner-freebsd-hackers Mon Aug 6 11: 2:19 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from InterJet.elischer.org (c421509-a.pinol1.sfba.home.com [24.7.86.9]) by hub.freebsd.org (Postfix) with ESMTP id 180AC37B403; Mon, 6 Aug 2001 11:02:08 -0700 (PDT) (envelope-from julian@elischer.org) Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id NAA66198; Mon, 6 Aug 2001 13:12:12 -0700 (PDT) Date: Mon, 6 Aug 2001 13:12:11 -0700 (PDT) From: Julian Elischer To: Mike Smith Cc: Assem Salama , freebsd-hackers@freebsd.org Subject: Re: detach In-Reply-To: <200108061755.f76Ht5i01556@mass.dis.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG if you can write a little sample code I'll put it in the sample driver. On Mon, 6 Aug 2001, Mike Smith wrote: > > Hello, > > I have a question. I'm trying to make a module for a PCI card. My > > problem is my 'detach' function never get's called when I unload the > > module. Al my other functions get called correctly. Here is my source: > > Detach != unload. > > The detach method is called by your parent to kick you out. If you want > to be notified when your module is unloaded, you need a module event > handler which finds all your instances and detaches them itself. > > Use devclass_find_devices() to locate your instances, and then run across > all the detach routines. If any of them return nonzero, you should > refuse to unload. > > This is because there isn't a 1:1 correspondence between a loaded module > and a driver instance. > > > > > #define DRIVERNAME "ide_mod" > > > > #ifdef DEBUG > > #define PRINTD(STR) uprintf("%s: %s",DRIVERNAME, > > STR); > > #else > > #define PRINTD(STR) > > #endif > > > > static int ide_mod_detach(device_t dev) > > { > > PRINTD("Inside detach ... \n"); > > return 0; > > } > > > > > > static device_method_t ide_mod_methods[] = > > { > > /* device methods */ > > DEVMETHOD(device_probe, ide_mod_probe), > > DEVMETHOD(device_attach, ide_mod_attach), > > DEVMETHOD(device_detach, ide_mod_detach), > > {0, 0} > > }; > > > > static driver_t ide_mod_driver = { > > "ide_mod", > > ide_mod_methods, > > sizeof(ide_mod_softc), > > }; > > > > static devclass_t ide_mod_devclas; > > > > /* all our macros */ > > DRIVER_MODULE(ide_mod, atapci, ide_mod_driver, ide_mod_devclas, 0, 0); > > > > > > Thanks, > > Assem Salama > > > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > > with "unsubscribe freebsd-hackers" in the body of the message > > -- > ... every activity meets with opposition, everyone who acts has his > rivals and unfortunately opponents also. But not because people want > to be opponents, rather because the tasks and relationships force > people to take different points of view. [Dr. Fritz Todt] > V I C T O R Y N O T V E N G E A N C E > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message