summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <greg@kroah.com>2014-11-15 12:12:16 -0800
committerGreg Kroah-Hartman <greg@kroah.com>2014-11-15 12:12:16 -0800
commit0ac5a838811c5921783cd8da410b23ee673b7e55 (patch)
treed7062a4572d93cc42271ce0f96db1e0a4a05470a /drivers
parent86bf33afa3c1d52f01f9e12c2e26b730acb6bbd6 (diff)
downloadlinux-0ac5a838811c5921783cd8da410b23ee673b7e55.tar.gz
linux-0ac5a838811c5921783cd8da410b23ee673b7e55.tar.bz2
linux-0ac5a838811c5921783cd8da410b23ee673b7e55.zip
greybus: skeleton for future uevents.
Implement a skeleton for the uevent framework, to be filled in later when we figure out what type of module "matching" we want to do for things (connections, interfaces, modules, etc.) Based on a patch from Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/greybus/connection.c2
-rw-r--r--drivers/staging/greybus/core.c37
-rw-r--r--drivers/staging/greybus/greybus.h19
-rw-r--r--drivers/staging/greybus/interface.c2
-rw-r--r--drivers/staging/greybus/module.c2
5 files changed, 55 insertions, 7 deletions
diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c
index f460df4b4ec8..5927f2d979c2 100644
--- a/drivers/staging/greybus/connection.c
+++ b/drivers/staging/greybus/connection.c
@@ -135,7 +135,7 @@ static void gb_connection_release(struct device *dev)
kfree(connection);
}
-static struct device_type greybus_connection_type = {
+struct device_type greybus_connection_type = {
.name = "greybus_connection",
.release = gb_connection_release,
};
diff --git a/drivers/staging/greybus/core.c b/drivers/staging/greybus/core.c
index be190e723a23..9567324c71ec 100644
--- a/drivers/staging/greybus/core.c
+++ b/drivers/staging/greybus/core.c
@@ -45,13 +45,42 @@ 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_module *gmod = to_gb_module(dev); */
+ struct gb_module *gmod = NULL;
+ struct gb_interface *interface = NULL;
+ struct gb_connection *connection = NULL;
+
+ if (is_gb_module(dev)) {
+ gmod = to_gb_module(dev);
+ } else if (is_gb_interface(dev)) {
+ interface = to_gb_interface(dev);
+ gmod = interface->gmod;
+ } else if (is_gb_connection(dev)) {
+ connection = to_gb_connection(dev);
+ interface = connection->interface;
+ gmod = interface->gmod;
+ } else {
+ dev_WARN(dev, "uevent for unknown greybus device \"type\"!\n");
+ return -EINVAL;
+ }
- /* FIXME - add some uevents here... */
+ if (connection) {
+ // FIXME
+ // add a uevent that can "load" a connection type
+ return 0;
+ }
- /* FIXME - be sure to check the type to know how to handle modules and
- * interfaces differently */
+ if (interface) {
+ // FIXME
+ // add a uevent that can "load" a interface type
+ // This is what we need to bind a driver to so use the info
+ // in gmod here as well
+ return 0;
+ }
+ // FIXME
+ // "just" a module, be vague here, nothing binds to a module except
+ // the greybus core, so there's not much, if anything, we need to
+ // advertise.
return 0;
}
diff --git a/drivers/staging/greybus/greybus.h b/drivers/staging/greybus/greybus.h
index 284be8472148..eb5eb6080783 100644
--- a/drivers/staging/greybus/greybus.h
+++ b/drivers/staging/greybus/greybus.h
@@ -259,5 +259,24 @@ void gb_uart_device_exit(struct gb_connection *connection);
int svc_set_route_send(struct gb_interface *interface,
struct greybus_host_device *hd);
+extern struct device_type greybus_module_type;
+extern struct device_type greybus_interface_type;
+extern struct device_type greybus_connection_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;
+}
+
+static inline int is_gb_connection(const struct device *dev)
+{
+ return dev->type == &greybus_connection_type;
+}
+
#endif /* __KERNEL__ */
#endif /* __LINUX_GREYBUS_H */
diff --git a/drivers/staging/greybus/interface.c b/drivers/staging/greybus/interface.c
index 04c864f2105f..38c104fc8675 100644
--- a/drivers/staging/greybus/interface.c
+++ b/drivers/staging/greybus/interface.c
@@ -31,7 +31,7 @@ static void gb_interface_release(struct device *dev)
kfree(interface);
}
-static struct device_type greybus_interface_type = {
+struct device_type greybus_interface_type = {
.name = "greybus_interface",
.release = gb_interface_release,
};
diff --git a/drivers/staging/greybus/module.c b/drivers/staging/greybus/module.c
index 51bd5c6131ce..f432bea3c818 100644
--- a/drivers/staging/greybus/module.c
+++ b/drivers/staging/greybus/module.c
@@ -62,7 +62,7 @@ static void greybus_module_release(struct device *dev)
kfree(gmod);
}
-static struct device_type greybus_module_type = {
+struct device_type greybus_module_type = {
.name = "greybus_module",
.release = greybus_module_release,
};