Date: Fri, 10 Apr 1998 11:30:19 -0700 (PDT) From: Archie Cobbs <archie@whistle.com> To: luigi@labinfo.iet.unipi.it (Luigi Rizzo) Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: PnP driver question Message-ID: <199804101830.LAA05807@bubba.whistle.com> In-Reply-To: <199804100522.HAA07607@labinfo.iet.unipi.it> from Luigi Rizzo at "Apr 10, 98 07:22:26 am"
next in thread | previous in thread | raw e-mail | index | archive | help
Luigi Rizzo writes: > > Need a little help understanding how to write a PnP aware device driver. > > > > Suppose I have a PnP card that I want to do a self-test on before > > claiming that it's been officially detected. Since the attach() routine > > in struct pnp_device returns NULL, then this has to be done in the > > probe routine, right? > > > > In order to talk to the card to do the self-test, I have to set > > the PnP params and enable the card during the probe routine... > > > > My question is.. is this safe? Is this this right way to proceed? > > > > I'm wondering because in Luigi's paper "PnP support in FreeBSD", > > the example has a very simple probe routine (which just compares the > > unqiue identifiers), while the attach routine does all the initialization > > work. > > i am not quite sure if mine is the correct way. However, after some > thinking, i took the following decisions: > - the probe routines should avoid changing the configuration of > PnP devices, since this belongs elsewhere. Pragmatically, > I do not enable anything, but allow a driver to disable resources > that the driver does not use (e.g. in the case of audio driver, all > the synth/midi stuff for which i currently have no support. > > - the probe routine, for non-pnp devices, just tries to figure out if > the device is there and it is properly configured. Since PnP tells > you all of this, there is little to be done in the probe routine, > so the only thing is to check the PnP id > > - the attach routine does all the initialization. Unfortunately > there is no check on the return code from the isa attach routine, > so you cannot report up if the attach fails... ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This is precisely the problem. Luigi Rizzo writes later on: > i am not sure if it is safe... i'd postpone all self test to the attach > routine. It can still fail by returning some value (forget which one) > in the struct isa_device set appropriately (like ports=0 or -1, etc.); > look at isa.c what is done after the attach routine. I looked at isa.c and after calling (*dp->attach)(isdp) all it does is check the interrupt value and register the interrupt handler. So there doesn't seem to be any way for "attach" to indicate failure. Here's a propsal (don't know how hard this would be to do): - Have BOTH the PnP and ISA attach routines be defined to return an int value (the ISA attach already does, but it's currently ignored). - Let device drivers' attach routines indicate failure by returning a non-zero value. Basically, since "probe" is only intended to only detect devices in a non-obtrusive way, only "attach" can be used for things like self-test, etc. Therefore, "attach" must be allowed to return non-zero to indicate failure -- in both ISA and PnP cases. If I'm misunderstanding the paradigm, please help clarify.. Thanks, -Archie ___________________________________________________________________________ Archie Cobbs * Whistle Communications, Inc. * http://www.whistle.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199804101830.LAA05807>