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>
diff --git a/drivers/staging/greybus/greybus.h b/drivers/staging/greybus/greybus.h
index 4ab5f60..f5447e7 100644
--- a/drivers/staging/greybus/greybus.h
+++ b/drivers/staging/greybus/greybus.h
@@ -28,6 +28,7 @@
 #include "hd.h"
 #include "svc.h"
 #include "control.h"
+#include "module.h"
 #include "interface.h"
 #include "bundle.h"
 #include "connection.h"
@@ -112,6 +113,7 @@
 extern struct bus_type greybus_bus_type;
 
 extern struct device_type greybus_hd_type;
+extern struct device_type greybus_module_type;
 extern struct device_type greybus_interface_type;
 extern struct device_type greybus_control_type;
 extern struct device_type greybus_bundle_type;
@@ -122,6 +124,11 @@
 	return dev->type == &greybus_hd_type;
 }
 
+static inline int is_gb_module(const struct device *dev)
+{
+	return dev->type == &greybus_module_type;
+}
+
 static inline int is_gb_interface(const struct device *dev)
 {
 	return dev->type == &greybus_interface_type;