Goal
This module will create Ray_DBG directory in debugfs and create a file REG for read/write. it's similar to previous module(create /proc/Ray), but easier to use and need less line of code.
Code
Makefile
Usage
1. Insert module
$>insmod test_module.ko
$>dmesg | tail
[7501255.251763] Create Ray_DBG !
[7501255.251776] Create REG debug !
2. Mount debugfs
$>mount -t debugfs none /sys/kernel/debug
3. Read data
$>cat /sys/kernel/debug/Ray_DBG/REG
$>0x000000aa
4. Write data
$>echo 0xff> /sys/kernel/debug/Ray_DBG/REG
$>cat /sys/kernel/debug/Ray_DBG/REG
$>0x000000ff