summaryrefslogtreecommitdiff
path: root/DeviceModel/cembus
diff options
context:
space:
mode:
Diffstat (limited to 'DeviceModel/cembus')
-rw-r--r--DeviceModel/cembus/Makefile13
-rw-r--r--DeviceModel/cembus/cembus.c48
2 files changed, 61 insertions, 0 deletions
diff --git a/DeviceModel/cembus/Makefile b/DeviceModel/cembus/Makefile
new file mode 100644
index 0000000..2327045
--- /dev/null
+++ b/DeviceModel/cembus/Makefile
@@ -0,0 +1,13 @@
+obj-m += cembus.o
+
+ifdef LINUX_SOURCE
+ KDIR = $(LINUX_SOURCE)
+endif
+
+ KDIR ?= /lib/modules/`uname -r`/build
+
+all:
+ make -C $(KDIR) M=$(PWD) modules
+
+clean:
+ make -C $(KDIR) M=$(PWD) clean
diff --git a/DeviceModel/cembus/cembus.c b/DeviceModel/cembus/cembus.c
new file mode 100644
index 0000000..7118aeb
--- /dev/null
+++ b/DeviceModel/cembus/cembus.c
@@ -0,0 +1,48 @@
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/string.h>
+
+/* cembus bus version */
+unsigned int bversion = 1;
+
+int cembus_match(struct device *dev, struct device_driver *drv)
+{
+ printk("cembus: Checking for device and driver compatibility...\n");
+ printk("bus_id: %s - driver: %s\n", "foo", drv->name);
+ return 0;
+}
+
+
+int cembus_uevent(struct device *dev, struct kobj_uevent_env *env)
+{
+ if (add_uevent_var(env, "CEMBUS_VERSION=%u", bversion));
+ return -ENOMEM;
+ return 0;
+}
+struct bus_type cem_bus_type = {
+ .name = "cembus",
+ .match = cembus_match,
+ .uevent = cembus_uevent,
+};
+
+static int __init cembus_init(void)
+{
+ int ret = 0;
+
+ ret = bus_register(&cem_bus_type);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
+static void cembus_exit(void)
+{
+ bus_unregister(&cem_bus_type);
+}
+
+MODULE_DESCRIPTION("cem virtual bus");
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Carlos Maiolino");
+module_init(cembus_init);
+module_exit(cembus_exit);