This section provides an overview of what linux-device-driver is, and why a developer might want to use it.
It should also mention any large subjects within linux-device-driver, and link out to the related topics. Since the Documentation for linux-device-driver is new, you may need to create initial versions of those related topics.
hello_world.c
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#define AUTHOR "Bruce Lee"
#define DESC "Hello World driver"
static int __init init(void)
{
printk(KERN_DEBUG "Hello World\n");
return 0;
}
static void __exit deinit(void)
{
printk(KERN_DEBUG "Goodbye World\n");
}
module_init(init);
module_exit(deinit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR(AUTHOR);
MODULE_DESCRIPTION(DESC);
Makefile:
KDIR ?= /lib/modules/`uname -r`/build
obj-m += hello_world.o
all:
make -C $(KDIR) M=$(PWD) modules
clean:
make -C $(KDIR) M=$(PWD) clean
How to compile:
$ make
How to insert the module:
$ sudo insmod hello_world.ko
How to see print messages
$ dmesg
How to list module/s
$ lsmod | grep hello_worls
How to remove the module
$ sudo rmmod hello_world
Detailed instructions on getting linux-device-driver set up or installed.