30 lines
507 B
C
30 lines
507 B
C
#include <linux/kernel.h>
|
|
#include <linux/module.h>
|
|
#include <linux/delay.h>
|
|
#include <linux/slab.h>
|
|
|
|
MODULE_LICENSE("GPL");
|
|
MODULE_AUTHOR("42");
|
|
MODULE_DESCRIPTION("A module that does work");
|
|
|
|
|
|
static int do_work(int *nbLoop)
|
|
{
|
|
int x;
|
|
for (x = 0; x < *nbLoop; ++x) {
|
|
udelay(10);
|
|
}
|
|
if (*nbLoop > 10)
|
|
pr_info("do_work(): slept a long time\n");
|
|
return(x * *nbLoop);
|
|
}
|
|
|
|
static int __init module_example_42_init(void)
|
|
{
|
|
int x = 10;
|
|
x = do_work(&x);
|
|
return x;
|
|
}
|
|
|
|
module_init(module_example_42_init);
|