2009年5月25日 星期一

GPIO Driver

老了,紀錄在這邊一下

1. Insert Module
#cd mtp_ios
#make --> mtp_io.ko
#insmod mtp_io.ko
#cat /proc/devices | grep mtp_io (Driver register name) --> get module major number 121
#mknod /dev/mtp_io0 (Ap open device name) 121 0

2. Compile AP
#cd mtp_api
#make --> mtp_api.so
#cp mtp_api.so /usr/lib/.

#cd test_mtp
#make
#./test_mtp

done!!

Character Device Driver (unregister_chrdev)

今天再編譯Char Driver時遇到一個錯誤
error: void value not ignored as it ought to be
意思是我把一個沒有回傳值的函數當成有回傳值來使用

看了一下程式碼,發現是在這行
if (unregister_chrdev(DEV_MAJOR, DEV_NAME))

翻了一下書,Driver老師講義和聖經黑馬書上是定義如下。
int unregister_chrdev(unsigned int major, const char *name)

但是我去看了一下在 include/linux/fs.h下的定義,卻是以下
extern void unregister_chredv(unsigned int, const char*)

所以在新版本核心提供的函式~他是沒有回傳值的!!