diff options
author | Johan Hovold <johan@hovoldconsulting.com> | 2015-11-21 10:52:03 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@google.com> | 2015-11-21 17:15:35 -0800 |
commit | 700001af960af35e57b701e57bd1595404dca613 (patch) | |
tree | 5bf65721fb67cf56cf1f1bac4ed75d8508e9fb9d /drivers/staging/greybus/core.c | |
parent | greybus: fix vendor and product matching (diff) | |
download | linux-dev-700001af960af35e57b701e57bd1595404dca613.tar.xz linux-dev-700001af960af35e57b701e57bd1595404dca613.zip |
greybus: move id-matching back to core
Move id-matching back to core and the bus code where it belongs.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/core.c')
-rw-r--r-- | drivers/staging/greybus/core.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/drivers/staging/greybus/core.c b/drivers/staging/greybus/core.c index 4396f90e65d6..56250fa37708 100644 --- a/drivers/staging/greybus/core.c +++ b/drivers/staging/greybus/core.c @@ -29,13 +29,46 @@ int greybus_disabled(void) } EXPORT_SYMBOL_GPL(greybus_disabled); +static int greybus_match_one_id(struct gb_bundle *bundle, + const struct greybus_bundle_id *id) +{ + if ((id->match_flags & GREYBUS_ID_MATCH_VENDOR) && + (id->vendor != bundle->intf->vendor)) + return 0; + + if ((id->match_flags & GREYBUS_ID_MATCH_PRODUCT) && + (id->product != bundle->intf->product)) + return 0; + + if ((id->match_flags & GREYBUS_ID_MATCH_CLASS) && + (id->class != bundle->class)) + return 0; + + return 1; +} + +static const struct greybus_bundle_id * +greybus_match_id(struct gb_bundle *bundle, const struct greybus_bundle_id *id) +{ + if (id == NULL) + return NULL; + + for (; id->vendor || id->product || id->class || id->driver_info; + id++) { + if (greybus_match_one_id(bundle, id)) + return id; + } + + return NULL; +} + static int greybus_module_match(struct device *dev, struct device_driver *drv) { struct greybus_driver *driver = to_greybus_driver(drv); struct gb_bundle *bundle = to_gb_bundle(dev); const struct greybus_bundle_id *id; - id = gb_bundle_match_id(bundle, driver->id_table); + id = greybus_match_id(bundle, driver->id_table); if (id) return 1; /* FIXME - Dynamic ids? */ @@ -97,7 +130,7 @@ static int greybus_probe(struct device *dev) int retval; /* match id */ - id = gb_bundle_match_id(bundle, driver->id_table); + id = greybus_match_id(bundle, driver->id_table); if (!id) return -ENODEV; |