diff options
author | Viresh Kumar | 2015-04-01 17:02:04 +0200 |
---|---|---|
committer | Greg Kroah-Hartman | 2015-04-06 12:07:30 +0200 |
commit | 9f5f30e712430912f4cff65e97dd36f9b3bdbe4e (patch) | |
tree | d7897f0cff367818aa75602ea615b9674375a1d5 /drivers/staging/greybus/bundle.c | |
parent | greybus: drop module descriptors (diff) | |
download | kernel-qcow2-linux-9f5f30e712430912f4cff65e97dd36f9b3bdbe4e.tar.gz kernel-qcow2-linux-9f5f30e712430912f4cff65e97dd36f9b3bdbe4e.tar.xz kernel-qcow2-linux-9f5f30e712430912f4cff65e97dd36f9b3bdbe4e.zip |
greybus: driver corresponds to a bundle, not interface
A Greybus driver will bind to a bundle, not an interface. Lets follow
this rule in code.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/bundle.c')
-rw-r--r-- | drivers/staging/greybus/bundle.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/drivers/staging/greybus/bundle.c b/drivers/staging/greybus/bundle.c index 969197872484..ce7db9734dad 100644 --- a/drivers/staging/greybus/bundle.c +++ b/drivers/staging/greybus/bundle.c @@ -22,8 +22,18 @@ static ssize_t device_id_show(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR_RO(device_id); +static ssize_t class_type_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct gb_bundle *bundle = to_gb_bundle(dev); + + return sprintf(buf, "%d\n", bundle->class_type); +} +static DEVICE_ATTR_RO(class_type); + static struct attribute *bundle_attrs[] = { &dev_attr_device_id.attr, + &dev_attr_class_type.attr, NULL, }; @@ -41,6 +51,44 @@ struct device_type greybus_bundle_type = { .release = gb_bundle_release, }; +static int gb_bundle_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_SERIAL) && + (id->unique_id != bundle->intf->unique_id)) + return 0; + + if ((id->match_flags & GREYBUS_ID_MATCH_CLASS_TYPE) && + (id->class_type != bundle->class_type)) + return 0; + + return 1; +} + +const struct greybus_bundle_id * +gb_bundle_match_id(struct gb_bundle *bundle, + const struct greybus_bundle_id *id) +{ + if (id == NULL) + return NULL; + + for (; id->vendor || id->product || id->unique_id || id->class_type || + id->driver_info; id++) { + if (gb_bundle_match_one_id(bundle, id)) + return id; + } + + return NULL; +} + /* XXX This could be per-host device or per-module */ static DEFINE_SPINLOCK(gb_bundles_lock); |