723 struct bus_type spmi_bus_type = {724 .name = "spmi",725 .match = spmi_device_match,726 .pm = &spmi_pm_ops,727 };632 static int spmi_device_match(struct device *dev, struct device_driver *drv)633 {634 struct spmi_device *spmi_dev;635 struct spmi_driver *sdrv = to_spmi_driver(drv);636 637 if (dev->type == &spmi_dev_type)638 spmi_dev = to_spmi_device(dev);639 else640 return 0;641 642 /* Attempt an OF style match */643 if (of_driver_match_device(dev, drv))644 return 1;645 646 if (sdrv->id_table)647 return spmi_match(sdrv->id_table, spmi_dev) != NULL;648 649 if (drv->name)650 return strncmp(spmi_dev->name, drv->name, SPMI_NAME_SIZE) == 0;651 return 0;652 }653 17 /** 18 * of_driver_match_device - Tell if a driver's of_match_table matches a device. 19 * @drv: the device_driver structure to test 20 * @dev: the device structure to match against 21 */ 22 static inline int of_driver_match_device(struct device *dev, 23 const struct device_driver *drv) 24 { 25 return of_match_device(drv->of_match_table, dev) != NULL; 26 } 11 #include "of_private.h" 12 13 /** 14 * of_match_device - Tell if a struct device matches an of_device_id list 15 * @ids: array of of device match structures to search in 16 * @dev: the of device structure to match against 17 * 18 * Used by a driver to check whether an platform_device present in the 19 * system is in its list of supported devices. 20 */ 21 const struct of_device_id *of_match_device(const struct of_device_id *matches, 22 const struct device *dev) 23 { 24 if ((!matches) || (!dev->of_node)) 25 return NULL; 26 return of_match_node(matches, dev->of_node); 27 }