diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2015-06-22 16:42:30 +0530 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@google.com> | 2015-06-23 23:17:25 -0700 |
commit | 730a2f6d1066e7771d5b85b8e9ec5ed09b153d01 (patch) | |
tree | f6dbe003e07d56b7a7a701d057a0382f9064740a /drivers/staging/greybus/manifest.c | |
parent | f18327e8ebf4738140e9b33a2de99bb8e526a269 (diff) |
greybus: control: Warn if non-control cport/bundles have control protocol/classes
It is possible that (by mistake) the manifest contains non-control
cports with their protocol set as control-protocol or non-control bundle
with their class set as control-class.
Catch such cases, WARN for them and finally ignore them.
Also WARN if the control cport doesn't have its protocol as
control-protocol and control bundle doesn't have its class as
control-class.
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/manifest.c')
-rw-r--r-- | drivers/staging/greybus/manifest.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/drivers/staging/greybus/manifest.c b/drivers/staging/greybus/manifest.c index bd5753f8c384..ce4e89c6d13e 100644 --- a/drivers/staging/greybus/manifest.c +++ b/drivers/staging/greybus/manifest.c @@ -225,12 +225,20 @@ static u32 gb_manifest_parse_cports(struct gb_bundle *bundle) if (cport_id > CPORT_ID_MAX) goto cleanup; + /* Found one. Set up its function structure */ + protocol_id = desc_cport->protocol_id; + /* Don't recreate connection for control cport */ - if (cport_id == GB_CONTROL_CPORT_ID) + if (cport_id == GB_CONTROL_CPORT_ID) { + /* This should have protocol set to control protocol*/ + WARN_ON(protocol_id != GREYBUS_PROTOCOL_CONTROL); + goto release_descriptor; + } - /* Found one. Set up its function structure */ - protocol_id = desc_cport->protocol_id; + /* Nothing else should have its protocol as control protocol */ + if (WARN_ON(protocol_id == GREYBUS_PROTOCOL_CONTROL)) + goto release_descriptor; if (!gb_connection_create(bundle, cport_id, protocol_id)) goto cleanup; @@ -277,10 +285,17 @@ static u32 gb_manifest_parse_bundles(struct gb_interface *intf) /* Don't recreate bundle for control cport */ if (desc_bundle->id == GB_CONTROL_BUNDLE_ID) { + /* This should have class set to control class */ + WARN_ON(desc_bundle->class != GREYBUS_CLASS_CONTROL); + bundle = intf->control->connection->bundle; goto parse_cports; } + /* Nothing else should have its class set to control class */ + if (WARN_ON(desc_bundle->class == GREYBUS_CLASS_CONTROL)) + goto release_descriptor; + bundle = gb_bundle_create(intf, desc_bundle->id, desc_bundle->class); if (!bundle) @@ -291,6 +306,7 @@ parse_cports: if (!gb_manifest_parse_cports(bundle)) goto cleanup; +release_descriptor: count++; /* Done with this bundle descriptor */ |