Files
counter/driver/init.c

65 lines
1.5 KiB
C

#include <linux/module.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/spi/spi.h>
#include "ls7366r.h"
#include "trigger.h"
#include "leds.h"
#include "io.h"
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Wolfgang Hottgenroth");
MODULE_DESCRIPTION("Driver for the MainsCnt measurement hat");
/* module loading and unloading */
static int __init my_init(void) {
printk("counter - Loading IO subsystem...\n");
if (io_init()) {
printk("counter - Error! Could not load IO subsystem\n");
return -1;
}
printk("counter - Loading the leds driver...\n");
if(platform_driver_register(&leds_driver)) {
printk("counter - Error! Could not load leds driver\n");
return -1;
}
printk("counter - Loading the ls7366r driver...\n");
if (spi_register_driver(&ls7366r_driver)) {
printk("counter - Error! Could not load spi driver\n");
return -1;
}
printk("counter - Loading the interrupt driver...\n");
if(platform_driver_register(&interrupt_driver)) {
printk("counter - Error! Could not load interrupt driver\n");
return -1;
}
return 0;
}
static void __exit my_exit(void) {
printk("counter - Unloading the leds driver...\n");
platform_driver_unregister(&leds_driver);
printk("counter - Unloading the ls7366r driver...\n");
spi_unregister_driver(&ls7366r_driver);
printk("counter - Unloading the interrupt driver...\n");
platform_driver_unregister(&interrupt_driver);
printk("counter - Unloading IO subsystem...\n");
io_exit();
}
module_init(my_init);
module_exit(my_exit);