Messages in this thread Patch in this message | ![/](/images/icornerl.gif) | | Date | Wed, 5 Mar 2003 07:39:12 +0100 | From | Dominik Brodowski <> | Subject | [PATCH] driver model: fix platform_match [Was: Re: [PATCH] pcmcia: get initialization ordering right [Was: [PATCH 2.5] : i82365 & platform_bus_type]] |
| |
Hi Pat,
On Tue, Mar 04, 2003 at 08:35:05AM -0600, Patrick Mochel wrote: > > On Tue, 4 Mar 2003, Dominik Brodowski wrote: > > > Hi Pat, > > > > How is it supposed to work then? I thought adding a platform_device and > > platform_driver with the same name and bus_id causes the platform_driver to > > be bound to the platform_device? > > Erm yes. Color me lazy, I just hadn't implemented that yet.. You've hit > something else no one had used before. > > This patch is completley untested, but it should work. ... > + > + if (sscanf(dev->bus_id,"%s",name)) > + return (strcmp(name,drv->name) == 0);
Unfortunately, this won't work: digits are perfectly valid entries of strings. However, we have the name without the appending instance still saved in platform_device pdev->name... so what about this?
diff -ruN linux-original/drivers/base/platform.c linux/drivers/base/platform.c --- linux-original/drivers/base/platform.c 2003-03-05 07:19:19.000000000 +0100 +++ linux/drivers/base/platform.c 2003-03-05 07:22:31.000000000 +0100 @@ -59,12 +59,9 @@ static int platform_match(struct device * dev, struct device_driver * drv) { - char name[BUS_ID_SIZE]; + struct platform_device *pdev = container_of(dev, struct platform_device, dev); - if (sscanf(dev->bus_id,"%s",name)) - return (strcmp(name,drv->name) == 0); - - return 0; + return (strncmp(pdev->name, drv->name, BUS_ID_SIZE) == 0); } struct bus_type platform_bus_type = { - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| ![\](/images/icornerr.gif) |