diff options
author | Alex Elder | 2014-10-16 13:35:35 +0200 |
---|---|---|
committer | Greg Kroah-Hartman | 2014-10-17 18:14:11 +0200 |
commit | 574341c67213afdc9dcb5aefb4f6fa84644438bb (patch) | |
tree | 1c9069ba64526541840f793f933a4fe860750b08 /drivers/staging/greybus/module.c | |
parent | greybus: move receive handling to operation layer (diff) | |
download | kernel-qcow2-linux-574341c67213afdc9dcb5aefb4f6fa84644438bb.tar.gz kernel-qcow2-linux-574341c67213afdc9dcb5aefb4f6fa84644438bb.tar.xz kernel-qcow2-linux-574341c67213afdc9dcb5aefb4f6fa84644438bb.zip |
greybus: add device initialization
Set up the infrastructure for initializing connections based on
their protocol.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Diffstat (limited to 'drivers/staging/greybus/module.c')
-rw-r--r-- | drivers/staging/greybus/module.c | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/drivers/staging/greybus/module.c b/drivers/staging/greybus/module.c index 1970e7b01081..699cd003e367 100644 --- a/drivers/staging/greybus/module.c +++ b/drivers/staging/greybus/module.c @@ -55,39 +55,52 @@ const struct greybus_module_id *gb_module_match_id(struct gb_module *gmod, */ struct gb_module *gb_module_create(struct greybus_host_device *hd, u8 module_id) { - struct gb_module *module; + struct gb_module *gmod; - module = kzalloc(sizeof(*module), GFP_KERNEL); - if (!module) + gmod = kzalloc(sizeof(*gmod), GFP_KERNEL); + if (!gmod) return NULL; - module->hd = hd; /* XXX refcount? */ - module->module_id = module_id; - INIT_LIST_HEAD(&module->interfaces); + gmod->hd = hd; /* XXX refcount? */ + gmod->module_id = module_id; + INIT_LIST_HEAD(&gmod->interfaces); spin_lock_irq(&gb_modules_lock); - list_add_tail(&module->links, &hd->modules); + list_add_tail(&gmod->links, &hd->modules); spin_unlock_irq(&gb_modules_lock); - return module; + return gmod; } /* * Tear down a previously set up module. */ -void gb_module_destroy(struct gb_module *module) +void gb_module_destroy(struct gb_module *gmod) { - if (WARN_ON(!module)) + if (WARN_ON(!gmod)) return; - kfree(module->product_string); - kfree(module->vendor_string); + kfree(gmod->product_string); + kfree(gmod->vendor_string); spin_lock_irq(&gb_modules_lock); - list_del(&module->links); + list_del(&gmod->links); spin_unlock_irq(&gb_modules_lock); /* kref_put(module->hd); */ - kfree(module); + kfree(gmod); +} + +void gb_module_interfaces_init(struct gb_module *gmod) +{ + struct gb_interface *interface; + int ret = 0; + + list_for_each_entry(interface, &gmod->interfaces, links) { + ret = gb_interface_connections_init(interface); + if (ret) + dev_err(gmod->hd->parent, + "module interface init error %d\n", ret); + } } |