Re: Platform device matching

Russell King
2004-04-25T23:27:38Z

On Mon, Apr 26, 2004 at 12:17:09AM +0100, Kenn Humborg wrote:
> On Mon, Apr 26, 2004 at 12:00:50AM +0100, Russell King wrote:
> > On Sun, Apr 25, 2004 at 11:05:11PM +0100, Kenn Humborg wrote:
> > > I'm looking at the code for binding platform devices with drivers.
> > > However, platform_match() doesn't seem to agree with its kerneldoc
> > > comment:
> >
> > The code is correct as stands. The documentation is behind times. All
> > platform devices are "<name><instance-number>" so it's correct that the
> > "floppy" driver matches "floppy0" and "floppy1" etc.
>
> Forgive me if I am being dense, but I still don't see how that works.

Sorry, I should've explained a little more.

pdev->name is the platform device name, which is just the <name> part.
pdev->dev.bus_id is the device model name, which is <name><instance-number>,
and the devices are known by this name.

Rather than going to the trouble of parsing <name> from the device model
name which would be inherently buggy, we reference it directly from the
platform_device structure.

So, this comment needs updating:

* So, extract the <name> from the device, and compare it against
* the name of the driver. Return whether they match or not.

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 PCMCIA - http://pcmcia.arm.linux.org.uk/
2.6 Serial core