/* match rpmsg channel and rpmsg driver */ static int rpmsg_dev_match(struct device *dev, struct device_driver *drv) { struct rpmsg_device *rpdev = to_rpmsg_device(dev); struct rpmsg_driver *rpdrv = to_rpmsg_driver(drv); const struct rpmsg_device_id *ids = rpdrv->id_table; unsigned int i; if (rpdev->driver_override) return !strcmp(rpdev->driver_override, drv->name); if (ids) for (i = 0; ids[i].name[0]; i++) if (rpmsg_id_match(rpdev, &ids[i])) return 1; return of_driver_match_device(dev, drv); }
static int ulpi_match(struct device *dev, struct device_driver *driver) { struct ulpi_driver *drv = to_ulpi_driver(driver); struct ulpi *ulpi = to_ulpi_dev(dev); const struct ulpi_device_id *id; /* Some ULPI devices don't have a vendor id so rely on OF match */ if (ulpi->id.vendor == 0) return of_driver_match_device(dev, driver); for (id = drv->id_table; id->vendor; id++) if (id->vendor == ulpi->id.vendor && id->product == ulpi->id.product) return 1; return 0; }
static int spmi_device_match(struct device *dev, struct device_driver *drv) { struct spmi_device *spmi_dev; struct spmi_driver *sdrv = to_spmi_driver(drv); if (dev->type == &spmi_dev_type) spmi_dev = to_spmi_device(dev); else return 0; /* Attempt an OF style match */ if (of_driver_match_device(dev, drv)) return 1; if (sdrv->id_table) return spmi_match(sdrv->id_table, spmi_dev) != NULL; if (drv->name) return strncmp(spmi_dev->name, drv->name, SPMI_NAME_SIZE) == 0; return 0; }
/** * platform_match - bind platform device to platform driver. * @dev: device. * @drv: driver. * * Platform device IDs are assumed to be encoded like this: * "<name><instance>", where <name> is a short description of the type of * device, like "pci" or "floppy", and <instance> is the enumerated * instance of the device, like '0' or '42'. Driver IDs are simply * "<name>". So, extract the <name> from the platform_device structure, * and compare it against the name of the driver. Return whether they match * or not. */ static int platform_match(struct device *dev, struct device_driver *drv) { struct platform_device *pdev = to_platform_device(dev); struct platform_driver *pdrv = to_platform_driver(drv); /* When driver_override is set, only bind to the matching driver */ if (pdev->driver_override) return !strcmp(pdev->driver_override, drv->name); /* Attempt an OF style match first */ if (of_driver_match_device(dev, drv)) return 1; /* Then try ACPI style match */ if (acpi_driver_match_device(dev, drv)) return 1; /* Then try to match against the id table */ if (pdrv->id_table) return platform_match_id(pdrv->id_table, pdev) != NULL; /* fall-back to driver name match */ return (strcmp(pdev->name, drv->name) == 0); }
static int sunxi_rsb_device_match(struct device *dev, struct device_driver *drv) { return of_driver_match_device(dev, drv); }