static struct file_operations fops =
{
.owner = THIS_MODULE,
.open = temp_open,
.release = temp_release,
.read = temp_read,
// .write = temp_write,
//.ioctl = temp_ioctl,
};
static struct class *dev_class;//use this to create device node
static int temp_init(void)
{
major = register_chrdev(0,DEVICE_NAME,&fops);
if(major < 0)
{
printk("register %s error\n",DEVICE_NAME);
return 1;
}
printk("DEV Number:%d,%d\n",major,minor);
dev_class = class_create(THIS_MODULE,DEVICE_NAME);
if(dev_class == NULL)
{
printk("18B20 node create error\n");
printk("TODO:mknod /dev/%s c %d %d\n",DEVICE_NAME,major,minor);
}
else
{
device_create(dev_class,NULL,MKDEV(major,minor),"%s%d",DEVICE_NAME,minor);
printk("/dev/%s%d register sucess\n",DEVICE_NAME,minor);
}
return 0;
}
static void temp_exit(void)
{
if(dev_class)
{
device_destroy(dev_class,MKDEV(major,minor));
class_destroy(dev_class);
}
上一页 [1] [2] [3] [4] [5] [6] [7] 下一页