/* * foodev.c - simple illustration of device node creation in driverfs. * * Copyright (c) 2002 Patrick Mochel * * This is simple and stupid. We declare a platform device, register it * with the system, then create a device node for it. * The major/minor used is the char misc device, and the first free minor * (right after the mk712 touchscreen; stupid mk712). * * This is very buggy, but it's not meant to be perfect. We should check * the return of the registration and creation functions. * And, the module can be unloaded while there are still references to * the device. Oh well.. * * Also, the device has no parent or bus. Don't do that. Ever. I wrote * the API, so I'm special. ;) * * Compiled with: CFLAGS = -Wall -O2 -fomit-frame-pointer -DMODULE -D__KERNEL__ IDIR = /home/mochel/src/kernel/devel/linux-2.5/include foodev.o:: $(CC) $(CFLAGS) -I$(IDIR) -c -o $@ $< */ #include #include #include #include static struct device foodev = { .bus_id = "foo0", .name = "The Foo Device", }; static int __init foodev_init(void) { device_register(&foodev); device_create_node(&foodev,(S_IFCHR|S_IRUGO),mk_kdev(10,16)); return 0; } static void __exit foodev_exit(void) { put_device(&foodev); } module_init(foodev_init); module_exit(foodev_exit);