-
Notifications
You must be signed in to change notification settings - Fork 5
/
helloworld_probe.c
51 lines (46 loc) · 1.27 KB
/
helloworld_probe.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/of_platform.h>
//
// Module entry point
//
static int helloworld_probe(struct platform_device *pdev) {
pr_info("Helloworld_module: probe\n");
return 0;
}
//
// Module exit point
//
static int helloworld_remove(struct platform_device *pdev) {
pr_info("Helloworld_module: remove\n");
return 0;
}
// Need to add following in DTS file to confirm
// that probe has been invoked the linux kernel.
// helloworld {
// compatible = "helloworld,helloworld-probe";
// status = "ok";
// };
static const struct of_device_id hellworld_driver_match_table[] = {
{ .compatible = "helloworld,helloworld-probe" },
{}
};
MODULE_DEVICE_TABLE(of, hellworld_driver_match_table);
static struct platform_driver hellworld_driver = {
.probe = helloworld_probe,
.remove = helloworld_remove,
.driver = {
.name = "helloworld-probe",
.of_match_table = of_match_ptr(hellworld_driver_match_table),
}
};
module_platform_driver(hellworld_driver);
//
// Setup module info
//
MODULE_VERSION("0.0.1");
MODULE_DESCRIPTION("Helloworld linux module");
MODULE_LICENSE("GPL");
MODULE_AUTHOR("aakbar5 <[email protected]>");