当前位置: 技术问答>linux和unix
关于驱动的一个问题 <asm/hardware.h>没有那个文件
来源: 互联网 发布时间:2016-12-22
本文导语: 这是.c文件 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define SIMPLE_CHAR_MAJOR 233 // ------------------- READ ------------------------ static ssize_t simplechar_...
这是.c文件
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define SIMPLE_CHAR_MAJOR 233
// ------------------- READ ------------------------
static ssize_t simplechar_read (struct file * file ,char *buf, size_t count, loff_t
*offset)
{
printk ("simplechar_read has been called n");
return 0;
}
// ------------------- WRITE -----------------------
static ssize_t simplechar_write (struct file * file ,const char *buf, size_t count,
loff_t *offset)
{
printk ("simplechar_write has been called n");
return 0;
}
// ------------------- IOCTL -----------------------
int simplechar_ioctl (struct inode * inode ,struct file * file, unsigned int cmd,
unsigned long arg)
{
printk ("simplechar_ioctl has been called n");
return 0;
}
// ------------------- OPEN ------------------------
static int simplechar_open (struct inode * inode ,struct file * file)
{
printk ("simplechar_open has been calledn");
return 0;
}
// ------------------- RELEASE/CLOSE ---------------
static int simplechar_release (struct inode * inode ,struct file * file)
{
printk ("simplechar_release has been called n");
return 0;
}
static struct file_operations simple_char_ops = {
.owner = THIS_MODULE,
.read = simplechar_read,
.write = simplechar_write,
.ioctl = simplechar_ioctl,
.open = simplechar_open,
.release = simplechar_release,
};
static int __init simplechar_init(void)
{
int ret = -ENODEV;
printk ("simplechar_init… …n");
ret = register_chrdev(SIMPLE_CHAR_MAJOR, "simple_char", &simple_char_ops);
if( ret
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define SIMPLE_CHAR_MAJOR 233
// ------------------- READ ------------------------
static ssize_t simplechar_read (struct file * file ,char *buf, size_t count, loff_t
*offset)
{
printk ("simplechar_read has been called n");
return 0;
}
// ------------------- WRITE -----------------------
static ssize_t simplechar_write (struct file * file ,const char *buf, size_t count,
loff_t *offset)
{
printk ("simplechar_write has been called n");
return 0;
}
// ------------------- IOCTL -----------------------
int simplechar_ioctl (struct inode * inode ,struct file * file, unsigned int cmd,
unsigned long arg)
{
printk ("simplechar_ioctl has been called n");
return 0;
}
// ------------------- OPEN ------------------------
static int simplechar_open (struct inode * inode ,struct file * file)
{
printk ("simplechar_open has been calledn");
return 0;
}
// ------------------- RELEASE/CLOSE ---------------
static int simplechar_release (struct inode * inode ,struct file * file)
{
printk ("simplechar_release has been called n");
return 0;
}
static struct file_operations simple_char_ops = {
.owner = THIS_MODULE,
.read = simplechar_read,
.write = simplechar_write,
.ioctl = simplechar_ioctl,
.open = simplechar_open,
.release = simplechar_release,
};
static int __init simplechar_init(void)
{
int ret = -ENODEV;
printk ("simplechar_init… …n");
ret = register_chrdev(SIMPLE_CHAR_MAJOR, "simple_char", &simple_char_ops);
if( ret