From: Takashi Iwai Subject: Re: Driver model ISA bus Date: Tue, 02 May 2006 14:05:47 +0200 Message-ID: References: <4455421E.1050104@keyaccess.nl> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Return-path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by alsa.jcu.cz (ALSA's E-mail Delivery System) with ESMTP id 05AA711D for ; Tue, 2 May 2006 14:06:19 +0200 (MEST) In-Reply-To: <4455421E.1050104@keyaccess.nl> Sender: alsa-devel-admin@lists.sourceforge.net Errors-To: alsa-devel-admin@lists.sourceforge.net List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , List-Archive: To: Rene Herman Cc: Russell King , ALSA devel List-Id: alsa-devel@alsa-project.org At Mon, 01 May 2006 01:02:54 +0200, Rene Herman wrote: > > Hi Takashi. > > During the recent discussion about ISA and platform devices I suggested > a seperate ISA bus instead of the platform bus for ISA devices due to > platform devices not providing the driver a chance to fail registration. > Russel King suggested using the ".match" bus method with this bus and > this indeed works fine -- .match is supposed to verify whether or not a > given driver supports a given device, meaning that it's a perfect > opportunity for an ISA driver to say "no, we don't support this > non-existant device" after failing a probe if it wants to. > > Unlike the platform bus therefore this isa bus also distributes the > .match method up to the driver same as the other methods (probe, remove, > shutdown, suspend, resume). probe() works as before with platform > devices, but a non-match makes the device fail the registration. > > Since with these ISA devices the devices also only exist by virtue of > the driver itself creating them because it might want to drive them, > actual device creation is also internal. The usage model is now very > nicely minimal: > > static struct isa_driver snd_foo_isa_driver = { > .nr_devices = SNDRV_CARDS, > > .match = snd_foo_match, > .probe = snd_foo_probe, > .remove = __devexit_p(snd_foo_remove), > .shutdown = snd_foo_shutdown, > .suspend = snd_foo_suspend, > .resume = snd_foo_resume, > > .driver = { > .name = DEV_NAME > } > }; > > static int __init alsa_card_foo_init(void) > { > return isa_register_driver(&snd_foo_driver); > } > > static void __exit alsa_card_foo_exit(void) > { > isa_unregister_driver(&snd_foo_isa_driver); > } > > This gives all options -- if we want to keep existing behaviour of a > non-loading driver if no devices are found, we can just move the > existing platform probe() methods to the ISA match() methods, with no > aditional probe() needed. If on the other hand we want to load if a > later bind could still succeed as PCI does then we might use the match > method only for the prerequisits, with probe() further as before: > > static int __devinit snd_foo_match(struct isa_dev *isa_dev) > { > unsigned int i = isa_dev->id; > > if (!enable[i]) > return 0; > > if (port[i] == SNDRV_AUTO_PORT) > return 0; > > return 1; > } > > static int __devinit snd_foo_probe(struct isa_dev *isa_dev) > { > struct snd_card *card; > > ... > > isa_set_drvdata(dev, card); > return 0; > } > > static int __devexit snd_foo_remove(struct isa_dev *isa_dev) > { > snd_card_free(isa_get_drvdata(isa_dev)); > isa_set_drvdata(isa_dev, NULL); > return 0; > } > > Would you like this as a setup / model? Yep, I like this implementation. It's pretty straightforward. > I also briefly looked into integrating this with PnP but this does not > seem to be a good match. The pnp_protocol {get,set}_resources() methods > would need to callback into drivers same as with this ISA bus match() > callback but this is at a time there might not _be_ a driver yet. This > is still that same fundamental difference of the ISA device only > existing due to a driver telling us it might. Even if there's a clean > way around that, you only end up inventing fake but valid-form PnP IDs > and generally catering to the PnP layer without any practical advantage > over this very simple isa_bus. The thing I suggested earlier (if you > read it) about the user setting up the device from userspace by echoing > values into /sys is... well, cute, but a horrible idea from a user > standpoint. Trying to force ISA into the PnP model just turns into > massive interface wankage. Agreed that it's not so easy to merge it together with pnp_driver. That's why I originally used platform_driver for ISA. Takashi ------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642