Date: Sat, 19 Jul 1997 13:46:57 +0200 (MET DST) From: Luigi Rizzo <luigi@labinfo.iet.unipi.it> To: bde@zeta.org.au (Bruce Evans) Cc: hasty@rah.star-gate.com, bde@zeta.org.au, hackers@FreeBSD.ORG, multimedia@FreeBSD.ORG, rhh@ct.picker.com, se@FreeBSD.ORG Subject: Re: snd driver attach routine Message-ID: <199707191146.NAA18801@labinfo.iet.unipi.it> In-Reply-To: <199707190643.QAA29949@godzilla.zeta.org.au> from "Bruce Evans" at Jul 19, 97 04:43:13 pm
next in thread | previous in thread | raw e-mail | index | archive | help
> >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/
_____________________________|______________________________________
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199707191146.NAA18801>
