mirror of
https://github.com/gatieme/LDD-LinuxDeviceDrivers.git
synced 2026-08-18 09:07:43 +08:00
seq_file_exam and oops...
This commit is contained in:
@@ -1,18 +1,81 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
#
|
||||
# Makefile for the LDD-LinuxDeviceDrivers.
|
||||
#
|
||||
# Author: gatieme
|
||||
# Create: 2016-07-29 15:50:46
|
||||
# Last modified: 2016-07-29 16:10:29
|
||||
# Description:
|
||||
# This program is loaded as a kernel(v2.6.18 or later) module.
|
||||
# Use "make install" to load it into kernel.
|
||||
# Use "make remove" to remove the module out of kernel.
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
|
||||
ROOT=..
|
||||
#PLATFORM=$(shell $(ROOT)/systype.sh)
|
||||
#include $(ROOT)/Make.defines.$(PLATFORM)
|
||||
|
||||
# my driver description
|
||||
DRIVER_VERSION := "1.0.0"
|
||||
DRIVER_AUTHOR := "Gatieme @ AderStep Inc..."
|
||||
DRIVER_DESC := "Linux input module for Elo MultiTouch(MT) devices"
|
||||
DRIVER_LICENSE := "Dual BSD/GPL"
|
||||
|
||||
|
||||
MODULE_NAME := seq_file_exam
|
||||
EXTRA_CFLAGS += -g
|
||||
|
||||
|
||||
|
||||
ifneq ($(KERNELRELEASE),)
|
||||
|
||||
obj-m := seq_file_exam.o
|
||||
|
||||
|
||||
|
||||
obj-m := $(MODULE_NAME).o
|
||||
|
||||
else
|
||||
|
||||
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
|
||||
#KERNELDIR ?= /home/gatieme/Work/Kernel/linux-headers-3.14-desktop/
|
||||
|
||||
PWD := $(shell pwd)
|
||||
|
||||
all:
|
||||
modules:
|
||||
make -C $(KERNELDIR) M=$(PWD) modules
|
||||
gcc test.c -o test
|
||||
|
||||
modules_install:
|
||||
make -C $(KERNELDIR) M=$(PWD) modules_install
|
||||
|
||||
|
||||
|
||||
insmod:
|
||||
sudo insmod $(MODULE_NAME).ko
|
||||
|
||||
reinsmod:
|
||||
sudo rmmod $(MODULE_NAME)
|
||||
sudo insmod $(MODULE_NAME).ko
|
||||
|
||||
github:
|
||||
cd $(ROOT) && make github
|
||||
|
||||
rmmod:
|
||||
sudo rmmod $(MODULE_NAME)
|
||||
|
||||
test :
|
||||
cat /sys/kernel/debug/mydebug/a
|
||||
cat /sys/kernel/debug/mydebug/b
|
||||
cat /sys/kernel/debug/mydebug/subdir/c
|
||||
|
||||
clean:
|
||||
make -C $(KERNELDIR) M=$(PWD) clean
|
||||
rm -rf ./test
|
||||
rm -f modules.order Module.symvers Module.markers
|
||||
|
||||
.PHNOY:
|
||||
modules modules_install clean
|
||||
|
||||
|
||||
|
||||
endif
|
||||
|
||||
|
||||
@@ -7,10 +7,12 @@
|
||||
|
||||
#include <linux/percpu.h>
|
||||
#include <linux/sched.h>
|
||||
|
||||
#include <linux/version.h>
|
||||
|
||||
|
||||
static struct proc_dir_entry *entry;
|
||||
#define PROC_NAME "exam_seq_file"
|
||||
|
||||
|
||||
static void *l_start(struct seq_file *m, loff_t * pos)
|
||||
{
|
||||
@@ -71,17 +73,29 @@ static struct file_operations exam_seq_fops = {
|
||||
|
||||
static int __init exam_seq_init(void)
|
||||
{
|
||||
|
||||
entry = create_proc_entry("exam_esq_file", 0666, NULL);
|
||||
if (entry)
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0))
|
||||
entry = proc_create(PROC_NAME, 0, NULL, &exam_seq_fops);
|
||||
#else
|
||||
entry = create_proc_entry(PROC_NAME, 0666, NULL);
|
||||
if (entry != NULL)
|
||||
entry->proc_fops = &exam_seq_fops;
|
||||
#endif
|
||||
|
||||
if(entry == NULL)
|
||||
{
|
||||
remove_proc_entry(PROC_NAME, NULL);
|
||||
printk(KERN_DEBUG "Error: Could not initialize /proc/%s\n", PROC_NAME);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit exam_seq_exit(void)
|
||||
{
|
||||
remove_proc_entry("exam_esq_file", NULL);
|
||||
remove_proc_entry(PROC_NAME, NULL);
|
||||
printk(KERN_DEBUG "/proc/%s removed\n", PROC_NAME);
|
||||
|
||||
}
|
||||
|
||||
module_init(exam_seq_init);
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
|
||||
[WiKipedia](https://en.wikipedia.org/wiki/Linux_kernel_oops)
|
||||
|
||||
[Oops中的error code解释](http://blog.csdn.net/mozun1/article/details/53306714)
|
||||
|
||||
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="知识共享许可协议" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" /></a>
|
||||
<br>
|
||||
本作品采用<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议</a>进行许可
|
||||
|
||||
Reference in New Issue
Block a user