#include #include #include #include #include #include "platform.h" static const struct of_device_id lork_ids[] = { { .compatible = "gpio-extern" }, {}, }; struct platform_driver lork_driver = { .probe = lork_probe, .remove = lork_remove, .driver = { .name = "gpio-extern", .owner = THIS_MODULE, .of_match_table = of_match_ptr(lork_ids), } }; struct class* class; static int mod_init(void) { int err; // create /sys/class/lork class = class_create("lork"); if (IS_ERR_OR_NULL(class)) { err = PTR_ERR(class); printk(KERN_ERR "class_create error %d\n", err); goto free_class; } // create platform driver err = platform_driver_register(&lork_driver); if (err) goto return_err; printk("%s() OK\n", __PRETTY_FUNCTION__); return 0; free_class: class_destroy(class); return_err: printk("%s() -> %d\n", __PRETTY_FUNCTION__, err); return err; } static void mod_exit(void) { platform_driver_unregister(&lork_driver); class_destroy(class); printk("%s()\n", __PRETTY_FUNCTION__); } module_init(mod_init); module_exit(mod_exit); MODULE_LICENSE("Dual MIT/GPL");