diff options
| author | Carlos Maiolino <[email protected]> | 2025-07-10 22:55:07 +0200 |
|---|---|---|
| committer | Carlos Maiolino <[email protected]> | 2025-07-10 22:56:55 +0200 |
| commit | d98f46ce647846b0aa30b2e16a30fd4e152a1bf5 (patch) | |
| tree | 267474fcc77cf20b428f6f4c7f768ca09f4cfe0e /DeviceModel/cembus | |
| parent | 869e68986aa8f69af6e7842260a68d1e5c6f796f (diff) | |
Add new code
Signed-off-by: Carlos Maiolino <[email protected]>
Diffstat (limited to 'DeviceModel/cembus')
| -rw-r--r-- | DeviceModel/cembus/Makefile | 13 | ||||
| -rw-r--r-- | DeviceModel/cembus/cembus.c | 48 |
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); |
