当前位置: 技术问答>linux和unix
驱动写函数调用失败..........
来源: 互联网 发布时间:2016-06-28
本文导语: 驱动代码如下: #define __NO_VERSION__ #include #include #include #include #include #include #include #include #include unsigned int test_major = 0; static ssize_t write_test(struct file *file, const char __user *buf, size_t co...
驱动代码如下:
#define __NO_VERSION__
#include
#include
#include
#include
#include
#include
#include
#include
#include
unsigned int test_major = 0;
static ssize_t write_test(struct file *file,
const char __user *buf,
size_t count,
loff_t * pos)
{
return 0;
}
static int open_test(struct inode *inode,struct file *file )
{
try_module_get(THIS_MODULE);
return 0;
}
static void release_test(struct inode *inode,struct file *file )
{
module_put(THIS_MODULE);
}
struct file_operations test_fops = {
.owner = THIS_MODULE,
.write = write_test,
.open = open_test,
.release = release_test,
};
int init_test(void)
{
int result;
result = register_chrdev(0, "test", &test_fops);
if (result
#define __NO_VERSION__
#include
#include
#include
#include
#include
#include
#include
#include
#include
unsigned int test_major = 0;
static ssize_t write_test(struct file *file,
const char __user *buf,
size_t count,
loff_t * pos)
{
return 0;
}
static int open_test(struct inode *inode,struct file *file )
{
try_module_get(THIS_MODULE);
return 0;
}
static void release_test(struct inode *inode,struct file *file )
{
module_put(THIS_MODULE);
}
struct file_operations test_fops = {
.owner = THIS_MODULE,
.write = write_test,
.open = open_test,
.release = release_test,
};
int init_test(void)
{
int result;
result = register_chrdev(0, "test", &test_fops);
if (result