赞
踩
当然,在exit函数中要把创建的class移除:
device_destroy(myclass, MKDEV(major_num, 0)); //delete device node under /dev
class_destroy(myclass);
方法二,在脚本里
#!/bin/ash
rm -rf /tmp/dev/
mkdir /tmp/
mkdir /tmp/dev/
path="/lib/modules/2.6.32/kernel/drivers/char/dc/cxon2"
module="hx170dec"
device="/tmp/dev/hx170"
mode="666"
echo
#insert module
insmod $path/$module.ko base_port=0xf00c4000 irq=58 || exit 1
echo "module $module inserted"
#remove old nod
rm -f $device
#read the major asigned at loading time
major=`cat /proc/devices | grep $module | cut -c1-3`
echo "$module major = $major"
#create dev node
mknod $device c $major 0
echo "node $device created"
#give all 'rw' access
chmod $mode $device
echo "set node access to $mode"
#the end
echo
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。