From owner-freebsd-multimedia Sat Jul 19 05:53:47 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id FAA24531 for multimedia-outgoing; Sat, 19 Jul 1997 05:53:47 -0700 (PDT) Received: from labinfo.iet.unipi.it (labinfo.iet.unipi.it [131.114.9.5]) by hub.freebsd.org (8.8.5/8.8.5) with SMTP id FAA24521; Sat, 19 Jul 1997 05:53:39 -0700 (PDT) Received: from localhost (luigi@localhost) by labinfo.iet.unipi.it (8.6.5/8.6.5) id NAA18801; Sat, 19 Jul 1997 13:46:57 +0200 From: Luigi Rizzo Message-Id: <199707191146.NAA18801@labinfo.iet.unipi.it> Subject: Re: snd driver attach routine To: bde@zeta.org.au (Bruce Evans) Date: Sat, 19 Jul 1997 13:46:57 +0200 (MET DST) Cc: hasty@rah.star-gate.com, bde@zeta.org.au, hackers@FreeBSD.ORG, multimedia@FreeBSD.ORG, rhh@ct.picker.com, se@FreeBSD.ORG In-Reply-To: <199707190643.QAA29949@godzilla.zeta.org.au> from "Bruce Evans" at Jul 19, 97 04:43:13 pm X-Mailer: ELM [version 2.4 PL23] Content-Type: text Sender: owner-multimedia@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > >I think I get the rationale for not testing return value in the attach > >routine. > > > >After the probe you (should) know that the peripheral is there. A > >failure to attach should then depend only on os problems (typically, > >failure to allocate resources such as memory, dma, irq, or a device > >descriptor). Since no resource allocation was in the probe, the routine > >calling the attach has nothing to do on failure -- all deallocations > >should be done in the attach routine being device specific. > > In practice, for isa devices the IRQ allocation is done in generic code, > so the probe status is necessary (but not used). ^^^^^ you mean attach I guess... but in isa.c I see the following piece of code: ... isdp->id_alive = id_alive; } (*dp->attach)(isdp); if (isdp->id_irq) { if (mp) INTRMASK(*mp, isdp->id_irq); register_intr(ffs(isdp->id_irq) - 1, isdp->id_id, isdp->id_ri_flags, isdp->id_intr, mp, isdp->id_unit); INTREN(isdp->id_irq); } ... so all the necessary info is in the id_irq field of the struct isa_device -- a device which does not attach properly could just zero this field. > >Secondly, if I am not mistaken, once you create a device entry in the > >fs with a major number corresponding to an existing device, the > >routines for the devices are always invoked and they have to check the > >minor dev anyways to see if it corresponds to a configured device. > > This is a bug. Drivers whose probe or attach can fail should not use > SYSINIT() to register their device switches. it is not a bug, it is a need. A device switch (registered with SYSINIT) serves for a device _type_, but you can have several units of the same type (hence with the same major number), so you have to check the minor number anyways. Cheers Luigi -----------------------------+-------------------------------------- Luigi Rizzo | Dip. di Ingegneria dell'Informazione email: luigi@iet.unipi.it | Universita' di Pisa tel: +39-50-568533 | via Diotisalvi 2, 56126 PISA (Italy) fax: +39-50-568522 | http://www.iet.unipi.it/~luigi/ _____________________________|______________________________________