diff options
author | Johan Hovold <johan@hovoldconsulting.com> | 2016-04-23 18:47:24 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@google.com> | 2016-04-25 11:08:30 -0700 |
commit | b15d97d77017dc168c74c5e9aacfe14ff74dcbe9 (patch) | |
tree | 4fe55aad777a3d5614cb4e61e0bf54a7fe63b5aa /drivers/staging/greybus/core.c | |
parent | 844fcbfeb6491d95b7e19b4705f9eb576a210536 (diff) |
greybus: core: add module abstraction
Add Greybus module abstraction that will be used to implement controlled
module removal (eject) and represent module geometry.
Greybus module devices correspond to physical modules and have one or
more interfaces. Modules have an id that is identical to the id of their
primary interface, which in turn is the interface with lowest numbered
id. The module name is constructed from the bus and module id:
<bus_id>-<module_id>
Interfaces, bundles, and control devices are consequently renamed as
<bus_id>-<module_id>.<interface_id>
<bus_id>-<module_id>.<interface_id>.<bundle_id>
<bus_id>-<module_id>.<interface_id>.ctrl
As before, interface ids (and therefore in a sense now also module ids)
correspond to physical interface positions on the frame.
Modules have the following attributes:
module_id
num_interfaces
where module_id is the id of the module and num_interface the number of
interfaces the module has.
Note that until SVC module-size detection has been implemented, all
interfaces are considered to be part of 1x2 modules. Specifically, the
two interfaces of a 2x2 module will be presented as two 1x2 modules for
now.
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 | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/staging/greybus/core.c b/drivers/staging/greybus/core.c index 9f143e5a7c9c..70a66e28471d 100644 --- a/drivers/staging/greybus/core.c +++ b/drivers/staging/greybus/core.c @@ -85,6 +85,7 @@ static int greybus_module_match(struct device *dev, struct device_driver *drv) static int greybus_uevent(struct device *dev, struct kobj_uevent_env *env) { struct gb_host_device *hd; + struct gb_module *module = NULL; struct gb_interface *intf = NULL; struct gb_control *control = NULL; struct gb_bundle *bundle = NULL; @@ -92,8 +93,12 @@ static int greybus_uevent(struct device *dev, struct kobj_uevent_env *env) if (is_gb_host_device(dev)) { hd = to_gb_host_device(dev); + } else if (is_gb_module(dev)) { + module = to_gb_module(dev); + hd = module->hd; } else if (is_gb_interface(dev)) { intf = to_gb_interface(dev); + module = intf->module; hd = intf->hd; } else if (is_gb_control(dev)) { control = to_gb_control(dev); @@ -102,6 +107,7 @@ static int greybus_uevent(struct device *dev, struct kobj_uevent_env *env) } else if (is_gb_bundle(dev)) { bundle = to_gb_bundle(dev); intf = bundle->intf; + module = intf->module; hd = intf->hd; } else if (is_gb_svc(dev)) { svc = to_gb_svc(dev); @@ -114,6 +120,11 @@ static int greybus_uevent(struct device *dev, struct kobj_uevent_env *env) if (add_uevent_var(env, "BUS=%u", hd->bus_id)) return -ENOMEM; + if (module) { + if (add_uevent_var(env, "MODULE=%u", module->module_id)) + return -ENOMEM; + } + if (intf) { if (add_uevent_var(env, "INTERFACE=%u", intf->interface_id)) return -ENOMEM; |