diff options
author | Greg Kroah-Hartman <greg@kroah.com> | 2014-12-23 15:16:53 -0800 |
---|---|---|
committer | Greg Kroah-Hartman <greg@kroah.com> | 2014-12-23 21:04:02 -0800 |
commit | fb69cb506c16d38de2c3b62ea4cf6e8728bd4348 (patch) | |
tree | c7e86e2980862d4a235320ad34af7dbb8960f618 /drivers/staging/greybus/bundle.c | |
parent | df469a942301c9bf4d939e1139c1a435079b288a (diff) |
greybus: protocol: split binding of prototcols to connections out of init
When adding a new protocol to the system, walk all bundles and try to
hook up any connections that do not have a protocol already. This sets
the stage to allow for protocols to be loaded at any time, not just
before the device is seen in the system.
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Diffstat (limited to 'drivers/staging/greybus/bundle.c')
-rw-r--r-- | drivers/staging/greybus/bundle.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/staging/greybus/bundle.c b/drivers/staging/greybus/bundle.c index 28a82229adeb..973ea39dc407 100644 --- a/drivers/staging/greybus/bundle.c +++ b/drivers/staging/greybus/bundle.c @@ -45,6 +45,36 @@ struct device_type greybus_bundle_type = { /* XXX This could be per-host device or per-module */ static DEFINE_SPINLOCK(gb_bundles_lock); +static int __bundle_bind_protocols(struct device *dev, void *data) +{ + struct gb_bundle *bundle; + struct gb_connection *connection; + + if (!is_gb_bundle(dev)) + return 0; + + bundle = to_gb_bundle(dev); + + list_for_each_entry(connection, &bundle->connections, bundle_links) { + gb_connection_bind_protocol(connection); + } + + return 0; +} + +/* + * Walk all bundles in the system, and see if any connections are not bound to a + * specific prototcol. If they are not, then try to find one for it and bind it + * to it. + * + * This is called after registering a new protocol. + */ +void gb_bundle_bind_protocols(void) +{ + bus_for_each_dev(&greybus_bus_type, NULL, NULL, + __bundle_bind_protocols); +} + /* * Create a gb_bundle structure to represent a discovered * bundle. Returns a pointer to the new bundle or a null |